Changeset a35b458 in mainline for uspace/drv/hid
- 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)
- Location:
- uspace/drv/hid
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/hid/atkbd/atkbd.c
r3061bc1 ra35b458 205 205 size_t nwr; 206 206 errno_t rc; 207 207 208 208 while (true) { 209 209 uint8_t code = 0; … … 211 211 if (rc != EOK) 212 212 return EIO; 213 213 214 214 const unsigned int *map; 215 215 size_t map_size; 216 216 217 217 if (code == KBD_SCANCODE_SET_EXTENDED) { 218 218 map = scanmap_e0; 219 219 map_size = sizeof(scanmap_e0) / sizeof(unsigned int); 220 220 221 221 rc = chardev_read(kbd->chardev, &code, 1, &nwr); 222 222 if (rc != EOK) … … 270 270 map_size = sizeof(scanmap_simple) / sizeof(unsigned int); 271 271 } 272 272 273 273 kbd_event_type_t type; 274 274 if (code == KBD_SCANCODE_KEY_RELEASE) { … … 280 280 type = KEY_PRESS; 281 281 } 282 282 283 283 const unsigned int key = (code < map_size) ? map[code] : 0; 284 284 285 285 if (key != 0) 286 286 push_event(kbd->client_sess, type, key); … … 315 315 async_sess_t *sess = 316 316 async_callback_receive_start(EXCHANGE_SERIALIZE, icall); 317 317 318 318 /* Probably ENOMEM error, try again. */ 319 319 if (sess == NULL) { … … 323 323 break; 324 324 } 325 325 326 326 if (kbd->client_sess == NULL) { 327 327 kbd->client_sess = sess; … … 332 332 async_answer_0(icallid, ELIMIT); 333 333 } 334 334 335 335 break; 336 336 } … … 359 359 async_sess_t *parent_sess; 360 360 errno_t rc; 361 361 362 362 assert(kbd); 363 363 assert(dev); 364 364 365 365 kbd->client_sess = NULL; 366 366 parent_sess = ddf_dev_parent_sess_get(dev); … … 370 370 goto error; 371 371 } 372 372 373 373 rc = chardev_open(parent_sess, &kbd->chardev); 374 374 if (rc != EOK) { … … 376 376 return EIO; 377 377 } 378 378 379 379 kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd"); 380 380 if (!kbd->kbd_fun) { … … 382 382 return ENOMEM; 383 383 } 384 384 385 385 ddf_fun_set_ops(kbd->kbd_fun, &kbd_ops); 386 386 387 387 errno_t ret = ddf_fun_bind(kbd->kbd_fun); 388 388 if (ret != EOK) { … … 391 391 return EEXIST; 392 392 } 393 393 394 394 ret = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard"); 395 395 if (ret != EOK) { … … 400 400 return ENOMEM; 401 401 } 402 402 403 403 kbd->polling_fibril = fibril_create(polling, kbd); 404 404 if (!kbd->polling_fibril) { … … 408 408 return ENOMEM; 409 409 } 410 410 411 411 fibril_add_ready(kbd->polling_fibril); 412 412 return EOK; -
uspace/drv/hid/usbhid/blink1/blink1.c
r3061bc1 ra35b458 67 67 return EINVAL; 68 68 } 69 69 70 70 blink1_report_t report; 71 71 72 72 report.id = BLINK1_REPORT_ID; 73 73 report.command = BLINK1_COMMAND_SET; … … 78 78 report.arg4 = 0; 79 79 report.arg5 = 0; 80 80 81 81 return usbhid_req_set_report( 82 82 usb_device_get_default_pipe(blink1_dev->hid_dev->usb_dev), … … 100 100 return EINVAL; 101 101 } 102 102 103 103 /* Create the exposed function. */ 104 104 ddf_fun_t *fun = usb_device_ddf_fun_create(hid_dev->usb_dev, … … 109 109 return ENOMEM; 110 110 } 111 111 112 112 usb_blink1_t *blink1_dev = (usb_blink1_t *) 113 113 ddf_fun_data_alloc(fun, sizeof(usb_blink1_t)); … … 118 118 return ENOMEM; 119 119 } 120 120 121 121 ddf_fun_set_ops(fun, &blink1_ops); 122 122 123 123 errno_t rc = ddf_fun_bind(fun); 124 124 if (rc != EOK) { … … 128 128 return rc; 129 129 } 130 130 131 131 rc = ddf_fun_add_to_category(fun, HID_BLINK1_CATEGORY); 132 132 if (rc != EOK) { 133 133 usb_log_error("Could not add DDF function to category %s: %s.", 134 134 HID_BLINK1_CATEGORY, str_error(rc)); 135 135 136 136 rc = ddf_fun_unbind(fun); 137 137 if (rc != EOK) { … … 140 140 return rc; 141 141 } 142 142 143 143 ddf_fun_destroy(fun); 144 144 return rc; 145 145 } 146 146 147 147 blink1_dev->fun = fun; 148 148 blink1_dev->hid_dev = hid_dev; 149 149 *data = blink1_dev; 150 150 151 151 return EOK; 152 152 } … … 156 156 if (data == NULL) 157 157 return; 158 158 159 159 usb_blink1_t *blink1_dev = (usb_blink1_t *) data; 160 160 161 161 errno_t rc = ddf_fun_unbind(blink1_dev->fun); 162 162 if (rc != EOK) { … … 165 165 return; 166 166 } 167 167 168 168 ddf_fun_destroy(blink1_dev->fun); 169 169 } -
uspace/drv/hid/usbhid/blink1/blink1.h
r3061bc1 ra35b458 44 44 /** DDF blink(1) function */ 45 45 ddf_fun_t *fun; 46 46 47 47 /** USB HID device */ 48 48 usb_hid_dev_t *hid_dev; -
uspace/drv/hid/usbhid/kbd/kbddev.h
r3061bc1 ra35b458 63 63 /** Link to HID device structure */ 64 64 usb_hid_dev_t *hid_dev; 65 65 66 66 /** Previously pressed keys (not translated to key codes). */ 67 67 int32_t *keys_old; … … 72 72 /** Currently pressed modifiers (bitmap). */ 73 73 uint8_t modifiers; 74 74 75 75 /** Currently active modifiers including locks. Sent to the console. */ 76 76 unsigned int mods; 77 77 78 78 /** Currently active lock keys. */ 79 79 unsigned int lock_keys; 80 80 81 81 /** IPC session to client (for sending key events). */ 82 82 async_sess_t *client_sess; 83 83 84 84 /** Information for auto-repeat of keys. */ 85 85 usb_kbd_repeat_t repeat; 86 86 87 87 /** Mutex for accessing the information about auto-repeat. */ 88 88 fibril_mutex_t repeat_mtx; 89 89 90 90 uint8_t *output_buffer; 91 91 92 92 size_t output_size; 93 93 94 94 size_t led_output_size; 95 95 96 96 usb_hid_report_path_t *led_path; 97 97 98 98 int32_t *led_data; 99 99 100 100 /** State of the structure (for checking before use). 101 101 * … … 105 105 */ 106 106 int initialized; 107 107 108 108 /** DDF function */ 109 109 ddf_fun_t *fun; -
uspace/drv/hid/usbhid/mouse/mousedev.h
r3061bc1 ra35b458 45 45 /** IPC session to consumer. */ 46 46 async_sess_t *mouse_sess; 47 47 48 48 /** Mouse buttons statuses. */ 49 49 int32_t *buttons; 50 50 size_t buttons_count; 51 51 52 52 /** DDF mouse function */ 53 53 ddf_fun_t *mouse_fun; -
uspace/drv/hid/usbhid/multimedia/keymap.c
r3061bc1 ra35b458 86 86 /*! @todo What if the usage is not in the table? */ 87 87 key = map[usage]; 88 88 89 89 return key; 90 90 } -
uspace/drv/hid/usbhid/subdrivers.h
r3061bc1 ra35b458 61 61 */ 62 62 const usb_hid_subdriver_usage_t *usage_path; 63 63 64 64 /** Report ID for which the path should apply. */ 65 65 int report_id; 66 66 67 67 /** Compare type for the usage path. */ 68 68 int compare; 69 69 70 70 /** Vendor ID (set to -1 if not specified). */ 71 71 int vendor_id; 72 72 73 73 /** Product ID (set to -1 if not specified). */ 74 74 int product_id; 75 75 76 76 /** Subdriver for controlling this device. */ 77 77 const usb_hid_subdriver_t subdriver; -
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.