82 |
|
|
83 |
|
static bool palette_changed = false; // Flag: Palette changed, redraw thread must update palette |
84 |
|
static bool ctrl_down = false; // Flag: Ctrl key pressed |
85 |
+ |
static bool caps_on = false; // Flag: Caps Lock on |
86 |
|
static bool quit_full_screen = false; // Flag: DGA close requested from redraw thread |
87 |
|
static volatile bool quit_full_screen_ack = false; // Acknowledge for quit_full_screen |
88 |
|
static bool emerg_quit = false; // Flag: Ctrl-Esc pressed, emergency quit requested from MacOS thread |
1485 |
|
return -1; |
1486 |
|
} |
1487 |
|
|
1488 |
< |
static int event2keycode(XKeyEvent &ev) |
1488 |
> |
static int event2keycode(XKeyEvent &ev, bool key_down) |
1489 |
|
{ |
1490 |
|
KeySym ks; |
1490 |
– |
int as; |
1491 |
|
int i = 0; |
1492 |
|
|
1493 |
|
do { |
1494 |
|
ks = XLookupKeysym(&ev, i++); |
1495 |
< |
as = kc_decode(ks); |
1496 |
< |
if (as != -1) |
1495 |
> |
int as = kc_decode(ks); |
1496 |
> |
if (as >= 0) |
1497 |
> |
return as; |
1498 |
> |
if (as == -2) |
1499 |
|
return as; |
1500 |
|
} while (ks != NoSymbol); |
1501 |
|
|
1570 |
|
|
1571 |
|
// Keyboard |
1572 |
|
case KeyPress: { |
1573 |
< |
int code = event2keycode(event.xkey); |
1574 |
< |
if (use_keycodes && code != -1) |
1575 |
< |
code = keycode_table[event.xkey.keycode & 0xff]; |
1576 |
< |
if (code != -1) { |
1573 |
> |
int code = -1; |
1574 |
> |
if (use_keycodes) { |
1575 |
> |
if (event2keycode(event.xkey, true) != -2) // This is called to process the hotkeys |
1576 |
> |
code = keycode_table[event.xkey.keycode & 0xff]; |
1577 |
> |
} else |
1578 |
> |
code = event2keycode(event.xkey, true); |
1579 |
> |
if (code >= 0) { |
1580 |
|
if (!emul_suspended) { |
1581 |
< |
ADBKeyDown(code); |
1581 |
> |
if (code == 0x39) { // Caps Lock pressed |
1582 |
> |
if (caps_on) { |
1583 |
> |
ADBKeyUp(code); |
1584 |
> |
caps_on = false; |
1585 |
> |
} else { |
1586 |
> |
ADBKeyDown(code); |
1587 |
> |
caps_on = true; |
1588 |
> |
} |
1589 |
> |
} else |
1590 |
> |
ADBKeyDown(code); |
1591 |
|
if (code == 0x36) |
1592 |
|
ctrl_down = true; |
1593 |
|
} else { |
1598 |
|
break; |
1599 |
|
} |
1600 |
|
case KeyRelease: { |
1601 |
< |
int code = event2keycode(event.xkey); |
1602 |
< |
if (use_keycodes && code != 1) |
1603 |
< |
code = keycode_table[event.xkey.keycode & 0xff]; |
1604 |
< |
if (code != -1) { |
1601 |
> |
int code = -1; |
1602 |
> |
if (use_keycodes) { |
1603 |
> |
if (event2keycode(event.xkey, false) != -2) // This is called to process the hotkeys |
1604 |
> |
code = keycode_table[event.xkey.keycode & 0xff]; |
1605 |
> |
} else |
1606 |
> |
code = event2keycode(event.xkey, false); |
1607 |
> |
if (code >= 0 && code != 0x39) { // Don't propagate Caps Lock releases |
1608 |
|
ADBKeyUp(code); |
1609 |
|
if (code == 0x36) |
1610 |
|
ctrl_down = false; |