Changeset 6336b6e in mainline
- Timestamp:
- 2011-01-17T15:21:18Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7c169ce
- Parents:
- 0a9ea4a
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbkbd/Makefile
r0a9ea4a r6336b6e 35 35 main.c \ 36 36 descparser.c \ 37 descdump.c 37 descdump.c \ 38 conv.c 38 39 39 40 include $(USPACE_PREFIX)/Makefile.common -
uspace/drv/usbkbd/descparser.c
r0a9ea4a r6336b6e 96 96 pos += sizeof(usb_standard_configuration_descriptor_t); 97 97 98 printf("Parsed configuration descriptor: \n");99 dump_standard_configuration_descriptor(0, &config->config_descriptor);98 //printf("Parsed configuration descriptor: \n"); 99 //dump_standard_configuration_descriptor(0, &config->config_descriptor); 100 100 101 101 int ret = EOK; … … 139 139 pos += desc_size; 140 140 141 printf("Parsed interface descriptor: \n");142 dump_standard_interface_descriptor(&actual_iface->iface_desc);141 //printf("Parsed interface descriptor: \n"); 142 //dump_standard_interface_descriptor(&actual_iface->iface_desc); 143 143 144 144 // allocate space for endpoint descriptors … … 153 153 ep_i = 0; 154 154 155 printf("Remaining size: %d\n", size - (size_t)(pos - data));155 //printf("Remaining size: %d\n", size - (size_t)(pos - data)); 156 156 157 157 break; … … 180 180 pos += desc_size; 181 181 182 printf("Parsed endpoint descriptor: \n");183 dump_standard_endpoint_descriptor(&actual_iface->endpoints[ep_i]);182 //printf("Parsed endpoint descriptor: \n"); 183 //dump_standard_endpoint_descriptor(&actual_iface->endpoints[ep_i]); 184 184 ++ep_i; 185 185 … … 208 208 }*/ 209 209 210 printf("Parsed HID descriptor header: \n");211 dump_standard_hid_descriptor_header(&actual_iface->hid_desc);210 //printf("Parsed HID descriptor header: \n"); 211 //dump_standard_hid_descriptor_header(&actual_iface->hid_desc); 212 212 213 213 // allocate space for all class-specific descriptor info -
uspace/drv/usbkbd/main.c
r0a9ea4a r6336b6e 38 38 #include <usb/devreq.h> 39 39 #include <usb/descriptor.h> 40 #include <io/console.h> 40 41 #include "descparser.h" 41 42 #include "descdump.h" 43 #include "conv.h" 42 44 43 45 #define BUFFER_SIZE 32 … … 88 90 89 91 /* 92 * TODO: Move somewhere else 93 */ 94 /* 95 #define BYTES_PER_LINE 12 96 97 static void dump_buffer(const char *msg, const uint8_t *buffer, size_t length) 98 { 99 printf("%s\n", msg); 100 101 size_t i; 102 for (i = 0; i < length; i++) { 103 printf(" 0x%02X", buffer[i]); 104 if (((i > 0) && (((i+1) % BYTES_PER_LINE) == 0)) 105 || (i + 1 == length)) { 106 printf("\n"); 107 } 108 } 109 } 110 */ 111 /* 112 * Copy-paste from srv/hid/kbd/generic/kbd.c 113 */ 114 115 /** Currently active modifiers. 116 * 117 * TODO: put to device? 118 */ 119 static unsigned mods = KM_NUM_LOCK; 120 121 /** Currently pressed lock keys. We track these to tackle autorepeat. 122 * 123 * TODO: put to device? 124 */ 125 static unsigned lock_keys; 126 127 // TODO: put to device? 128 //static int active_layout = 0; 129 130 static void kbd_push_ev(int type, unsigned int key) 131 { 132 console_event_t ev; 133 unsigned mod_mask; 134 135 // TODO: replace by our own parsing?? or are the key codes identical?? 136 switch (key) { 137 case KC_LCTRL: mod_mask = KM_LCTRL; break; 138 case KC_RCTRL: mod_mask = KM_RCTRL; break; 139 case KC_LSHIFT: mod_mask = KM_LSHIFT; break; 140 case KC_RSHIFT: mod_mask = KM_RSHIFT; break; 141 case KC_LALT: mod_mask = KM_LALT; break; 142 case KC_RALT: mod_mask = KM_RALT; break; 143 default: mod_mask = 0; break; 144 } 145 146 if (mod_mask != 0) { 147 if (type == KEY_PRESS) 148 mods = mods | mod_mask; 149 else 150 mods = mods & ~mod_mask; 151 } 152 153 switch (key) { 154 case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; break; 155 case KC_NUM_LOCK: mod_mask = KM_NUM_LOCK; break; 156 case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break; 157 default: mod_mask = 0; break; 158 } 159 160 if (mod_mask != 0) { 161 if (type == KEY_PRESS) { 162 /* 163 * Only change lock state on transition from released 164 * to pressed. This prevents autorepeat from messing 165 * up the lock state. 166 */ 167 mods = mods ^ (mod_mask & ~lock_keys); 168 lock_keys = lock_keys | mod_mask; 169 170 /* Update keyboard lock indicator lights. */ 171 // TODO 172 //kbd_ctl_set_ind(mods); 173 } else { 174 lock_keys = lock_keys & ~mod_mask; 175 } 176 } 177 /* 178 printf("type: %d\n", type); 179 printf("mods: 0x%x\n", mods); 180 printf("keycode: %u\n", key); 181 */ 182 /* 183 if (type == KEY_PRESS && (mods & KM_LCTRL) && 184 key == KC_F1) { 185 active_layout = 0; 186 layout[active_layout]->reset(); 187 return; 188 } 189 190 if (type == KEY_PRESS && (mods & KM_LCTRL) && 191 key == KC_F2) { 192 active_layout = 1; 193 layout[active_layout]->reset(); 194 return; 195 } 196 197 if (type == KEY_PRESS && (mods & KM_LCTRL) && 198 key == KC_F3) { 199 active_layout = 2; 200 layout[active_layout]->reset(); 201 return; 202 } 203 */ 204 ev.type = type; 205 ev.key = key; 206 ev.mods = mods; 207 208 //ev.c = layout[active_layout]->parse_ev(&ev); 209 210 printf("Sending key %d to the console\n", ev.key); 211 assert(console_callback_phone != -1); 212 async_msg_4(console_callback_phone, KBD_EVENT, ev.type, ev.key, ev.mods, 0); 213 } 214 /* 215 * End of copy-paste 216 */ 217 218 /* 219 * TODO: 220 * 1) key press / key release - how does the keyboard notify about release? 221 * 2) layouts (use the already defined), not important now 222 * 3) 223 */ 224 225 /* 90 226 * Callbacks for parser 91 227 */ … … 97 233 for (i = 0; i < count; ++i) { 98 234 printf("%d ", key_codes[i]); 235 // TODO: Key press / release 236 237 // TODO: NOT WORKING 238 unsigned int key = usbkbd_parse_scancode(key_codes[i]); 239 kbd_push_ev(KEY_PRESS, key); 99 240 } 100 241 printf("\n"); … … 130 271 assert(actual_size == length); 131 272 132 dump_hid_class_descriptor(0, USB_DESCTYPE_HID_REPORT,133 kbd_dev->conf->interfaces[i].report_desc, length);273 //dump_hid_class_descriptor(0, USB_DESCTYPE_HID_REPORT, 274 // kbd_dev->conf->interfaces[i].report_desc, length); 134 275 } 135 276 … … 189 330 } 190 331 191 usbkbd_print_config(kbd_dev->conf);332 //usbkbd_print_config(kbd_dev->conf); 192 333 193 334 /* … … 264 405 //usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks, 265 406 // NULL); 266 printf("Calling usb_hid_boot_keyboard_input_report()...\n)"); 267 usb_hid_boot_keyboard_input_report(buffer, actual_size, callbacks, NULL); 407 // printf("Calling usb_hid_boot_keyboard_input_report() with size %d\n", 408 // actual_size); 409 // dump_buffer("bufffer: ", buffer, actual_size); 410 int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, callbacks, 411 NULL); 412 if (rc != EOK) { 413 printf("Error in usb_hid_boot_keyboard_input_report(): %d\n", rc); 414 } 268 415 } 269 416 270 417 static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev) 271 418 { 272 return;273 274 419 int rc; 275 420 usb_handle_t handle; … … 289 434 }; 290 435 436 printf("Polling keyboard...\n"); 437 291 438 while (true) { 292 async_usleep(1000 * 1000 );439 async_usleep(1000 * 1000 * 2); 293 440 rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone, 294 441 poll_target, buffer, BUFFER_SIZE, &actual_size, &handle); 295 442 296 443 if (rc != EOK) { 444 printf("Error in usb_drv_async_interrupt_in(): %d\n", rc); 297 445 continue; 298 446 } … … 300 448 rc = usb_drv_async_wait_for(handle); 301 449 if (rc != EOK) { 450 printf("Error in usb_drv_async_wait_for(): %d\n", rc); 302 451 continue; 303 452 } … … 308 457 */ 309 458 if (actual_size == 0) { 459 printf("Keyboar returned NAK\n"); 310 460 continue; 311 461 } … … 314 464 * TODO: Process pressed keys. 315 465 */ 316 usbkbd_process_interrupt_in(kbd_dev, buffer, actual_size); 466 printf("Calling usbkbd_process_interrupt_in()\n"); 467 // actual_size is not set, workaround... 468 usbkbd_process_interrupt_in(kbd_dev, buffer, /*actual_size*/8); 317 469 } 318 470 … … 334 486 // initialize device (get and process descriptors, get address, etc.) 335 487 usb_hid_dev_kbd_t *kbd_dev = usbkbd_init_device(dev); 488 if (kbd_dev == NULL) { 489 printf("Error while initializing device.\n"); 490 return -1; 491 } 336 492 337 493 usbkbd_poll_keyboard(kbd_dev); -
uspace/lib/usb/src/hidparser.c
r0a9ea4a r6336b6e 35 35 #include <usb/classes/hidparser.h> 36 36 #include <errno.h> 37 #include <stdio.h> 37 38 38 39 /** Parse HID report descriptor. … … 120 121 item.logical_max = 255; 121 122 122 if (size != 8){123 return -1;123 if (size != 8) { 124 return ERANGE; 124 125 } 125 126 126 127 uint8_t keys[6]; 127 for (i=item.offset; i<item.count; i++) {128 keys[i -2] = data[i];128 for (i = 0; i < item.count; i++) { 129 keys[i] = data[i + item.offset]; 129 130 } 130 131
Note:
See TracChangeset
for help on using the changeset viewer.