Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbkbd/kbddev.c

    r70a71e5 rb83edb93  
    7070static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK;
    7171
    72 /** Boot protocol report size (key part). */
    73 static const size_t BOOTP_REPORT_SIZE = 6;
    74 
    75 /** Boot protocol total report size. */
    76 static const size_t BOOTP_BUFFER_SIZE = 8;
    77 
    78 /** Boot protocol output report size. */
    79 static const size_t BOOTP_BUFFER_OUT_SIZE = 1;
    80 
    81 /** Boot protocol error key code. */
    82 static const uint8_t BOOTP_ERROR_ROLLOVER = 1;
     72///** Boot protocol report size (key part). */
     73//static const size_t BOOTP_REPORT_SIZE = 6;
     74
     75///** Boot protocol total report size. */
     76//static const size_t BOOTP_BUFFER_SIZE = 8;
     77
     78///** Boot protocol output report size. */
     79//static const size_t BOOTP_BUFFER_OUT_SIZE = 1;
     80
     81///** Boot protocol error key code. */
     82//static const uint8_t BOOTP_ERROR_ROLLOVER = 1;
     83static const uint8_t ERROR_ROLLOVER = 1;
    8384
    8485/** Default idle rate for keyboards. */
     
    264265static void usb_kbd_set_led(usb_kbd_t *kbd_dev)
    265266{
    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 
     267        if (kbd_dev->output_size == 0) {
     268                return;
     269        }
     270       
    272271        unsigned i = 0;
     272       
     273        /* Reset the LED data. */
     274        memset(kbd_dev->led_data, 0, kbd_dev->led_output_size * sizeof(int32_t));
    273275       
    274276        if ((kbd_dev->mods & KM_NUM_LOCK) && (i < kbd_dev->led_output_size)) {
    275277                kbd_dev->led_data[i++] = USB_HID_LED_NUM_LOCK;
    276 //              leds |= USB_HID_LED_NUM_LOCK;
    277         }
    278         else {
    279             kbd_dev->led_data[i++] = 0;
    280278        }
    281279       
    282280        if ((kbd_dev->mods & KM_CAPS_LOCK) && (i < kbd_dev->led_output_size)) {
    283281                kbd_dev->led_data[i++] = USB_HID_LED_CAPS_LOCK;
    284 //              leds |= USB_HID_LED_CAPS_LOCK;
    285         }
    286         else {
    287             kbd_dev->led_data[i++] = 0;
    288282        }
    289283       
     
    291285            && (i < kbd_dev->led_output_size)) {
    292286                kbd_dev->led_data[i++] = USB_HID_LED_SCROLL_LOCK;
    293 //              leds |= USB_HID_LED_SCROLL_LOCK;
    294         }
    295         else {
    296             kbd_dev->led_data[i++] = 0;
    297         }
    298        
    299         usb_log_debug("Output report data: ");
    300         for (i = 0; i < kbd_dev->led_output_size; ++i) {
    301                 usb_log_debug("%u: %d", i, kbd_dev->led_data[i]);
    302287        }
    303288
     
    307292       
    308293        int rc = usb_hid_report_output_translate(kbd_dev->parser,
    309             kbd_dev->led_path, USB_HID_PATH_COMPARE_END, kbd_dev->output_buffer,
     294            kbd_dev->led_path,
     295            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     296            kbd_dev->output_buffer,
    310297            kbd_dev->output_size, kbd_dev->led_data, kbd_dev->led_output_size);
    311298       
     
    315302                return;
    316303        }
    317        
    318 //      if ((rc = usb_hid_boot_keyboard_output_report(
    319 //          leds, buffer, BOOTP_BUFFER_OUT_SIZE)) != EOK) {
    320 //              usb_log_warning("Error composing output report to the keyboard:"
    321 //                  "%s.\n", str_error(rc));
    322 //              return;
    323 //      }
    324304       
    325305        usb_log_debug("Output report buffer: %s\n",
     
    480460         * First of all, check if the kbd have reported phantom state.
    481461         *
    482          *  this must be changed as we don't know which keys are modifiers
    483          *       and which are regular keys.
     462         * As there is no way to distinguish keys from modifiers, we do not have
     463         * a way to check that 'all keys report Error Rollover'. We thus check
     464         * if there is at least one such error and in such case we ignore the
     465         * whole input report.
    484466         */
    485467        i = 0;
    486         // all fields should report Error Rollover
    487         while (i < count &&
    488             key_codes[i] == BOOTP_ERROR_ROLLOVER) {
     468        while (i < count && key_codes[i] != ERROR_ROLLOVER) {
    489469                ++i;
    490470        }
    491         if (i == count) {
     471        if (i != count) {
    492472                usb_log_debug("Phantom state occured.\n");
    493473                // phantom state, do nothing
     
    565545 *                  according to HID Usage Tables.
    566546 * @param count Number of key codes in report (size of the report).
    567  * @param modifiers Bitmap of modifiers (Ctrl, Alt, Shift, GUI).
     547 * @param report_id
    568548 * @param arg User-specified argument. Expects pointer to the keyboard device
    569549 *            structure representing the keyboard.
     
    572552 */
    573553static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
    574     uint8_t modifiers, void *arg)
     554    uint8_t report_id, void *arg)
    575555{
    576556        if (arg == NULL) {
     
    583563        assert(kbd_dev != NULL);
    584564
    585         usb_log_debug("Got keys from parser: %s\n",
    586             usb_debug_str_buffer(key_codes, count, 0));
     565        usb_log_debug("Got keys from parser (report id: %u): %s\n",
     566            report_id, usb_debug_str_buffer(key_codes, count, 0));
    587567       
    588568        if (count != kbd_dev->key_count) {
     
    634614        usb_hid_report_path_t *path = usb_hid_report_path();
    635615        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
     616        usb_hid_report_path_set_report_id(path, 1);
    636617       
    637618        int rc = usb_hid_parse_report(kbd_dev->parser, buffer,
    638             actual_size, path, USB_HID_PATH_COMPARE_STRICT, callbacks, kbd_dev);
     619            actual_size, path,
     620            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     621            callbacks, kbd_dev);
    639622
    640623        usb_hid_report_path_free (path);
     
    784767        usb_hid_report_path_t *path = usb_hid_report_path();
    785768        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
     769       
     770        usb_hid_report_path_set_report_id(path, 1);
     771       
    786772        kbd_dev->key_count = usb_hid_report_input_length(
    787             kbd_dev->parser, path, USB_HID_PATH_COMPARE_STRICT);
     773            kbd_dev->parser, path,
     774            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
    788775        usb_hid_report_path_free (path);
    789776       
     
    803790        kbd_dev->output_buffer = usb_hid_report_output(kbd_dev->parser,
    804791            &kbd_dev->output_size);
    805         if (kbd_dev->output_buffer == NULL) {
     792        if (kbd_dev->output_buffer == NULL && kbd_dev->output_size != 0) {
    806793                usb_log_warning("Error creating output report buffer.\n");
    807794                free(kbd_dev->keys);
     
    816803       
    817804        kbd_dev->led_output_size = usb_hid_report_output_size(kbd_dev->parser,
    818             kbd_dev->led_path, USB_HID_PATH_COMPARE_END);
     805            kbd_dev->led_path,
     806            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
    819807       
    820808        usb_log_debug("Output report size (in items): %zu\n",
Note: See TracChangeset for help on using the changeset viewer.