Changes in / [d20f211:474d08e] in mainline
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/hidreq.c
rd20f211 r474d08e 143 143 /*----------------------------------------------------------------------------*/ 144 144 145 int usbhid_req_set_idle(usbhid_dev_t *hid_dev, uint8_t duration)146 {147 if (hid_dev == NULL) {148 usb_log_error("usbhid_req_set_idle(): no HID device "149 "structure given.\n");150 return EINVAL;151 }152 153 /*154 * No need for checking other parameters, as they are checked in155 * the called function (usb_control_request_set()).156 */157 158 int rc, sess_rc;159 160 sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe);161 if (sess_rc != EOK) {162 usb_log_warning("Failed to start a session: %s.\n",163 str_error(sess_rc));164 return sess_rc;165 }166 167 usb_log_debug("Sending Set_Idle request to the device ("168 "duration: %u, iface: %d).\n", duration, hid_dev->iface);169 170 uint16_t value = duration << 8;171 172 rc = usb_control_request_set(&hid_dev->ctrl_pipe,173 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,174 USB_HIDREQ_SET_IDLE, value, hid_dev->iface, NULL, 0);175 176 sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);177 178 if (rc != EOK) {179 usb_log_warning("Error sending output report to the keyboard: "180 "%s.\n", str_error(rc));181 return rc;182 }183 184 if (sess_rc != EOK) {185 usb_log_warning("Error closing session: %s.\n",186 str_error(sess_rc));187 return sess_rc;188 }189 190 return EOK;191 }192 193 /*----------------------------------------------------------------------------*/194 195 145 /** 196 146 * @} -
uspace/drv/usbhid/hidreq.h
rd20f211 r474d08e 50 50 int usbhid_req_set_protocol(usbhid_dev_t *hid_dev, usb_hid_protocol_t protocol); 51 51 52 int usbhid_req_set_idle(usbhid_dev_t *hid_dev, uint8_t duration);53 54 52 /*----------------------------------------------------------------------------*/ 55 53 -
uspace/drv/usbhid/kbddev.c
rd20f211 r474d08e 38 38 #include <str_error.h> 39 39 #include <fibril.h> 40 #include <stdio.h>41 40 42 41 #include <io/keycode.h> … … 63 62 static const size_t BOOTP_BUFFER_SIZE = 8; 64 63 static const size_t BOOTP_BUFFER_OUT_SIZE = 1; 65 static const uint8_t IDLE_RATE = 0;66 64 67 65 /** Keyboard polling endpoint description for boot protocol class. */ … … 151 149 uint8_t buffer[BOOTP_BUFFER_OUT_SIZE]; 152 150 int rc= 0; 151 unsigned i; 153 152 154 153 memset(buffer, 0, BOOTP_BUFFER_OUT_SIZE); … … 178 177 } 179 178 180 usb_log_debug("Output report buffer: %s\n", 181 usb_debug_str_buffer(buffer, BOOTP_BUFFER_OUT_SIZE, 0)); 179 // TODO: REFACTOR!!! 180 181 usb_log_debug("Output report buffer: "); 182 for (i = 0; i < BOOTP_BUFFER_OUT_SIZE; ++i) { 183 usb_log_debug("0x%x ", buffer[i]); 184 } 185 usb_log_debug("\n"); 182 186 183 187 uint16_t value = 0; … … 224 228 225 229 if (mod_mask != 0) { 230 usb_log_debug2("\n\nChanging mods and lock keys\n"); 231 usb_log_debug2("\nmods before: 0x%x\n", kbd_dev->mods); 232 usb_log_debug2("\nLock keys before:0x%x\n\n", 233 kbd_dev->lock_keys); 234 226 235 if (type == KEY_PRESS) { 236 usb_log_debug2("\nKey pressed.\n"); 227 237 /* 228 238 * Only change lock state on transition from released … … 237 247 usbhid_kbd_set_led(kbd_dev); 238 248 } else { 249 usb_log_debug2("\nKey released.\n"); 239 250 kbd_dev->lock_keys = kbd_dev->lock_keys & ~mod_mask; 240 251 } 241 252 } 242 253 254 usb_log_debug2("\n\nmods after: 0x%x\n", kbd_dev->mods); 255 usb_log_debug2("\nLock keys after: 0x%x\n\n", kbd_dev->lock_keys); 256 243 257 if (key == KC_CAPS_LOCK || key == KC_NUM_LOCK || key == KC_SCROLL_LOCK) { 244 258 // do not send anything to the console, this is our business … … 267 281 ev.key = key; 268 282 ev.mods = kbd_dev->mods; 283 284 if (ev.mods & KM_NUM_LOCK) { 285 usb_log_debug("\n\nNum Lock turned on.\n\n"); 286 } 269 287 270 288 ev.c = layout[active_layout]->parse_ev(&ev); … … 371 389 } 372 390 } 373 // // report all currently pressed keys374 // for (i = 0; i < kbd_dev->keycode_count; ++i) {375 // if (key_codes[i] != 0) {376 // key = usbhid_parse_scancode(key_codes[i]);377 // usb_log_debug2("\nKey pressed: %d (keycode: %d)\n", key,378 // key_codes[i]);379 // usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, key);380 // }381 // }382 391 383 392 memcpy(kbd_dev->keycodes, key_codes, kbd_dev->keycode_count); 384 385 usb_log_debug("New stored keycodes: %s\n", 386 usb_debug_str_buffer(kbd_dev->keycodes, kbd_dev->keycode_count, 0)); 393 394 usb_log_debug2("\nNew stored keycodes: "); 395 for (i = 0; i < kbd_dev->keycode_count; ++i) { 396 usb_log_debug2("%d ", kbd_dev->keycodes[i]); 397 } 387 398 } 388 399 … … 399 410 return; 400 411 } 412 413 usb_log_debug2("Got keys from parser: "); 414 unsigned i; 415 for (i = 0; i < count; ++i) { 416 usb_log_debug2("%d ", key_codes[i]); 417 } 418 usb_log_debug2("\n"); 401 419 402 420 usbhid_kbd_t *kbd_dev = (usbhid_kbd_t *)arg; 403 421 assert(kbd_dev != NULL); 404 405 usb_log_debug("Got keys from parser: %s\n",406 usb_debug_str_buffer(key_codes, kbd_dev->keycode_count, 0));407 422 408 423 if (count != kbd_dev->keycode_count) { … … 429 444 callbacks->keyboard = usbhid_kbd_process_keycodes; 430 445 431 usb_log_debug("Calling usb_hid_boot_keyboard_input_report() with " 432 "buffer %s\n", usb_debug_str_buffer(buffer, actual_size, 0)); 446 //usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks, 447 // NULL); 448 /*usb_log_debug2("Calling usb_hid_boot_keyboard_input_report() with size" 449 " %zu\n", actual_size);*/ 450 //dump_buffer("bufffer: ", buffer, actual_size); 433 451 434 452 int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, … … 541 559 * Set boot protocol. 542 560 * Set LEDs according to initial setup. 543 * Set Idle rate544 561 */ 545 562 assert(kbd_dev->hid_dev != NULL); … … 548 565 549 566 usbhid_kbd_set_led(kbd_dev); 550 551 usbhid_req_set_idle(kbd_dev->hid_dev, IDLE_RATE);552 567 553 568 kbd_dev->initialized = 1; … … 619 634 usbhid_kbd_process_data(kbd_dev, buffer, actual_size); 620 635 621 // disabled for now, no reason to sleep 622 //async_usleep(kbd_dev->hid_dev->poll_interval); 636 async_usleep(kbd_dev->hid_dev->poll_interval); 623 637 } 624 638 -
uspace/drv/usbhid/main.c
rd20f211 r474d08e 80 80 int main(int argc, char *argv[]) 81 81 { 82 usb_log_enable(USB_LOG_LEVEL_ DEBUG, NAME);82 usb_log_enable(USB_LOG_LEVEL_INFO, NAME); 83 83 return ddf_driver_main(&kbd_driver); 84 84 } -
uspace/lib/usb/include/usb/debug.h
rd20f211 r474d08e 79 79 usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__) 80 80 81 const char *usb_debug_str_buffer( constuint8_t *, size_t, size_t);81 const char *usb_debug_str_buffer(uint8_t *, size_t, size_t); 82 82 83 83 -
uspace/lib/usb/src/debug.c
rd20f211 r474d08e 281 281 * @return Dumped buffer as a static (but fibril local) string. 282 282 */ 283 const char *usb_debug_str_buffer( constuint8_t *buffer, size_t size,283 const char *usb_debug_str_buffer(uint8_t *buffer, size_t size, 284 284 size_t dumped_size) 285 285 {
Note:
See TracChangeset
for help on using the changeset viewer.