Changes in uspace/drv/bus/usb/usbhid/kbd/kbddev.c [2d1ba51:76fbd9a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/kbd/kbddev.c
r2d1ba51 r76fbd9a 71 71 #include "../usbhid.h" 72 72 73 /*----------------------------------------------------------------------------*/ 73 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 74 static ddf_dev_ops_t kbdops = { .default_handler = default_connection_handler }; 75 74 76 75 77 static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK; … … 86 88 static const unsigned int DEFAULT_REPEAT_DELAY = 50 * 1000; 87 89 88 /*----------------------------------------------------------------------------*/ 90 89 91 /** Keyboard polling endpoint description for boot protocol class. */ 90 92 const usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description = { … … 101 103 102 104 static void usb_kbd_set_led(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev); 103 /*----------------------------------------------------------------------------*/ 105 104 106 static const uint8_t USB_KBD_BOOT_REPORT_DESCRIPTOR[] = { 105 107 0x05, 0x01, /* Usage Page (Generic Desktop), */ … … 136 138 0xC0 /* End Collection */ 137 139 }; 138 /*----------------------------------------------------------------------------*/ 140 139 141 typedef enum usb_kbd_flags { 140 142 USB_KBD_STATUS_UNINITIALIZED = 0, … … 142 144 USB_KBD_STATUS_TO_DESTROY = -1 143 145 } usb_kbd_flags; 144 /*----------------------------------------------------------------------------*/ 146 145 147 /* IPC method handler */ 146 /*----------------------------------------------------------------------------*/ 148 147 149 /** 148 150 * Default handler for IPC methods not handled by DDF. … … 187 189 break; 188 190 } 189 if (kbd_dev->c onsole_sess == NULL) {190 kbd_dev->c onsole_sess = sess;191 if (kbd_dev->client_sess == NULL) { 192 kbd_dev->client_sess = sess; 191 193 usb_log_debug("%s: OK\n", __FUNCTION__); 192 194 async_answer_0(icallid, EOK); … … 206 208 207 209 } 208 /*----------------------------------------------------------------------------*/ 210 209 211 /* Key processing functions */ 210 /*----------------------------------------------------------------------------*/ 212 211 213 /** 212 214 * Handles turning of LED lights on and off. … … 281 283 } 282 284 } 283 /*----------------------------------------------------------------------------*/ 285 284 286 /** Send key event. 285 287 * … … 292 294 { 293 295 usb_log_debug2("Sending kbdev event %d/%d to the console\n", type, key); 294 if (kbd_dev->c onsole_sess == NULL) {296 if (kbd_dev->client_sess == NULL) { 295 297 usb_log_warning( 296 298 "Connection to console not ready, key discarded.\n"); … … 298 300 } 299 301 300 async_exch_t *exch = async_exchange_begin(kbd_dev->c onsole_sess);302 async_exch_t *exch = async_exchange_begin(kbd_dev->client_sess); 301 303 if (exch != NULL) { 302 304 async_msg_2(exch, KBDEV_EVENT, type, key); … … 306 308 } 307 309 } 308 /*----------------------------------------------------------------------------*/ 310 309 311 static inline int usb_kbd_is_lock(unsigned int key_code) 310 312 { … … 313 315 || key_code == KC_CAPS_LOCK); 314 316 } 315 /*----------------------------------------------------------------------------*/ 317 316 318 static size_t find_in_array_int32(int32_t val, int32_t *arr, size_t arr_size) 317 319 { … … 324 326 return (size_t) -1; 325 327 } 326 /*----------------------------------------------------------------------------*/ 328 327 329 /** 328 330 * Checks if some keys were pressed or released and generates key events. … … 407 409 usb_log_debug2("Stored keys %s.\n", key_buffer); 408 410 } 409 /*----------------------------------------------------------------------------*/ 411 410 412 /* General kbd functions */ 411 /*----------------------------------------------------------------------------*/ 413 412 414 /** 413 415 * Processes data received from the device in form of report. … … 479 481 usb_kbd_check_key_changes(hid_dev, kbd_dev); 480 482 } 481 /*----------------------------------------------------------------------------*/ 483 482 484 /* HID/KBD structure manipulation */ 483 /*----------------------------------------------------------------------------*/ 485 484 486 static int usb_kbd_create_function(usb_kbd_t *kbd_dev) 485 487 { … … 499 501 /* Store the initialized HID device and HID ops 500 502 * to the DDF function. */ 501 fun->ops = &kbd _dev->ops;503 fun->ops = &kbdops; 502 504 fun->driver_data = kbd_dev; 503 505 … … 535 537 return EOK; 536 538 } 537 /*----------------------------------------------------------------------------*/ 539 538 540 /* API functions */ 539 /*----------------------------------------------------------------------------*/ 541 540 542 /** 541 543 * Initialization of the USB/HID keyboard structure. … … 576 578 fibril_mutex_initialize(&kbd_dev->repeat_mtx); 577 579 kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED; 578 kbd_dev->ops.default_handler = default_connection_handler;579 580 580 581 /* Store link to HID device */ … … 700 701 return EOK; 701 702 } 702 /*----------------------------------------------------------------------------*/ 703 703 704 bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, void *data) 704 705 { … … 714 715 return true; 715 716 } 716 /*----------------------------------------------------------------------------*/ 717 717 718 int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev) 718 719 { 719 720 return (kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED); 720 721 } 721 /*----------------------------------------------------------------------------*/ 722 722 723 int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev) 723 724 { 724 725 return (kbd_dev->initialized == USB_KBD_STATUS_TO_DESTROY); 725 726 } 726 /*----------------------------------------------------------------------------*/ 727 727 728 /** 728 729 * Properly destroys the USB/HID keyboard structure. … … 737 738 738 739 /* Hangup session to the console. */ 739 if (kbd_dev->c onsole_sess)740 async_hangup(kbd_dev->c onsole_sess);740 if (kbd_dev->client_sess) 741 async_hangup(kbd_dev->client_sess); 741 742 742 743 //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)); … … 765 766 free(kbd_dev); 766 767 } 767 /*----------------------------------------------------------------------------*/ 768 768 769 void usb_kbd_deinit(usb_hid_dev_t *hid_dev, void *data) 769 770 { … … 778 779 } 779 780 } 780 /*----------------------------------------------------------------------------*/ 781 781 782 int usb_kbd_set_boot_protocol(usb_hid_dev_t *hid_dev) 782 783 {
Note:
See TracChangeset
for help on using the changeset viewer.