Changes in / [d20f211:474d08e] in mainline


Ignore:
Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/hidreq.c

    rd20f211 r474d08e  
    143143/*----------------------------------------------------------------------------*/
    144144
    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 in
    155          * 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 
    195145/**
    196146 * @}
  • uspace/drv/usbhid/hidreq.h

    rd20f211 r474d08e  
    5050int usbhid_req_set_protocol(usbhid_dev_t *hid_dev, usb_hid_protocol_t protocol);
    5151
    52 int usbhid_req_set_idle(usbhid_dev_t *hid_dev, uint8_t duration);
    53 
    5452/*----------------------------------------------------------------------------*/
    5553
  • uspace/drv/usbhid/kbddev.c

    rd20f211 r474d08e  
    3838#include <str_error.h>
    3939#include <fibril.h>
    40 #include <stdio.h>
    4140
    4241#include <io/keycode.h>
     
    6362static const size_t BOOTP_BUFFER_SIZE = 8;
    6463static const size_t BOOTP_BUFFER_OUT_SIZE = 1;
    65 static const uint8_t IDLE_RATE = 0;
    6664
    6765/** Keyboard polling endpoint description for boot protocol class. */
     
    151149        uint8_t buffer[BOOTP_BUFFER_OUT_SIZE];
    152150        int rc= 0;
     151        unsigned i;
    153152       
    154153        memset(buffer, 0, BOOTP_BUFFER_OUT_SIZE);
     
    178177        }
    179178       
    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");
    182186       
    183187        uint16_t value = 0;
     
    224228
    225229        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               
    226235                if (type == KEY_PRESS) {
     236                        usb_log_debug2("\nKey pressed.\n");
    227237                        /*
    228238                         * Only change lock state on transition from released
     
    237247                        usbhid_kbd_set_led(kbd_dev);
    238248                } else {
     249                        usb_log_debug2("\nKey released.\n");
    239250                        kbd_dev->lock_keys = kbd_dev->lock_keys & ~mod_mask;
    240251                }
    241252        }
    242253
     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       
    243257        if (key == KC_CAPS_LOCK || key == KC_NUM_LOCK || key == KC_SCROLL_LOCK) {
    244258                // do not send anything to the console, this is our business
     
    267281        ev.key = key;
    268282        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        }
    269287
    270288        ev.c = layout[active_layout]->parse_ev(&ev);
     
    371389                }
    372390        }
    373 //      // report all currently pressed keys
    374 //      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 //      }
    382391       
    383392        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        }
    387398}
    388399
     
    399410                return;
    400411        }
     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");
    401419       
    402420        usbhid_kbd_t *kbd_dev = (usbhid_kbd_t *)arg;
    403421        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));
    407422       
    408423        if (count != kbd_dev->keycode_count) {
     
    429444        callbacks->keyboard = usbhid_kbd_process_keycodes;
    430445
    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);
    433451       
    434452        int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size,
     
    541559         * Set boot protocol.
    542560         * Set LEDs according to initial setup.
    543          * Set Idle rate
    544561         */
    545562        assert(kbd_dev->hid_dev != NULL);
     
    548565       
    549566        usbhid_kbd_set_led(kbd_dev);
    550        
    551         usbhid_req_set_idle(kbd_dev->hid_dev, IDLE_RATE);
    552567       
    553568        kbd_dev->initialized = 1;
     
    619634                usbhid_kbd_process_data(kbd_dev, buffer, actual_size);
    620635               
    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);
    623637        }
    624638
  • uspace/drv/usbhid/main.c

    rd20f211 r474d08e  
    8080int main(int argc, char *argv[])
    8181{
    82         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     82        usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
    8383        return ddf_driver_main(&kbd_driver);
    8484}
  • uspace/lib/usb/include/usb/debug.h

    rd20f211 r474d08e  
    7979        usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__)
    8080
    81 const char *usb_debug_str_buffer(const uint8_t *, size_t, size_t);
     81const char *usb_debug_str_buffer(uint8_t *, size_t, size_t);
    8282
    8383
  • uspace/lib/usb/src/debug.c

    rd20f211 r474d08e  
    281281 * @return Dumped buffer as a static (but fibril local) string.
    282282 */
    283 const char *usb_debug_str_buffer(const uint8_t *buffer, size_t size,
     283const char *usb_debug_str_buffer(uint8_t *buffer, size_t size,
    284284    size_t dumped_size)
    285285{
Note: See TracChangeset for help on using the changeset viewer.