spice-input.c (e01151de165070c25a1b202e9e2392950bd7c8da) spice-input.c (e92316ad3074aaf13bced21f03c98969ca6f73a9)
1/*
2 * Copyright (C) 2010 Red Hat, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 or
7 * (at your option) version 3 of the License.
8 *

--- 36 unchanged lines hidden (view full) ---

45 .base.major_version = SPICE_INTERFACE_KEYBOARD_MAJOR,
46 .base.minor_version = SPICE_INTERFACE_KEYBOARD_MINOR,
47 .push_scan_freg = kbd_push_key,
48 .get_leds = kbd_get_leds,
49};
50
51static void kbd_push_key(SpiceKbdInstance *sin, uint8_t scancode)
52{
1/*
2 * Copyright (C) 2010 Red Hat, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 or
7 * (at your option) version 3 of the License.
8 *

--- 36 unchanged lines hidden (view full) ---

45 .base.major_version = SPICE_INTERFACE_KEYBOARD_MAJOR,
46 .base.minor_version = SPICE_INTERFACE_KEYBOARD_MINOR,
47 .push_scan_freg = kbd_push_key,
48 .get_leds = kbd_get_leds,
49};
50
51static void kbd_push_key(SpiceKbdInstance *sin, uint8_t scancode)
52{
53 static const uint8_t pauseseq[] = { 0xe1, 0x1d, 0x45, 0xe1, 0x9d, 0xc5 };
53 QemuSpiceKbd *kbd = container_of(sin, QemuSpiceKbd, sin);
54 int keycode;
55 bool up;
56
57 if (scancode == SCANCODE_EMUL0) {
58 kbd->emul0 = true;
59 return;
60 }
54 QemuSpiceKbd *kbd = container_of(sin, QemuSpiceKbd, sin);
55 int keycode;
56 bool up;
57
58 if (scancode == SCANCODE_EMUL0) {
59 kbd->emul0 = true;
60 return;
61 }
61 keycode = scancode & ~SCANCODE_UP;
62 up = scancode & SCANCODE_UP;
63 if (kbd->emul0) {
64 kbd->emul0 = false;
65 keycode |= SCANCODE_GREY;
66 }
67
62
68 if (scancode == SCANCODE_EMUL1) {
63 if (scancode == pauseseq[kbd->pauseseq]) {
69 kbd->pauseseq++;
64 kbd->pauseseq++;
70 return;
71 } else if (kbd->pauseseq == 1) {
72 if (keycode == 0x1d) {
73 kbd->pauseseq++;
74 return;
75 } else {
65 if (kbd->pauseseq == G_N_ELEMENTS(pauseseq)) {
66 qemu_input_event_send_key_qcode(NULL, Q_KEY_CODE_PAUSE, true);
76 kbd->pauseseq = 0;
77 }
67 kbd->pauseseq = 0;
68 }
78 } else if (kbd->pauseseq == 2) {
79 if (keycode == 0x45) {
80 qemu_input_event_send_key_qcode(NULL, Q_KEY_CODE_PAUSE, !up);
81 kbd->pauseseq = 0;
82 return;
83 }
69 return;
70 } else {
84 kbd->pauseseq = 0;
85 }
86
71 kbd->pauseseq = 0;
72 }
73
74 keycode = scancode & ~SCANCODE_UP;
75 up = scancode & SCANCODE_UP;
76 if (kbd->emul0) {
77 kbd->emul0 = false;
78 keycode |= SCANCODE_GREY;
79 }
80
87 qemu_input_event_send_key_number(NULL, keycode, !up);
88}
89
90static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
91{
92 QemuSpiceKbd *kbd = container_of(sin, QemuSpiceKbd, sin);
93 return kbd->ledstate;
94}

--- 172 unchanged lines hidden ---
81 qemu_input_event_send_key_number(NULL, keycode, !up);
82}
83
84static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
85{
86 QemuSpiceKbd *kbd = container_of(sin, QemuSpiceKbd, sin);
87 return kbd->ledstate;
88}

--- 172 unchanged lines hidden ---