* [Qemu-devel] [PATCH v3] PS/2 keyboard Scancode Set 3 support
@ 2011-02-14 12:59 Roy Tam
2011-02-14 13:23 ` Kevin Wolf
2011-02-20 18:19 ` Aurelien Jarno
0 siblings, 2 replies; 4+ messages in thread
From: Roy Tam @ 2011-02-14 12:59 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 3151 bytes --]
The following patch adds PS/2 keyboard Scancode Set 3 support.
Sign-off-by: Roy Tam <roytam@gmail.com>
--
v3: change from switch to array, more style fixes
v2: checkpatch.pl style fixes
diff --git a/hw/ps2.c b/hw/ps2.c
index 762bb00..da4737a 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -110,14 +110,24 @@ typedef struct {
/* Table to convert from PC scancodes to raw scancodes. */
static const unsigned char ps2_raw_keycode[128] = {
- 0,118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85,102, 13,
- 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27,
- 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42,
- 50, 49, 58, 65, 73, 74, 89,124, 17, 41, 88, 5, 6, 4, 12, 3,
- 11, 2, 10, 1, 9,119,126,108,117,125,123,107,115,116,121,105,
- 114,122,112,113,127, 96, 97,120, 7, 15, 23, 31, 39, 47, 55, 63,
- 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87,111,
- 19, 25, 57, 81, 83, 92, 95, 98, 99,100,101,103,104,106,109,110
+ 0, 118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85, 102, 13,
+ 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27,
+ 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42,
+ 50, 49, 58, 65, 73, 74, 89, 124, 17, 41, 88, 5, 6, 4, 12, 3,
+ 11, 2, 10, 1, 9, 119, 126, 108, 117, 125, 123, 107, 115, 116, 121, 105,
+114, 122, 112, 113, 127, 96, 97, 120, 7, 15, 23, 31, 39, 47, 55, 63,
+ 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87, 111,
+ 19, 25, 57, 81, 83, 92, 95, 98, 99, 100, 101, 103, 104, 106, 109, 110
+};
+static const unsigned char ps2_raw_keycode_set3[128] = {
+ 0, 8, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85, 102, 13,
+ 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 17, 28, 27,
+ 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 92, 26, 34, 33, 42,
+ 50, 49, 58, 65, 73, 74, 89, 126, 25, 41, 20, 7, 15, 23, 31, 39,
+ 47, 2, 63, 71, 79, 118, 95, 108, 117, 125, 132, 107, 115, 116, 124, 105,
+114, 122, 112, 113, 127, 96, 97, 86, 94, 15, 23, 31, 39, 47, 55, 63,
+ 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87, 111,
+ 19, 25, 57, 81, 83, 92, 95, 98, 99, 100, 101, 103, 104, 106, 109, 110
};
void ps2_queue(void *opaque, int b)
@@ -144,11 +154,15 @@ static void ps2_put_keycode(void *opaque, int keycode)
PS2KbdState *s = opaque;
/* XXX: add support for scancode sets 1 and 3 */
- if (!s->translate && keycode < 0xe0 && s->scancode_set == 2)
- {
- if (keycode & 0x80)
+ if (!s->translate && keycode < 0xe0 && s->scancode_set > 1) {
+ if (keycode & 0x80) {
ps2_queue(&s->common, 0xf0);
- keycode = ps2_raw_keycode[keycode & 0x7f];
+ }
+ if (s->scancode_set == 2) {
+ keycode = ps2_raw_keycode[keycode & 0x7f];
+ } else if (s->scancode_set == 3) {
+ keycode = ps2_raw_keycode_set3[keycode & 0x7f];
+ }
}
ps2_queue(&s->common, keycode);
}
[-- Attachment #2: ps2_scancode_set3.patch --]
[-- Type: application/octet-stream, Size: 2966 bytes --]
diff --git a/hw/ps2.c b/hw/ps2.c
index 762bb00..da4737a 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -110,14 +110,24 @@ typedef struct {
/* Table to convert from PC scancodes to raw scancodes. */
static const unsigned char ps2_raw_keycode[128] = {
- 0,118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85,102, 13,
- 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27,
- 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42,
- 50, 49, 58, 65, 73, 74, 89,124, 17, 41, 88, 5, 6, 4, 12, 3,
- 11, 2, 10, 1, 9,119,126,108,117,125,123,107,115,116,121,105,
- 114,122,112,113,127, 96, 97,120, 7, 15, 23, 31, 39, 47, 55, 63,
- 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87,111,
- 19, 25, 57, 81, 83, 92, 95, 98, 99,100,101,103,104,106,109,110
+ 0, 118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85, 102, 13,
+ 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27,
+ 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42,
+ 50, 49, 58, 65, 73, 74, 89, 124, 17, 41, 88, 5, 6, 4, 12, 3,
+ 11, 2, 10, 1, 9, 119, 126, 108, 117, 125, 123, 107, 115, 116, 121, 105,
+114, 122, 112, 113, 127, 96, 97, 120, 7, 15, 23, 31, 39, 47, 55, 63,
+ 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87, 111,
+ 19, 25, 57, 81, 83, 92, 95, 98, 99, 100, 101, 103, 104, 106, 109, 110
+};
+static const unsigned char ps2_raw_keycode_set3[128] = {
+ 0, 8, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85, 102, 13,
+ 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 17, 28, 27,
+ 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 92, 26, 34, 33, 42,
+ 50, 49, 58, 65, 73, 74, 89, 126, 25, 41, 20, 7, 15, 23, 31, 39,
+ 47, 2, 63, 71, 79, 118, 95, 108, 117, 125, 132, 107, 115, 116, 124, 105,
+114, 122, 112, 113, 127, 96, 97, 86, 94, 15, 23, 31, 39, 47, 55, 63,
+ 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87, 111,
+ 19, 25, 57, 81, 83, 92, 95, 98, 99, 100, 101, 103, 104, 106, 109, 110
};
void ps2_queue(void *opaque, int b)
@@ -144,11 +154,15 @@ static void ps2_put_keycode(void *opaque, int keycode)
PS2KbdState *s = opaque;
/* XXX: add support for scancode sets 1 and 3 */
- if (!s->translate && keycode < 0xe0 && s->scancode_set == 2)
- {
- if (keycode & 0x80)
+ if (!s->translate && keycode < 0xe0 && s->scancode_set > 1) {
+ if (keycode & 0x80) {
ps2_queue(&s->common, 0xf0);
- keycode = ps2_raw_keycode[keycode & 0x7f];
+ }
+ if (s->scancode_set == 2) {
+ keycode = ps2_raw_keycode[keycode & 0x7f];
+ } else if (s->scancode_set == 3) {
+ keycode = ps2_raw_keycode_set3[keycode & 0x7f];
+ }
}
ps2_queue(&s->common, keycode);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v3] PS/2 keyboard Scancode Set 3 support
2011-02-14 12:59 [Qemu-devel] [PATCH v3] PS/2 keyboard Scancode Set 3 support Roy Tam
@ 2011-02-14 13:23 ` Kevin Wolf
2011-02-20 18:19 ` Aurelien Jarno
1 sibling, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2011-02-14 13:23 UTC (permalink / raw)
To: Roy Tam; +Cc: qemu-devel
Am 14.02.2011 13:59, schrieb Roy Tam:
> The following patch adds PS/2 keyboard Scancode Set 3 support.
>
> Sign-off-by: Roy Tam <roytam@gmail.com>
> --
> v3: change from switch to array, more style fixes
> v2: checkpatch.pl style fixes
Looks much better now. :-)
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v3] PS/2 keyboard Scancode Set 3 support
2011-02-14 12:59 [Qemu-devel] [PATCH v3] PS/2 keyboard Scancode Set 3 support Roy Tam
2011-02-14 13:23 ` Kevin Wolf
@ 2011-02-20 18:19 ` Aurelien Jarno
2011-02-21 0:07 ` Roy Tam
1 sibling, 1 reply; 4+ messages in thread
From: Aurelien Jarno @ 2011-02-20 18:19 UTC (permalink / raw)
To: Roy Tam; +Cc: qemu-devel
On Mon, Feb 14, 2011 at 08:59:02PM +0800, Roy Tam wrote:
> The following patch adds PS/2 keyboard Scancode Set 3 support.
>
> Sign-off-by: Roy Tam <roytam@gmail.com>
> --
> v3: change from switch to array, more style fixes
> v2: checkpatch.pl style fixes
>
> diff --git a/hw/ps2.c b/hw/ps2.c
> index 762bb00..da4737a 100644
> --- a/hw/ps2.c
> +++ b/hw/ps2.c
> @@ -110,14 +110,24 @@ typedef struct {
>
> /* Table to convert from PC scancodes to raw scancodes. */
> static const unsigned char ps2_raw_keycode[128] = {
> - 0,118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85,102, 13,
> - 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27,
> - 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42,
> - 50, 49, 58, 65, 73, 74, 89,124, 17, 41, 88, 5, 6, 4, 12, 3,
> - 11, 2, 10, 1, 9,119,126,108,117,125,123,107,115,116,121,105,
> - 114,122,112,113,127, 96, 97,120, 7, 15, 23, 31, 39, 47, 55, 63,
> - 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87,111,
> - 19, 25, 57, 81, 83, 92, 95, 98, 99,100,101,103,104,106,109,110
> + 0, 118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85, 102, 13,
> + 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27,
> + 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42,
> + 50, 49, 58, 65, 73, 74, 89, 124, 17, 41, 88, 5, 6, 4, 12, 3,
> + 11, 2, 10, 1, 9, 119, 126, 108, 117, 125, 123, 107, 115, 116, 121, 105,
> +114, 122, 112, 113, 127, 96, 97, 120, 7, 15, 23, 31, 39, 47, 55, 63,
> + 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87, 111,
> + 19, 25, 57, 81, 83, 92, 95, 98, 99, 100, 101, 103, 104, 106, 109, 110
> +};
> +static const unsigned char ps2_raw_keycode_set3[128] = {
> + 0, 8, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85, 102, 13,
> + 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 17, 28, 27,
> + 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 92, 26, 34, 33, 42,
> + 50, 49, 58, 65, 73, 74, 89, 126, 25, 41, 20, 7, 15, 23, 31, 39,
> + 47, 2, 63, 71, 79, 118, 95, 108, 117, 125, 132, 107, 115, 116, 124, 105,
> +114, 122, 112, 113, 127, 96, 97, 86, 94, 15, 23, 31, 39, 47, 55, 63,
> + 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87, 111,
> + 19, 25, 57, 81, 83, 92, 95, 98, 99, 100, 101, 103, 104, 106, 109, 110
> };
>
> void ps2_queue(void *opaque, int b)
> @@ -144,11 +154,15 @@ static void ps2_put_keycode(void *opaque, int keycode)
> PS2KbdState *s = opaque;
>
> /* XXX: add support for scancode sets 1 and 3 */
This command should be updated to explain only set 1 has to be added.
> - if (!s->translate && keycode < 0xe0 && s->scancode_set == 2)
> - {
> - if (keycode & 0x80)
> + if (!s->translate && keycode < 0xe0 && s->scancode_set > 1) {
> + if (keycode & 0x80) {
> ps2_queue(&s->common, 0xf0);
> - keycode = ps2_raw_keycode[keycode & 0x7f];
> + }
> + if (s->scancode_set == 2) {
> + keycode = ps2_raw_keycode[keycode & 0x7f];
> + } else if (s->scancode_set == 3) {
> + keycode = ps2_raw_keycode_set3[keycode & 0x7f];
> + }
> }
> ps2_queue(&s->common, keycode);
> }
Otherwise looks fine.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v3] PS/2 keyboard Scancode Set 3 support
2011-02-20 18:19 ` Aurelien Jarno
@ 2011-02-21 0:07 ` Roy Tam
0 siblings, 0 replies; 4+ messages in thread
From: Roy Tam @ 2011-02-21 0:07 UTC (permalink / raw)
To: Aurelien Jarno; +Cc: qemu-devel
2011/2/21 Aurelien Jarno <aurelien@aurel32.net>:
> On Mon, Feb 14, 2011 at 08:59:02PM +0800, Roy Tam wrote:
>> The following patch adds PS/2 keyboard Scancode Set 3 support.
>>
>> Sign-off-by: Roy Tam <roytam@gmail.com>
>> --
>> v3: change from switch to array, more style fixes
>> v2: checkpatch.pl style fixes
>>
>> diff --git a/hw/ps2.c b/hw/ps2.c
>> index 762bb00..da4737a 100644
>> --- a/hw/ps2.c
>> +++ b/hw/ps2.c
>> @@ -110,14 +110,24 @@ typedef struct {
>>
>> /* Table to convert from PC scancodes to raw scancodes. */
>> static const unsigned char ps2_raw_keycode[128] = {
>> - 0,118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85,102, 13,
>> - 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27,
>> - 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42,
>> - 50, 49, 58, 65, 73, 74, 89,124, 17, 41, 88, 5, 6, 4, 12, 3,
>> - 11, 2, 10, 1, 9,119,126,108,117,125,123,107,115,116,121,105,
>> - 114,122,112,113,127, 96, 97,120, 7, 15, 23, 31, 39, 47, 55, 63,
>> - 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87,111,
>> - 19, 25, 57, 81, 83, 92, 95, 98, 99,100,101,103,104,106,109,110
>> + 0, 118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85, 102, 13,
>> + 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27,
>> + 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42,
>> + 50, 49, 58, 65, 73, 74, 89, 124, 17, 41, 88, 5, 6, 4, 12, 3,
>> + 11, 2, 10, 1, 9, 119, 126, 108, 117, 125, 123, 107, 115, 116, 121, 105,
>> +114, 122, 112, 113, 127, 96, 97, 120, 7, 15, 23, 31, 39, 47, 55, 63,
>> + 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87, 111,
>> + 19, 25, 57, 81, 83, 92, 95, 98, 99, 100, 101, 103, 104, 106, 109, 110
>> +};
>> +static const unsigned char ps2_raw_keycode_set3[128] = {
>> + 0, 8, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85, 102, 13,
>> + 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 17, 28, 27,
>> + 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 92, 26, 34, 33, 42,
>> + 50, 49, 58, 65, 73, 74, 89, 126, 25, 41, 20, 7, 15, 23, 31, 39,
>> + 47, 2, 63, 71, 79, 118, 95, 108, 117, 125, 132, 107, 115, 116, 124, 105,
>> +114, 122, 112, 113, 127, 96, 97, 86, 94, 15, 23, 31, 39, 47, 55, 63,
>> + 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87, 111,
>> + 19, 25, 57, 81, 83, 92, 95, 98, 99, 100, 101, 103, 104, 106, 109, 110
>> };
>>
>> void ps2_queue(void *opaque, int b)
>> @@ -144,11 +154,15 @@ static void ps2_put_keycode(void *opaque, int keycode)
>> PS2KbdState *s = opaque;
>>
>> /* XXX: add support for scancode sets 1 and 3 */
>
> This command should be updated to explain only set 1 has to be added.
Thanks, v4 fixed this.
>> - if (!s->translate && keycode < 0xe0 && s->scancode_set == 2)
>> - {
>> - if (keycode & 0x80)
>> + if (!s->translate && keycode < 0xe0 && s->scancode_set > 1) {
>> + if (keycode & 0x80) {
>> ps2_queue(&s->common, 0xf0);
>> - keycode = ps2_raw_keycode[keycode & 0x7f];
>> + }
>> + if (s->scancode_set == 2) {
>> + keycode = ps2_raw_keycode[keycode & 0x7f];
>> + } else if (s->scancode_set == 3) {
>> + keycode = ps2_raw_keycode_set3[keycode & 0x7f];
>> + }
>> }
>> ps2_queue(&s->common, keycode);
>> }
>
> Otherwise looks fine.
>
>
> --
> Aurelien Jarno GPG: 1024D/F1BCDB73
> aurelien@aurel32.net http://www.aurel32.net
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-02-21 0:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-14 12:59 [Qemu-devel] [PATCH v3] PS/2 keyboard Scancode Set 3 support Roy Tam
2011-02-14 13:23 ` Kevin Wolf
2011-02-20 18:19 ` Aurelien Jarno
2011-02-21 0:07 ` Roy Tam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).