Changeset 4837092 in mainline


Ignore:
Timestamp:
2011-02-04T16:40:10Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
92574f4
Parents:
8c3c756
Message:

Modifiers handling + fixes.

  • Handle modifiers from flags. However, modifiers may be sent also as regular keys, would need to look into that.
  • Changed modifier constants in hidparser.h
Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/hid.h

    r8c3c756 r4837092  
    7979        uint8_t *keycodes;
    8080        size_t keycode_count;
     81        uint8_t modifiers;
    8182} usb_hid_dev_kbd_t;
    8283
  • uspace/drv/usbhid/main.c

    r8c3c756 r4837092  
    248248         */
    249249
     250static const keycode_t usb_hid_modifiers_boot_keycodes[5] = {
     251        KC_NUM_LOCK,      /* USB_HID_MOD_BOOT_NUM_LOCK */
     252        KC_CAPS_LOCK,     /* USB_HID_MOD_BOOT_CAPS_LOCK */
     253        KC_SCROLL_LOCK,   /* USB_HID_MOD_BOOT_SCROLL_LOCK */
     254        0,                /* USB_HID_MOD_BOOT_COMPOSE */
     255        0                 /* USB_HID_MOD_BOOT_KANA */
     256};
     257
    250258static void usbkbd_check_modifier_changes(usb_hid_dev_kbd_t *kbd_dev,
    251259    uint8_t modifiers)
    252260{
    253         // ignore for now
    254         // modifiers should be sent as normal keys to usbkbd_parse_scancode()!!
    255         // so it would be better if I received it from report parser in that way
     261        /*
     262         * TODO: why the USB keyboard has NUM_, SCROLL_ and CAPS_LOCK
     263         *       both as modifiers and as keys with their own scancodes???
     264         *
     265         * modifiers should be sent as normal keys to usbkbd_parse_scancode()!!
     266         * so maybe it would be better if I received it from report parser in
     267         * that way
     268         */
     269       
     270        int i;
     271        for (i = 0; i < USB_HID_MOD_BOOT_COUNT; ++i) {
     272                if ((modifiers & usb_hid_modifiers_boot_consts[i]) &&
     273                    !(kbd_dev->modifiers & usb_hid_modifiers_boot_consts[i])) {
     274                        // modifier pressed
     275                        if (usb_hid_modifiers_boot_keycodes[i] != 0) {
     276                                kbd_push_ev(KEY_PRESS,
     277                                    usb_hid_modifiers_boot_keycodes[i]);
     278                        }
     279                } else if (!(modifiers & usb_hid_modifiers_boot_consts[i]) &&
     280                    (kbd_dev->modifiers & usb_hid_modifiers_boot_consts[i])) {
     281                        // modifier released
     282                        if (usb_hid_modifiers_boot_keycodes[i] != 0) {
     283                                kbd_push_ev(KEY_RELEASE,
     284                                    usb_hid_modifiers_boot_keycodes[i]);
     285                        }
     286                }       // no change
     287        }
    256288}
    257289
     
    262294       
    263295        unsigned int key;
    264         int i, j;
     296        unsigned int i, j;
    265297       
    266298        // TODO: quite dummy right now, think of better implementation
     
    486518        kbd_dev->keycode_count = BOOTP_REPORT_SIZE;
    487519        kbd_dev->keycodes = (uint8_t *)calloc(
    488             kbd_dev->keycode_count * sizeof(uint8_t));
     520            kbd_dev->keycode_count, sizeof(uint8_t));
    489521       
    490522        if (kbd_dev->keycodes == NULL) {
  • uspace/lib/usb/include/usb/classes/hidparser.h

    r8c3c756 r4837092  
    7070} usb_hid_report_in_callbacks_t;
    7171
    72 #define USB_HID_BOOT_KEYBOARD_NUM_LOCK          0x01
    73 #define USB_HID_BOOT_KEYBOARD_CAPS_LOCK         0x02
    74 #define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK       0x04
    75 #define USB_HID_BOOT_KEYBOARD_COMPOSE           0x08
    76 #define USB_HID_BOOT_KEYBOARD_KANA                      0x10
     72
     73typedef enum {
     74        USB_HID_MOD_BOOT_NUM_LOCK = 0x01,
     75        USB_HID_MOD_BOOT_CAPS_LOCK = 0x02,
     76        USB_HID_MOD_BOOT_SCROLL_LOCK = 0x04,
     77        USB_HID_MOD_BOOT_COMPOSE = 0x08,
     78        USB_HID_MOD_BOOT_KANA = 0x10,
     79        USB_HID_MOD_BOOT_COUNT = 5
     80} usb_hid_modifiers_boot_t;
     81
     82static const usb_hid_modifiers_boot_t usb_hid_modifiers_boot_consts[5] = {
     83        USB_HID_MOD_BOOT_NUM_LOCK,
     84        USB_HID_MOD_BOOT_CAPS_LOCK,
     85        USB_HID_MOD_BOOT_SCROLL_LOCK,
     86        USB_HID_MOD_BOOT_COMPOSE,
     87        USB_HID_MOD_BOOT_KANA
     88};
     89
     90//#define USB_HID_BOOT_KEYBOARD_NUM_LOCK                0x01
     91//#define USB_HID_BOOT_KEYBOARD_CAPS_LOCK               0x02
     92//#define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK     0x04
     93//#define USB_HID_BOOT_KEYBOARD_COMPOSE         0x08
     94//#define USB_HID_BOOT_KEYBOARD_KANA                    0x10
    7795
    7896/*
Note: See TracChangeset for help on using the changeset viewer.