Changeset a35b458 in mainline for uspace/drv/hid/xtkbd
- Timestamp:
- 2018-03-02T20:10:49Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
-
uspace/drv/hid/xtkbd/xtkbd.c (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/hid/xtkbd/xtkbd.c
r3061bc1 ra35b458 47 47 static const unsigned int scanmap_simple[] = { 48 48 [0x29] = KC_BACKTICK, 49 49 50 50 [0x02] = KC_1, 51 51 [0x03] = KC_2, … … 58 58 [0x0a] = KC_9, 59 59 [0x0b] = KC_0, 60 60 61 61 [0x0c] = KC_MINUS, 62 62 [0x0d] = KC_EQUALS, 63 63 [0x0e] = KC_BACKSPACE, 64 64 65 65 [0x0f] = KC_TAB, 66 66 67 67 [0x10] = KC_Q, 68 68 [0x11] = KC_W, … … 75 75 [0x18] = KC_O, 76 76 [0x19] = KC_P, 77 77 78 78 [0x1a] = KC_LBRACKET, 79 79 [0x1b] = KC_RBRACKET, 80 80 81 81 [0x3a] = KC_CAPS_LOCK, 82 82 83 83 [0x1e] = KC_A, 84 84 [0x1f] = KC_S, … … 90 90 [0x25] = KC_K, 91 91 [0x26] = KC_L, 92 92 93 93 [0x27] = KC_SEMICOLON, 94 94 [0x28] = KC_QUOTE, 95 95 [0x2b] = KC_BACKSLASH, 96 96 97 97 [0x2a] = KC_LSHIFT, 98 98 99 99 [0x2c] = KC_Z, 100 100 [0x2d] = KC_X, … … 104 104 [0x31] = KC_N, 105 105 [0x32] = KC_M, 106 106 107 107 [0x33] = KC_COMMA, 108 108 [0x34] = KC_PERIOD, 109 109 [0x35] = KC_SLASH, 110 110 111 111 [0x36] = KC_RSHIFT, 112 112 113 113 [0x1d] = KC_LCTRL, 114 114 [0x38] = KC_LALT, 115 115 [0x39] = KC_SPACE, 116 116 117 117 [0x01] = KC_ESCAPE, 118 118 119 119 [0x3b] = KC_F1, 120 120 [0x3c] = KC_F2, … … 124 124 [0x40] = KC_F6, 125 125 [0x41] = KC_F7, 126 126 127 127 [0x42] = KC_F8, 128 128 [0x43] = KC_F9, 129 129 [0x44] = KC_F10, 130 130 131 131 [0x57] = KC_F11, 132 132 [0x58] = KC_F12, 133 133 134 134 [0x46] = KC_SCROLL_LOCK, 135 135 136 136 [0x1c] = KC_ENTER, 137 137 138 138 [0x45] = KC_NUM_LOCK, 139 139 [0x37] = KC_NTIMES, … … 162 162 [0x38] = KC_RALT, 163 163 [0x1d] = KC_RCTRL, 164 164 165 165 [0x37] = KC_SYSREQ, 166 166 167 167 [0x52] = KC_INSERT, 168 168 [0x47] = KC_HOME, 169 169 [0x49] = KC_PAGE_UP, 170 170 171 171 [0x53] = KC_DELETE, 172 172 [0x4f] = KC_END, 173 173 [0x51] = KC_PAGE_DOWN, 174 174 175 175 [0x48] = KC_UP, 176 176 [0x4b] = KC_LEFT, 177 177 [0x50] = KC_DOWN, 178 178 [0x4d] = KC_RIGHT, 179 179 180 180 [0x35] = KC_NSLASH, 181 181 [0x1c] = KC_NENTER … … 210 210 size_t nread; 211 211 errno_t rc; 212 212 213 213 while (true) { 214 214 const unsigned int *map = scanmap_simple; 215 215 size_t map_size = sizeof(scanmap_simple) / sizeof(unsigned int); 216 216 217 217 uint8_t code = 0; 218 218 rc = chardev_read(kbd->chardev, &code, 1, &nread); 219 219 if (rc != EOK) 220 220 return EIO; 221 221 222 222 /* Ignore AT command reply */ 223 223 if ((code == KBD_ACK) || (code == KBD_RESEND)) 224 224 continue; 225 225 226 226 /* Extended set */ 227 227 if (code == KBD_SCANCODE_SET_EXTENDED) { 228 228 map = scanmap_e0; 229 229 map_size = sizeof(scanmap_e0) / sizeof(unsigned int); 230 231 rc = chardev_read(kbd->chardev, &code, 1, &nread); 232 if (rc != EOK) 233 return EIO; 234 230 231 rc = chardev_read(kbd->chardev, &code, 1, &nread); 232 if (rc != EOK) 233 return EIO; 234 235 235 /* Handle really special keys */ 236 236 237 237 if (code == 0x2a) { /* Print Screen */ 238 238 rc = chardev_read(kbd->chardev, &code, 1, &nread); 239 239 if (rc != EOK) 240 240 return EIO; 241 241 242 242 if (code != 0xe0) 243 243 continue; 244 244 245 245 rc = chardev_read(kbd->chardev, &code, 1, &nread); 246 246 if (rc != EOK) 247 247 return EIO; 248 248 249 249 if (code == 0x37) 250 250 push_event(kbd->client_sess, KEY_PRESS, KC_PRTSCR); 251 251 252 252 continue; 253 253 } 254 254 255 255 if (code == 0x46) { /* Break */ 256 256 rc = chardev_read(kbd->chardev, &code, 1, &nread); 257 257 if (rc != EOK) 258 258 return EIO; 259 259 260 260 if (code != 0xe0) 261 261 continue; 262 262 263 263 rc = chardev_read(kbd->chardev, &code, 1, &nread); 264 264 if (rc != EOK) 265 265 return EIO; 266 266 267 267 if (code == 0xc6) 268 268 push_event(kbd->client_sess, KEY_PRESS, KC_BREAK); 269 269 270 270 continue; 271 271 } 272 272 } 273 273 274 274 /* Extended special set */ 275 275 if (code == KBD_SCANCODE_SET_EXTENDED_SPECIAL) { … … 277 277 if (rc != EOK) 278 278 return EIO; 279 279 280 280 if (code != 0x1d) 281 281 continue; 282 283 rc = chardev_read(kbd->chardev, &code, 1, &nread); 284 if (rc != EOK) 285 return EIO; 286 282 283 rc = chardev_read(kbd->chardev, &code, 1, &nread); 284 if (rc != EOK) 285 return EIO; 286 287 287 if (code != 0x45) 288 288 continue; 289 290 rc = chardev_read(kbd->chardev, &code, 1, &nread); 291 if (rc != EOK) 292 return EIO; 293 289 290 rc = chardev_read(kbd->chardev, &code, 1, &nread); 291 if (rc != EOK) 292 return EIO; 293 294 294 if (code != 0xe1) 295 295 continue; 296 297 rc = chardev_read(kbd->chardev, &code, 1, &nread); 298 if (rc != EOK) 299 return EIO; 300 296 297 rc = chardev_read(kbd->chardev, &code, 1, &nread); 298 if (rc != EOK) 299 return EIO; 300 301 301 if (code != 0x9d) 302 302 continue; 303 304 rc = chardev_read(kbd->chardev, &code, 1, &nread); 305 if (rc != EOK) 306 return EIO; 307 303 304 rc = chardev_read(kbd->chardev, &code, 1, &nread); 305 if (rc != EOK) 306 return EIO; 307 308 308 if (code == 0xc5) 309 309 push_event(kbd->client_sess, KEY_PRESS, KC_PAUSE); 310 310 311 311 continue; 312 312 } 313 313 314 314 /* Bit 7 indicates press/release */ 315 315 const kbd_event_type_t type = 316 316 (code & 0x80) ? KEY_RELEASE : KEY_PRESS; 317 317 code &= ~0x80; 318 318 319 319 const unsigned int key = (code < map_size) ? map[code] : 0; 320 320 321 321 if (key != 0) 322 322 push_event(kbd->client_sess, type, key); … … 351 351 ((mods & KM_SCROLL_LOCK) ? LI_SCROLL : 0); 352 352 uint8_t cmds[] = { KBD_CMD_SET_LEDS, status }; 353 353 354 354 size_t nwr; 355 355 errno_t rc = chardev_write(kbd->chardev, &cmds[0], 1, &nwr); … … 370 370 async_sess_t *sess = 371 371 async_callback_receive_start(EXCHANGE_SERIALIZE, icall); 372 372 373 373 /* Probably ENOMEM error, try again. */ 374 374 if (sess == NULL) { … … 378 378 break; 379 379 } 380 380 381 381 if (kbd->client_sess == NULL) { 382 382 kbd->client_sess = sess; … … 387 387 async_answer_0(icallid, ELIMIT); 388 388 } 389 389 390 390 break; 391 391 } … … 415 415 bool bound = false; 416 416 errno_t rc; 417 417 418 418 kbd->client_sess = NULL; 419 419 420 420 parent_sess = ddf_dev_parent_sess_get(dev); 421 421 if (parent_sess == NULL) { … … 424 424 goto error; 425 425 } 426 426 427 427 rc = chardev_open(parent_sess, &kbd->chardev); 428 428 if (rc != EOK) { … … 430 430 goto error; 431 431 } 432 432 433 433 kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd"); 434 434 if (kbd->kbd_fun == NULL) { … … 437 437 goto error; 438 438 } 439 439 440 440 ddf_fun_set_ops(kbd->kbd_fun, &kbd_ops); 441 441 442 442 rc = ddf_fun_bind(kbd->kbd_fun); 443 443 if (rc != EOK) { … … 445 445 goto error; 446 446 } 447 447 448 448 rc = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard"); 449 449 if (rc != EOK) { … … 452 452 goto error; 453 453 } 454 454 455 455 kbd->polling_fibril = fibril_create(polling, kbd); 456 456 if (kbd->polling_fibril == 0) { … … 459 459 goto error; 460 460 } 461 461 462 462 fibril_add_ready(kbd->polling_fibril); 463 463 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.
