mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-09 07:30:05 +00:00
Manage keyboard
This commit is contained in:
parent
5963764d98
commit
5797b03ea2
63
second/keyboard.c
Normal file
63
second/keyboard.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "misc.h"
|
||||||
|
#include "glue.h"
|
||||||
|
#include "keyboard.h"
|
||||||
|
|
||||||
|
#define test_bit(n,m) (((char*)(m))[(n) / 8] & (1L << (n % 8)))
|
||||||
|
|
||||||
|
enum keycode {
|
||||||
|
keycode_command = 0x37,
|
||||||
|
keycode_shift = 0x38,
|
||||||
|
keycode_capslock = 0x39,
|
||||||
|
keycode_option = 0x3A,
|
||||||
|
keycode_control = 0x3B,
|
||||||
|
|
||||||
|
keycode_last = 0x80
|
||||||
|
};
|
||||||
|
|
||||||
|
void keyboard_get_key(int *modifiers, int *code)
|
||||||
|
{
|
||||||
|
KeyMap keyboard;
|
||||||
|
int keycode;
|
||||||
|
|
||||||
|
GetKeys(keyboard);
|
||||||
|
|
||||||
|
/* modifier keys */
|
||||||
|
|
||||||
|
*modifiers = 0;
|
||||||
|
if (test_bit(keycode_command, keyboard))
|
||||||
|
*modifiers |= modifiers_command;
|
||||||
|
if (test_bit(keycode_shift, keyboard))
|
||||||
|
*modifiers |= modifiers_command;
|
||||||
|
if (test_bit(keycode_capslock, keyboard))
|
||||||
|
*modifiers |= modifiers_command;
|
||||||
|
if (test_bit(keycode_option, keyboard))
|
||||||
|
*modifiers |= modifiers_command;
|
||||||
|
if (test_bit(keycode_control, keyboard))
|
||||||
|
*modifiers |= modifiers_command;
|
||||||
|
|
||||||
|
/* other keys */
|
||||||
|
|
||||||
|
for (keycode = 0; keycode < keycode_last; keycode++)
|
||||||
|
{
|
||||||
|
/* modifiers */
|
||||||
|
|
||||||
|
if ( (keycode == keycode_command) ||
|
||||||
|
(keycode == keycode_shift) ||
|
||||||
|
(keycode == keycode_capslock) ||
|
||||||
|
(keycode == keycode_option) ||
|
||||||
|
(keycode == keycode_control) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* other keys */
|
||||||
|
|
||||||
|
if (test_bit(keycode, keyboard))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*code = keycode;
|
||||||
|
}
|
16
second/keyboard.h
Normal file
16
second/keyboard.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
enum modifiers_mask {
|
||||||
|
modifiers_command = 0x01,
|
||||||
|
modifiers_shift = 0x02,
|
||||||
|
modifiers_capslock = 0x04,
|
||||||
|
modifiers_option = 0x08,
|
||||||
|
modifiers_control = 0x10,
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void keyboard_get_key(int *modifiers, int *code);
|
Loading…
Reference in New Issue
Block a user