Changeset 85fa1e1 in mainline
- Timestamp:
- 2011-03-31T10:31:10Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7787dd81, ad7bb42
- Parents:
- fc883bb
- Location:
- uspace
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbkbd/kbddev.c
rfc883bb r85fa1e1 56 56 #include <usb/classes/hidreq.h> 57 57 #include <usb/classes/hidreport.h> 58 #include <usb/classes/hid/utled.h> 58 59 59 60 #include <usb/devdrv.h> … … 263 264 static void usb_kbd_set_led(usb_kbd_t *kbd_dev) 264 265 { 265 uint8_t buffer[BOOTP_BUFFER_OUT_SIZE]; 266 int rc= 0; 267 268 memset(buffer, 0, BOOTP_BUFFER_OUT_SIZE); 269 uint8_t leds = 0; 270 271 if (kbd_dev->mods & KM_NUM_LOCK) { 272 leds |= USB_HID_LED_NUM_LOCK; 273 } 274 275 if (kbd_dev->mods & KM_CAPS_LOCK) { 276 leds |= USB_HID_LED_CAPS_LOCK; 277 } 278 279 if (kbd_dev->mods & KM_SCROLL_LOCK) { 280 leds |= USB_HID_LED_SCROLL_LOCK; 266 // uint8_t buffer[BOOTP_BUFFER_OUT_SIZE]; 267 // int rc= 0; 268 269 // memset(buffer, 0, BOOTP_BUFFER_OUT_SIZE); 270 // uint8_t leds = 0; 271 272 unsigned i = 0; 273 274 if ((kbd_dev->mods & KM_NUM_LOCK) && (i < kbd_dev->led_output_size)) { 275 kbd_dev->led_data[i++] = USB_HID_LED_NUM_LOCK; 276 // leds |= USB_HID_LED_NUM_LOCK; 277 } 278 279 if ((kbd_dev->mods & KM_CAPS_LOCK) && (i < kbd_dev->led_output_size)) { 280 kbd_dev->led_data[i++] = USB_HID_LED_CAPS_LOCK; 281 // leds |= USB_HID_LED_CAPS_LOCK; 282 } 283 284 if ((kbd_dev->mods & KM_SCROLL_LOCK) 285 && (i < kbd_dev->led_output_size)) { 286 kbd_dev->led_data[i++] = USB_HID_LED_SCROLL_LOCK; 287 // leds |= USB_HID_LED_SCROLL_LOCK; 288 } 289 290 usb_log_debug("Output report data: "); 291 for (i = 0; i < kbd_dev->led_output_size; ++i) { 292 usb_log_debug("%u: %d", i, kbd_dev->led_data[i]); 281 293 } 282 294 … … 284 296 285 297 usb_log_debug("Creating output report.\n"); 286 usb_log_debug("Leds: 0x%x\n", leds); 287 if ((rc = usb_hid_boot_keyboard_output_report( 288 leds, buffer, BOOTP_BUFFER_OUT_SIZE)) != EOK) { 289 usb_log_warning("Error composing output report to the keyboard:" 290 "%s.\n", str_error(rc)); 291 return; 292 } 298 299 int rc = usb_hid_report_output_translate(kbd_dev->parser, 300 kbd_dev->led_path, USB_HID_PATH_COMPARE_END, kbd_dev->output_buffer, 301 kbd_dev->output_size, kbd_dev->led_data, kbd_dev->led_output_size); 302 303 if (rc != EOK) { 304 usb_log_warning("Error translating LED output to output report" 305 ".\n"); 306 return; 307 } 308 309 // if ((rc = usb_hid_boot_keyboard_output_report( 310 // leds, buffer, BOOTP_BUFFER_OUT_SIZE)) != EOK) { 311 // usb_log_warning("Error composing output report to the keyboard:" 312 // "%s.\n", str_error(rc)); 313 // return; 314 // } 293 315 294 316 usb_log_debug("Output report buffer: %s\n", 295 usb_debug_str_buffer(buffer, BOOTP_BUFFER_OUT_SIZE, 0)); 296 297 assert(kbd_dev->usb_dev != NULL); 317 usb_debug_str_buffer(kbd_dev->output_buffer, kbd_dev->output_size, 318 0)); 298 319 299 320 usbhid_req_set_report(&kbd_dev->usb_dev->ctrl_pipe, 300 321 kbd_dev->usb_dev->interface_no, USB_HID_REPORT_TYPE_OUTPUT, 301 buffer, BOOTP_BUFFER_OUT_SIZE);322 kbd_dev->output_buffer, kbd_dev->output_size); 302 323 } 303 324 … … 586 607 */ 587 608 static void usb_kbd_process_data(usb_kbd_t *kbd_dev, 588 609 uint8_t *buffer, size_t actual_size) 589 610 { 590 611 assert(kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED); … … 760 781 usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count); 761 782 762 kbd_dev->keys = (uint8_t *)calloc( 763 kbd_dev->key_count, sizeof(uint8_t)); 783 kbd_dev->keys = (uint8_t *)calloc(kbd_dev->key_count, sizeof(uint8_t)); 764 784 765 785 if (kbd_dev->keys == NULL) { … … 768 788 } 769 789 790 /* 791 * Output report 792 */ 793 kbd_dev->output_size = 0; 794 kbd_dev->output_buffer = usb_hid_report_output(kbd_dev->parser, 795 &kbd_dev->output_size); 796 if (kbd_dev->output_buffer == NULL) { 797 usb_log_warning("Error creating output report buffer.\n"); 798 free(kbd_dev->keys); 799 return ENOMEM; /* TODO: other error code */ 800 } 801 802 usb_log_debug("Output buffer size: %zu\n", kbd_dev->output_size); 803 804 kbd_dev->led_path = usb_hid_report_path(); 805 usb_hid_report_path_append_item( 806 kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0); 807 808 kbd_dev->led_output_size = usb_hid_report_output_size(kbd_dev->parser, 809 kbd_dev->led_path, USB_HID_PATH_COMPARE_END); 810 811 usb_log_debug("Output report size (in items): %zu\n", 812 kbd_dev->led_output_size); 813 814 kbd_dev->led_data = (int32_t *)calloc( 815 kbd_dev->led_output_size, sizeof(int32_t)); 816 817 if (kbd_dev->led_data == NULL) { 818 usb_log_warning("Error creating buffer for LED output report." 819 "\n"); 820 free(kbd_dev->keys); 821 usb_hid_report_output_free(kbd_dev->output_buffer); 822 return ENOMEM; 823 } 824 825 /* 826 * Modifiers and locks 827 */ 770 828 kbd_dev->modifiers = 0; 771 829 kbd_dev->mods = DEFAULT_ACTIVE_MODS; 772 830 kbd_dev->lock_keys = 0; 773 831 832 /* 833 * Autorepeat 834 */ 774 835 kbd_dev->repeat.key_new = 0; 775 836 kbd_dev->repeat.key_repeated = 0; … … 879 940 } 880 941 942 // free the output buffer 943 usb_hid_report_output_free((*kbd_dev)->output_buffer); 944 881 945 /* TODO: what about the USB device structure?? */ 882 946 -
uspace/drv/usbkbd/kbddev.h
rfc883bb r85fa1e1 94 94 /** Report descriptor size. */ 95 95 size_t report_desc_size; 96 97 uint8_t *output_buffer; 98 99 size_t output_size; 100 101 size_t led_output_size; 102 103 usb_hid_report_path_t *led_path; 104 105 int32_t *led_data; 96 106 97 107 /** HID Report parser. */ -
uspace/lib/usb/include/usb/classes/hidparser.h
rfc883bb r85fa1e1 182 182 } usb_hid_modifiers_t; 183 183 184 typedef enum {185 USB_HID_LED_NUM_LOCK = 0x1,186 USB_HID_LED_CAPS_LOCK = 0x2,187 USB_HID_LED_SCROLL_LOCK = 0x4,188 USB_HID_LED_COMPOSE = 0x8,189 USB_HID_LED_KANA = 0x10,190 USB_HID_LED_COUNT = 5191 } usb_hid_led_t;184 //typedef enum { 185 // USB_HID_LED_NUM_LOCK = 0x1, 186 // USB_HID_LED_CAPS_LOCK = 0x2, 187 // USB_HID_LED_SCROLL_LOCK = 0x4, 188 // USB_HID_LED_COMPOSE = 0x8, 189 // USB_HID_LED_KANA = 0x10, 190 // USB_HID_LED_COUNT = 5 191 //} usb_hid_led_t; 192 192 193 193 static const usb_hid_modifiers_t
Note:
See TracChangeset
for help on using the changeset viewer.