| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kbd.c,v 1.4 2015/02/14 13:06:28 tsutsui Exp $ */ | | 1 | /* $NetBSD: kbd.c,v 1.5 2021/09/03 16:21:15 tsutsui Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1992 OMRON Corporation. | | 4 | * Copyright (c) 1992 OMRON Corporation. |
5 | * | | 5 | * |
6 | * This code is derived from software contributed to Berkeley by | | 6 | * This code is derived from software contributed to Berkeley by |
7 | * OMRON Corporation. | | 7 | * OMRON Corporation. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -203,32 +203,43 @@ static const struct kbd_keymap kbd_keyma | | | @@ -203,32 +203,43 @@ static const struct kbd_keymap kbd_keyma |
203 | { KC_IGNORE, { 0, 0 } }, /* 120 [0x78] */ | | 203 | { KC_IGNORE, { 0, 0 } }, /* 120 [0x78] */ |
204 | { KC_IGNORE, { 0, 0 } }, /* 121 [0x79] */ | | 204 | { KC_IGNORE, { 0, 0 } }, /* 121 [0x79] */ |
205 | { KC_IGNORE, { 0, 0 } }, /* 122 [0x7A] */ | | 205 | { KC_IGNORE, { 0, 0 } }, /* 122 [0x7A] */ |
206 | { KC_IGNORE, { 0, 0 } }, /* 123 [0x7B] */ | | 206 | { KC_IGNORE, { 0, 0 } }, /* 123 [0x7B] */ |
207 | { KC_IGNORE, { 0, 0 } }, /* 124 [0x7C] */ | | 207 | { KC_IGNORE, { 0, 0 } }, /* 124 [0x7C] */ |
208 | { KC_IGNORE, { 0, 0 } }, /* 125 [0x7D] */ | | 208 | { KC_IGNORE, { 0, 0 } }, /* 125 [0x7D] */ |
209 | { KC_IGNORE, { 0, 0 } }, /* 126 [0x7E] */ | | 209 | { KC_IGNORE, { 0, 0 } }, /* 126 [0x7E] */ |
210 | { KC_IGNORE, { 0, 0 } }, /* 127 [0x7F] */ | | 210 | { KC_IGNORE, { 0, 0 } }, /* 127 [0x7F] */ |
211 | }; | | 211 | }; |
212 | | | 212 | |
213 | int shift_flag = 0; | | 213 | int shift_flag = 0; |
214 | int ctrl_flag = 0; | | 214 | int ctrl_flag = 0; |
215 | int meta_flag = 0; | | 215 | int meta_flag = 0; |
| | | 216 | int mouse_flag = 0; |
216 | | | 217 | |
217 | int | | 218 | int |
218 | kbd_decode(uint8_t code) | | 219 | kbd_decode(uint8_t code) |
219 | { | | 220 | { |
220 | unsigned int c, updown = 0; | | 221 | unsigned int c, updown = 0; |
221 | | | 222 | |
| | | 223 | /* ignore mouse data */ |
| | | 224 | if (mouse_flag != 0) { |
| | | 225 | mouse_flag--; |
| | | 226 | return KC_IGNORE; |
| | | 227 | } |
| | | 228 | if ((code & 0xf8) == 0x80) { |
| | | 229 | mouse_flag = 2; |
| | | 230 | return KC_IGNORE; |
| | | 231 | } |
| | | 232 | |
222 | if (code & 0x80) | | 233 | if (code & 0x80) |
223 | updown = 1; | | 234 | updown = 1; |
224 | | | 235 | |
225 | code &= 0x7F; | | 236 | code &= 0x7F; |
226 | | | 237 | |
227 | c = kbd_keymap[code].km_type; | | 238 | c = kbd_keymap[code].km_type; |
228 | | | 239 | |
229 | if (c == KC_IGNORE) | | 240 | if (c == KC_IGNORE) |
230 | return KC_IGNORE; | | 241 | return KC_IGNORE; |
231 | | | 242 | |
232 | if ((c == KC_CODE) && updown) | | 243 | if ((c == KC_CODE) && updown) |
233 | return KC_IGNORE; | | 244 | return KC_IGNORE; |
234 | | | 245 | |