Changeset 06f9d8fb in mainline for uspace/drv/usbhid/kbd/kbddev.c


Ignore:
Timestamp:
2011-05-30T20:02:17Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c3dafe1
Parents:
be8d907 (diff), 63862a0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with usb/development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/kbd/kbddev.c

    rbe8d907 r06f9d8fb  
    7272static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK;
    7373
    74 ///** Boot protocol report size (key part). */
    75 //static const size_t BOOTP_REPORT_SIZE = 6;
    76 
    77 ///** Boot protocol total report size. */
    78 //static const size_t BOOTP_BUFFER_SIZE = 8;
    79 
    80 ///** Boot protocol output report size. */
    81 //static const size_t BOOTP_BUFFER_OUT_SIZE = 1;
    82 
    83 ///** Boot protocol error key code. */
    84 //static const uint8_t BOOTP_ERROR_ROLLOVER = 1;
    8574static const uint8_t ERROR_ROLLOVER = 1;
    8675
     
    10594        .flags = 0
    10695};
    107 
    108 //static usb_endpoint_description_t hid_poll_endpoint_description = {
    109 //      .transfer_type = USB_TRANSFER_INTERRUPT,
    110 //      .direction = USB_DIRECTION_IN,
    111 //      .interface_class = USB_CLASS_HID,
    112 //      .flags = 0
    113 //};
    114 
    115 ///* Array of endpoints expected on the device, NULL terminated. */
    116 //usb_endpoint_description_t
    117 //    *usb_kbd_endpoints[USB_KBD_POLL_EP_COUNT + 1] = {
    118 //      &boot_poll_endpoint_description,
    119 //      &hid_poll_endpoint_description,
    120 //      NULL
    121 //};
    12296
    12397const char *HID_KBD_FUN_NAME = "keyboard";
     
    176150
    177151/*----------------------------------------------------------------------------*/
    178 
    179 //static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
    180 //    uint8_t report_id, void *arg);
    181 
    182 //static const usb_hid_report_in_callbacks_t usb_kbd_parser_callbacks = {
    183 //      .keyboard = usb_kbd_process_keycodes
    184 //};
    185 
    186 /*----------------------------------------------------------------------------*/
    187152/* Keyboard layouts                                                           */
    188153/*----------------------------------------------------------------------------*/
     
    200165
    201166/*----------------------------------------------------------------------------*/
    202 /* Modifier constants                                                         */
    203 /*----------------------------------------------------------------------------*/
    204 /** Mapping of USB modifier key codes to generic modifier key codes. */
    205 //static const keycode_t usbhid_modifiers_keycodes[USB_HID_MOD_COUNT] = {
    206 //      KC_LCTRL,         /* USB_HID_MOD_LCTRL */
    207 //      KC_LSHIFT,        /* USB_HID_MOD_LSHIFT */
    208 //      KC_LALT,          /* USB_HID_MOD_LALT */
    209 //      0,                /* USB_HID_MOD_LGUI */
    210 //      KC_RCTRL,         /* USB_HID_MOD_RCTRL */
    211 //      KC_RSHIFT,        /* USB_HID_MOD_RSHIFT */
    212 //      KC_RALT,          /* USB_HID_MOD_RALT */
    213 //      0,                /* USB_HID_MOD_RGUI */
    214 //};
    215 
    216 //typedef enum usbhid_lock_code {
    217 //      USB_KBD_LOCK_NUM = 0x53,
    218 //      USB_KBD_LOCK_CAPS = 0x39,
    219 //      USB_KBD_LOCK_SCROLL = 0x47,
    220 //      USB_KBD_LOCK_COUNT = 3
    221 //} usbhid_lock_code;
    222 
    223 //static const usbhid_lock_code usbhid_lock_codes[USB_KBD_LOCK_COUNT] = {
    224 //      USB_KBD_LOCK_NUM,
    225 //      USB_KBD_LOCK_CAPS,
    226 //      USB_KBD_LOCK_SCROLL
    227 //};
    228 
    229 /*----------------------------------------------------------------------------*/
    230167/* IPC method handler                                                         */
    231168/*----------------------------------------------------------------------------*/
    232169
    233170static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
    234 //ddf_dev_ops_t keyboard_ops = {
    235 //      .default_handler = default_connection_handler
    236 //};
    237171
    238172/**
     
    301235                return;
    302236        }
    303                
     237
    304238        /* Reset the LED data. */
    305239        memset(kbd_dev->led_data, 0, kbd_dev->led_output_size * sizeof(int32_t));
     
    495429 */
    496430static void usb_kbd_check_key_changes(usb_hid_dev_t *hid_dev,
    497     usb_kbd_t *kbd_dev/*, const uint8_t *key_codes, size_t count*/)
     431    usb_kbd_t *kbd_dev)
    498432{
    499433        unsigned int key;
     
    567501        }
    568502       
    569 //      usb_log_debug("Old keys: ");
    570 //      for (i = 0; i < kbd_dev->key_count; ++i) {
    571 //              usb_log_debug("%d ", kbd_dev->keys_old[i]);
    572 //      }
    573 //      usb_log_debug("\n");
    574        
    575        
    576 //      usb_log_debug("New keys: ");
    577 //      for (i = 0; i < kbd_dev->key_count; ++i) {
    578 //              usb_log_debug("%d ", kbd_dev->keys[i]);
    579 //      }
    580 //      usb_log_debug("\n");
    581        
    582503        memcpy(kbd_dev->keys_old, kbd_dev->keys, kbd_dev->key_count * 4);
    583504       
     
    590511
    591512/*----------------------------------------------------------------------------*/
    592 /* Callbacks for parser                                                       */
    593 /*----------------------------------------------------------------------------*/
    594 /**
    595  * Callback function for the HID report parser.
    596  *
    597  * This function is called by the HID report parser with the parsed report.
    598  * The parsed report is used to check if any events occured (key was pressed or
    599  * released, modifier was pressed or released).
    600  *
    601  * @param key_codes Parsed keyboard report - codes of currently pressed keys
    602  *                  according to HID Usage Tables.
    603  * @param count Number of key codes in report (size of the report).
    604  * @param report_id
    605  * @param arg User-specified argument. Expects pointer to the keyboard device
    606  *            structure representing the keyboard.
    607  *
    608  * @sa usb_kbd_check_key_changes(), usb_kbd_check_modifier_changes()
    609  */
    610 //static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
    611 //    uint8_t report_id, void *arg)
    612 //{
    613 //      if (arg == NULL) {
    614 //              usb_log_warning("Missing argument in callback "
    615 //                  "usbhid_process_keycodes().\n");
    616 //              return;
    617 //      }
    618        
    619 //      usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;
    620        
    621 //      if (hid_dev->data == NULL) {
    622 //              usb_log_warning("Missing KBD device structure in callback.\n");
    623 //              return;
    624 //      }
    625        
    626 //      usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
    627 
    628 //      usb_log_debug("Got keys from parser (report id: %u): %s\n",
    629 //          report_id, usb_debug_str_buffer(key_codes, count, 0));
    630        
    631 //      if (count != kbd_dev->key_count) {
    632 //              usb_log_warning("Number of received keycodes (%zu) differs from"
    633 //                  " expected (%zu).\n", count, kbd_dev->key_count);
    634 //              return;
    635 //      }
    636        
    637 //      ///usb_kbd_check_modifier_changes(kbd_dev, key_codes, count);
    638 //      usb_kbd_check_key_changes(hid_dev, kbd_dev, key_codes, count);
    639 //}
    640 
    641 /*----------------------------------------------------------------------------*/
    642513/* General kbd functions                                                      */
    643514/*----------------------------------------------------------------------------*/
     
    668539            "buffer %s\n", usb_debug_str_buffer(buffer, actual_size, 0));
    669540       
    670 //      int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size,
    671 //          callbacks, kbd_dev);
    672541        usb_hid_report_path_t *path = usb_hid_report_path();
    673542        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
    674         //usb_hid_report_path_set_report_id(path, 0);
    675543
    676544        uint8_t report_id;
     
    698566               
    699567                assert(i < kbd_dev->key_count);
    700 //              if (i == kbd_dev->key_count) {
    701 //                      break;
    702 //              }
    703568               
    704569                // save the key usage
    705                 /* TODO: maybe it's not good to save value, nor usage
    706                  *       as the value may be e.g. 1 for LEDs and usage may be
    707                  *       value of the LED. On the other hand, in case of normal
    708                  *       keys, the usage is more important and we must check
    709                  *       that. One possible solution: distinguish between those
    710                  *       two parts of the Report somehow.
    711                  */
    712570                if (field->value != 0) {
    713571                        kbd_dev->keys[i] = field->usage;
     
    896754                usb_log_warning("Error creating output report buffer.\n");
    897755                free(kbd_dev->keys);
    898                 return ENOMEM;  /* TODO: other error code */
     756                return ENOMEM;
    899757        }
    900758       
     
    951809       
    952810        // save the KBD device structure into the HID device structure
    953         //hid_dev->data = kbd_dev;
    954811        *data = kbd_dev;
    955812       
     
    1038895       
    1039896        if ((*kbd_dev)->repeat_mtx != NULL) {
    1040                 /* TODO: replace by some check and wait */
    1041                 assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
     897                //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
     898                while (fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)) {}
    1042899                free((*kbd_dev)->repeat_mtx);
    1043900        }
Note: See TracChangeset for help on using the changeset viewer.