typedef struct emulator_config_info {
+ char emulator_name[256];
int lcd_size_w;
int lcd_size_h;
//TODO:
@Override
public void keyReleased( KeyEvent e ) {
logger.info( "key released. key event:" + e );
- int keyCode = e.keyCode;
+ int keyCode = e.keyCode | e.stateMask;
KeyEventData keyEventData = new KeyEventData( KeyEventType.RELEASED.value(), keyCode );
communicator.sendToQEMU( SendCommand.SEND_KEY_EVENT, keyEventData );
@Override
public void keyPressed( KeyEvent e ) {
logger.info( "key pressed. key event:" + e );
- int keyCode = e.keyCode;
+ int keyCode = e.keyCode | e.stateMask;
KeyEventData keyEventData = new KeyEventData( KeyEventType.PRESSED.value(), keyCode );
communicator.sendToQEMU( SendCommand.SEND_KEY_EVENT, keyEventData );
}
int javakeycode_to_scancode(int java_keycode)
{
+ int state_mask = java_keycode & JAVA_KEYCODE_BIT;
int vk = java_keycode & JAVA_KEY_MASK;
+ int ctrl_mask = java_keycode & JAVA_KEYCODE_BIT_CTRL;
+ int shift_mask = java_keycode & JAVA_KEYCODE_BIT_SHIFT;
+ int alt_mask = java_keycode & JAVA_KEYCODE_BIT_ALT;
+
/*#ifdef _WIN32
return MapVirtualKey(vk, MAPVK_VK_TO_VSC);
#endif*/
- if (java_keycode & JAVA_KEYCODE_BIT) {
- if (vk >= JAVA_KEY_F1 && vk <=JAVA_KEY_F20) { //function keys
+ if (vk == 0) { //meta keys
+ if (java_keycode == JAVA_KEYCODE_BIT_CTRL) { //ctrl key
+ return 29;
+ } else if (java_keycode == JAVA_KEYCODE_BIT_SHIFT) { //shift key
+ return 42;
+ } else if (java_keycode == JAVA_KEYCODE_BIT_ALT) { //alt key
+ return 56;
+ } else {
+ return -1;
+ }
+ }
+
+ if (state_mask != 0)
+ { //non-character keys
+ if (vk >= JAVA_KEY_F1 && vk <= JAVA_KEY_F20) { //function keys
vk += 255;
} else { //special keys
switch(vk) {
break;
}
}
- //TODO:
- //meta keys
+
+ }
+ else //state_mask == 0
+ { //character keys
+ if (ctrl_mask == 0 && shift_mask != 0 && alt_mask == 0) { //shift + character keys
+ switch(vk) {
+ case '`' :
+ vk = '~';
+ break;
+ case '1' :
+ vk = '!';
+ break;
+ case '2' :
+ vk = '@';
+ break;
+ case '3' :
+ vk = '#';
+ break;
+ case '4' :
+ vk = '$';
+ break;
+ case '5' :
+ vk = '%';
+ break;
+ case '6' :
+ vk = '^';
+ break;
+ case '7' :
+ vk = '&';
+ break;
+ case '8' :
+ vk = '*';
+ break;
+ case '9' :
+ vk = '(';
+ break;
+ case '0' :
+ vk = ')';
+ break;
+ case '-' :
+ vk = '_';
+ break;
+ case '=' :
+ vk = '+';
+ break;
+ case '\\' :
+ vk = '|';
+ break;
+ default :
+ if (vk > 32 && vk < KEY_MAX) { //text keys
+ vk -= 32; //case sensitive offset
+ } else {
+ return -1;
+ }
+ break;
+ }
+ }
+
}
return vkkey2scancode[vk];
#define KEY_NPAGE 0522
#define KEY_PPAGE 0523
#define KEY_ENTER 0527
+#define KEY_BTAB 0541
#define KEY_END 0550
-
static const int vkkey2scancode[KEY_MAX] = {
[0 ... (KEY_MAX - 1)] = -1,
['.'] = 52,
['/'] = 53,
- [' '] = 57,
+ [' '] = 57, /* Space */
[KEY_F(1)] = 59, /* Function Key 1 */
[KEY_F(2)] = 60, /* Function Key 2 */
[KEY_IC] = 82, /* Insert */
[KEY_DC] = 83, /* Delete */
-#if 0
['!'] = 2 | SHIFT,
['@'] = 3 | SHIFT,
['#'] = 4 | SHIFT,
['>'] = 52 | SHIFT,
['?'] = 53 | SHIFT,
+#if 0
[KEY_F(13)] = 59 | SHIFT, /* Shift + Function Key 1 */
[KEY_F(14)] = 60 | SHIFT, /* Shift + Function Key 2 */
[KEY_F(15)] = 61 | SHIFT, /* Shift + Function Key 3 */