Commit bbbb2f0af96dbf6706c90209ebb16dc5b87d32e1
1 parent
e32664fb
Fix Caps lock and Num lock handling
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3209 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
26 additions
and
3 deletions
hw/slavio_serial.c
... | ... | @@ -95,7 +95,7 @@ typedef struct ChannelState { |
95 | 95 | uint8_t rx, tx, wregs[16], rregs[16]; |
96 | 96 | SERIOQueue queue; |
97 | 97 | CharDriverState *chr; |
98 | - int e0_mode, led_mode; | |
98 | + int e0_mode, led_mode, caps_lock_mode, num_lock_mode; | |
99 | 99 | } ChannelState; |
100 | 100 | |
101 | 101 | struct SerialState { |
... | ... | @@ -195,7 +195,7 @@ static void slavio_serial_reset_chn(ChannelState *s) |
195 | 195 | s->rx = s->tx = 0; |
196 | 196 | s->rxint = s->txint = 0; |
197 | 197 | s->rxint_under_svc = s->txint_under_svc = 0; |
198 | - s->e0_mode = s->led_mode = 0; | |
198 | + s->e0_mode = s->led_mode = s->caps_lock_mode = s->num_lock_mode = 0; | |
199 | 199 | clear_queue(s); |
200 | 200 | } |
201 | 201 | |
... | ... | @@ -651,9 +651,32 @@ static void sunkbd_event(void *opaque, int ch) |
651 | 651 | int release = ch & 0x80; |
652 | 652 | |
653 | 653 | KBD_DPRINTF("Untranslated keycode %2.2x (%s)\n", ch, release? "release" : "press"); |
654 | - if (ch == 0xe0) { | |
654 | + switch (ch) { | |
655 | + case 58: // Caps lock press | |
656 | + s->caps_lock_mode ^= 1; | |
657 | + if (s->caps_lock_mode == 2) | |
658 | + return; // Drop second press | |
659 | + break; | |
660 | + case 69: // Num lock press | |
661 | + s->num_lock_mode ^= 1; | |
662 | + if (s->num_lock_mode == 2) | |
663 | + return; // Drop second press | |
664 | + break; | |
665 | + case 186: // Caps lock release | |
666 | + s->caps_lock_mode ^= 2; | |
667 | + if (s->caps_lock_mode == 3) | |
668 | + return; // Drop first release | |
669 | + break; | |
670 | + case 197: // Num lock release | |
671 | + s->num_lock_mode ^= 2; | |
672 | + if (s->num_lock_mode == 3) | |
673 | + return; // Drop first release | |
674 | + break; | |
675 | + case 0xe0: | |
655 | 676 | s->e0_mode = 1; |
656 | 677 | return; |
678 | + default: | |
679 | + break; | |
657 | 680 | } |
658 | 681 | if (s->e0_mode) { |
659 | 682 | s->e0_mode = 0; | ... | ... |