Changeset 9e929a0 in mainline for uspace/drv


Ignore:
Timestamp:
2011-04-29T14:07:23Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0dea35f, 26f6094
Parents:
152ec79 (diff), f19f1b7 (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 development

Location:
uspace/drv
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/Makefile

    r152ec79 r9e929a0  
    4747        mouse/mousedev.c \
    4848        lgtch-ultrax/lgtch-ultrax.c \
     49        lgtch-ultrax/keymap.c \
    4950        $(STOLEN_LAYOUT_SOURCES)
    5051
  • uspace/drv/usbhid/kbd/conv.c

    r152ec79 r9e929a0  
    9999        [0x30] = KC_RBRACKET,
    100100        [0x31] = KC_BACKSLASH,
    101         //[0x32] = KC_, // TODO: HASH??? maybe some as 0x31 - backslash
     101        //[0x32] = KC_, // TODO: HASH??? maybe same as 0x31 - backslash
     102        [0x32] = KC_BACKSLASH,
    102103        [0x33] = KC_SEMICOLON,
    103104        [0x34] = KC_QUOTE,  // same as APOSTROPHE? (')
  • uspace/drv/usbhid/kbd/kbddev.c

    r152ec79 r9e929a0  
    177177/*----------------------------------------------------------------------------*/
    178178
    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 };
     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//};
    185185
    186186/*----------------------------------------------------------------------------*/
     
    203203/*----------------------------------------------------------------------------*/
    204204/** 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 };
     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//};
    228228
    229229/*----------------------------------------------------------------------------*/
     
    299299                return;
    300300        }
    301        
    302         unsigned i = 0;
    303        
     301               
    304302        /* Reset the LED data. */
    305303        memset(kbd_dev->led_data, 0, kbd_dev->led_output_size * sizeof(int32_t));
    306        
    307         if ((kbd_dev->mods & KM_NUM_LOCK) && (i < kbd_dev->led_output_size)) {
    308                 kbd_dev->led_data[i++] = USB_HID_LED_NUM_LOCK;
    309         }
    310        
    311         if ((kbd_dev->mods & KM_CAPS_LOCK) && (i < kbd_dev->led_output_size)) {
    312                 kbd_dev->led_data[i++] = USB_HID_LED_CAPS_LOCK;
    313         }
    314        
    315         if ((kbd_dev->mods & KM_SCROLL_LOCK)
    316             && (i < kbd_dev->led_output_size)) {
    317                 kbd_dev->led_data[i++] = USB_HID_LED_SCROLL_LOCK;
    318         }
    319 
    320         // TODO: COMPOSE and KANA
    321        
    322         usb_log_debug("Creating output report.\n");
    323        
    324         int rc = usb_hid_report_output_translate(hid_dev->parser,
    325             kbd_dev->led_path,
    326             USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    327             kbd_dev->output_buffer,
    328             kbd_dev->output_size, kbd_dev->led_data, kbd_dev->led_output_size);
     304        usb_log_debug("Creating output report:\n");
     305
     306        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
     307            hid_dev->report, NULL, kbd_dev->led_path,
     308            USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY | USB_HID_PATH_COMPARE_END,
     309            USB_HID_REPORT_TYPE_OUTPUT);
     310       
     311        while (field != NULL) {
     312
     313                if ((field->usage == USB_HID_LED_NUM_LOCK)
     314                    && (kbd_dev->mods & KM_NUM_LOCK)){
     315                        field->value = 1;
     316                }
     317
     318                if ((field->usage == USB_HID_LED_CAPS_LOCK)
     319                    && (kbd_dev->mods & KM_CAPS_LOCK)){
     320                        field->value = 1;
     321                }
     322
     323                if ((field->usage == USB_HID_LED_SCROLL_LOCK)
     324                    && (kbd_dev->mods & KM_SCROLL_LOCK)){
     325                        field->value = 1;
     326                }
     327               
     328                field = usb_hid_report_get_sibling(hid_dev->report, field,
     329                    kbd_dev->led_path, USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY
     330                    | USB_HID_PATH_COMPARE_END, USB_HID_REPORT_TYPE_OUTPUT);
     331        }
     332       
     333        // TODO: what about the Report ID?
     334        int rc = usb_hid_report_output_translate(hid_dev->report, 0,
     335            kbd_dev->output_buffer, kbd_dev->output_size);
    329336       
    330337        if (rc != EOK) {
     
    485492 */
    486493static void usb_kbd_check_key_changes(usb_hid_dev_t *hid_dev,
    487     usb_kbd_t *kbd_dev, const uint8_t *key_codes, size_t count)
     494    usb_kbd_t *kbd_dev/*, const uint8_t *key_codes, size_t count*/)
    488495{
    489496        unsigned int key;
     
    499506         */
    500507        i = 0;
    501         while (i < count && key_codes[i] != ERROR_ROLLOVER) {
     508        while (i < kbd_dev->key_count && kbd_dev->keys[i] != ERROR_ROLLOVER) {
    502509                ++i;
    503510        }
    504         if (i != count) {
     511        if (i != kbd_dev->key_count) {
    505512                usb_log_debug("Phantom state occured.\n");
    506513                // phantom state, do nothing
    507514                return;
    508515        }
    509        
    510         /* TODO: quite dummy right now, think of better implementation */
    511         assert(count == kbd_dev->key_count);
    512516       
    513517        /*
    514518         * 1) Key releases
    515519         */
    516         for (j = 0; j < count; ++j) {
     520        for (j = 0; j < kbd_dev->key_count; ++j) {
    517521                // try to find the old key in the new key list
    518522                i = 0;
    519523                while (i < kbd_dev->key_count
    520                     && key_codes[i] != kbd_dev->keys[j]) {
     524                    && kbd_dev->keys[i] != kbd_dev->keys_old[j]) {
    521525                        ++i;
    522526                }
    523527               
    524                 if (i == count) {
     528                if (i == kbd_dev->key_count) {
    525529                        // not found, i.e. the key was released
    526                         key = usbhid_parse_scancode(kbd_dev->keys[j]);
     530                        key = usbhid_parse_scancode(kbd_dev->keys_old[j]);
    527531                        if (!usb_kbd_is_lock(key)) {
    528532                                usb_kbd_repeat_stop(kbd_dev, key);
     
    541545                // try to find the new key in the old key list
    542546                j = 0;
    543                 while (j < count && kbd_dev->keys[j] != key_codes[i]) {
     547                while (j < kbd_dev->key_count
     548                    && kbd_dev->keys_old[j] != kbd_dev->keys[i]) {
    544549                        ++j;
    545550                }
    546551               
    547                 if (j == count) {
     552                if (j == kbd_dev->key_count) {
    548553                        // not found, i.e. new key pressed
    549                         key = usbhid_parse_scancode(key_codes[i]);
     554                        key = usbhid_parse_scancode(kbd_dev->keys[i]);
    550555                        usb_log_debug2("Key pressed: %d (keycode: %d)\n", key,
    551                             key_codes[i]);
    552                         usb_kbd_push_ev(hid_dev, kbd_dev, KEY_PRESS,
    553                             key);
     556                            kbd_dev->keys[i]);
     557                        usb_kbd_push_ev(hid_dev, kbd_dev, KEY_PRESS, key);
    554558                        if (!usb_kbd_is_lock(key)) {
    555559                                usb_kbd_repeat_start(kbd_dev, key);
     
    560564        }
    561565       
    562         memcpy(kbd_dev->keys, key_codes, count);
    563 
    564         usb_log_debug("New stored keycodes: %s\n",
    565             usb_debug_str_buffer(kbd_dev->keys, kbd_dev->key_count, 0));
     566//      usb_log_debug("Old keys: ");
     567//      for (i = 0; i < kbd_dev->key_count; ++i) {
     568//              usb_log_debug("%d ", kbd_dev->keys_old[i]);
     569//      }
     570//      usb_log_debug("\n");
     571       
     572       
     573//      usb_log_debug("New keys: ");
     574//      for (i = 0; i < kbd_dev->key_count; ++i) {
     575//              usb_log_debug("%d ", kbd_dev->keys[i]);
     576//      }
     577//      usb_log_debug("\n");
     578       
     579        memcpy(kbd_dev->keys_old, kbd_dev->keys, kbd_dev->key_count * 4);
     580       
     581        usb_log_debug2("New stored keys: ");
     582        for (i = 0; i < kbd_dev->key_count; ++i) {
     583                usb_log_debug2("%d ", kbd_dev->keys_old[i]);
     584        }
     585        usb_log_debug2("\n");
    566586}
    567587
     
    585605 * @sa usb_kbd_check_key_changes(), usb_kbd_check_modifier_changes()
    586606 */
    587 static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
    588     uint8_t report_id, void *arg)
    589 {
    590         if (arg == NULL) {
    591                 usb_log_warning("Missing argument in callback "
    592                     "usbhid_process_keycodes().\n");
    593                 return;
    594         }
    595        
    596         usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;
    597        
    598         if (hid_dev->data == NULL) {
    599                 usb_log_warning("Missing KBD device structure in callback.\n");
    600                 return;
    601         }
    602        
    603         usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
    604 
    605         usb_log_debug("Got keys from parser (report id: %u): %s\n",
    606             report_id, usb_debug_str_buffer(key_codes, count, 0));
    607        
    608         if (count != kbd_dev->key_count) {
    609                 usb_log_warning("Number of received keycodes (%zu) differs from"
    610                     " expected (%zu).\n", count, kbd_dev->key_count);
    611                 return;
    612         }
    613        
    614         ///usb_kbd_check_modifier_changes(kbd_dev, key_codes, count);
    615         usb_kbd_check_key_changes(hid_dev, kbd_dev, key_codes, count);
    616 }
     607//static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
     608//    uint8_t report_id, void *arg)
     609//{
     610//      if (arg == NULL) {
     611//              usb_log_warning("Missing argument in callback "
     612//                  "usbhid_process_keycodes().\n");
     613//              return;
     614//      }
     615       
     616//      usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;
     617       
     618//      if (hid_dev->data == NULL) {
     619//              usb_log_warning("Missing KBD device structure in callback.\n");
     620//              return;
     621//      }
     622       
     623//      usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
     624
     625//      usb_log_debug("Got keys from parser (report id: %u): %s\n",
     626//          report_id, usb_debug_str_buffer(key_codes, count, 0));
     627       
     628//      if (count != kbd_dev->key_count) {
     629//              usb_log_warning("Number of received keycodes (%zu) differs from"
     630//                  " expected (%zu).\n", count, kbd_dev->key_count);
     631//              return;
     632//      }
     633       
     634//      ///usb_kbd_check_modifier_changes(kbd_dev, key_codes, count);
     635//      usb_kbd_check_key_changes(hid_dev, kbd_dev, key_codes, count);
     636//}
    617637
    618638/*----------------------------------------------------------------------------*/
     
    638658                                 uint8_t *buffer, size_t actual_size)
    639659{
    640         assert(hid_dev->parser != NULL);
     660        assert(hid_dev->report != NULL);
     661        assert(hid_dev != NULL);
     662        assert(hid_dev->data != NULL);
     663       
     664        usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
    641665
    642666        usb_log_debug("Calling usb_hid_parse_report() with "
     
    648672        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
    649673        //usb_hid_report_path_set_report_id(path, 0);
    650        
    651         int rc = usb_hid_parse_report(hid_dev->parser, buffer,
    652             actual_size, path,
     674
     675        uint8_t report_id;
     676        int rc = usb_hid_parse_report(hid_dev->report, buffer, actual_size,
     677            &report_id);
     678       
     679        if (rc != EOK) {
     680                usb_log_warning("Error in usb_hid_parse_report():"
     681                    "%s\n", str_error(rc));
     682        }
     683       
     684        usb_hid_report_path_set_report_id (path, report_id);
     685       
     686        // fill in the currently pressed keys
     687       
     688        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
     689            hid_dev->report, NULL, path,
    653690            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    654             &usb_kbd_parser_callbacks, hid_dev);
    655 
     691            USB_HID_REPORT_TYPE_INPUT);
     692        unsigned i = 0;
     693       
     694        while (field != NULL) {
     695                usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)\n",
     696                    field, field->value, field->usage);
     697               
     698                assert(i < kbd_dev->key_count);
     699//              if (i == kbd_dev->key_count) {
     700//                      break;
     701//              }
     702               
     703                // save the key usage
     704                /* TODO: maybe it's not good to save value, nor usage
     705                 *       as the value may be e.g. 1 for LEDs and usage may be
     706                 *       value of the LED. On the other hand, in case of normal
     707                 *       keys, the usage is more important and we must check
     708                 *       that. One possible solution: distinguish between those
     709                 *       two parts of the Report somehow.
     710                 */
     711                if (field->value != 0) {
     712                        kbd_dev->keys[i] = field->usage;
     713                }
     714                else {
     715                        kbd_dev->keys[i] = 0;
     716                }
     717                usb_log_debug2("Saved %u. key usage %d\n", i, kbd_dev->keys[i]);
     718               
     719                ++i;
     720                field = usb_hid_report_get_sibling(hid_dev->report, field, path,
     721                    USB_HID_PATH_COMPARE_END
     722                    | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     723                    USB_HID_REPORT_TYPE_INPUT);
     724        }
     725       
    656726        usb_hid_report_path_free(path);
    657727       
    658         if (rc != EOK) {
    659                 usb_log_warning("Error in usb_hid_boot_keyboard_input_report():"
    660                     "%s\n", str_error(rc));
    661         }
     728        usb_kbd_check_key_changes(hid_dev, kbd_dev);
    662729}
    663730
     
    747814       
    748815        kbd_dev->key_count = usb_hid_report_input_length(
    749             hid_dev->parser, path,
     816            hid_dev->report, path,
    750817            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
    751818        usb_hid_report_path_free(path);
     
    753820        usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count);
    754821       
    755         kbd_dev->keys = (uint8_t *)calloc(kbd_dev->key_count, sizeof(uint8_t));
     822        kbd_dev->keys = (int32_t *)calloc(kbd_dev->key_count, sizeof(int32_t));
    756823       
    757824        if (kbd_dev->keys == NULL) {
     
    761828        }
    762829       
     830        kbd_dev->keys_old =
     831                (int32_t *)calloc(kbd_dev->key_count, sizeof(int32_t));
     832       
     833        if (kbd_dev->keys_old == NULL) {
     834                usb_log_fatal("No memory!\n");
     835                free(kbd_dev->keys);
     836                free(kbd_dev);
     837                return ENOMEM;
     838        }
     839       
    763840        /*
    764841         * Output report
    765842         */
    766843        kbd_dev->output_size = 0;
    767         kbd_dev->output_buffer = usb_hid_report_output(hid_dev->parser,
    768             &kbd_dev->output_size);
    769         if (kbd_dev->output_buffer == NULL && kbd_dev->output_size != 0) {
     844        kbd_dev->output_buffer = usb_hid_report_output(hid_dev->report,
     845            &kbd_dev->output_size, 0);
     846        if (kbd_dev->output_buffer == NULL) {
    770847                usb_log_warning("Error creating output report buffer.\n");
    771848                free(kbd_dev->keys);
    772                 free(kbd_dev);
    773                 return ENOMEM;
     849                return ENOMEM;  /* TODO: other error code */
    774850        }
    775851       
     
    780856            kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
    781857       
    782         kbd_dev->led_output_size = usb_hid_report_output_size(hid_dev->parser,
     858        kbd_dev->led_output_size = usb_hid_report_output_size(hid_dev->report,
    783859            kbd_dev->led_path,
    784860            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
     
    908984        }
    909985       
    910         // free the output buffer
    911         usb_hid_report_output_free((*kbd_dev)->output_buffer);
     986        // free all buffers
     987        if ((*kbd_dev)->keys != NULL) {
     988                free((*kbd_dev)->keys);
     989        }
     990        if ((*kbd_dev)->keys_old != NULL) {
     991                free((*kbd_dev)->keys_old);
     992        }
     993        if ((*kbd_dev)->led_data != NULL) {
     994                free((*kbd_dev)->led_data);
     995        }
     996        if ((*kbd_dev)->output_buffer != NULL) {
     997                free((*kbd_dev)->output_buffer);
     998        }
     999        if ((*kbd_dev)->led_path != NULL) {
     1000                usb_hid_report_path_free((*kbd_dev)->led_path);
     1001        }
     1002        if ((*kbd_dev)->output_buffer != NULL) {
     1003                usb_hid_report_output_free((*kbd_dev)->output_buffer);
     1004        }
    9121005
    9131006        free(*kbd_dev);
     
    9291022                } else {
    9301023                        usb_kbd_free(&kbd_dev);
     1024                        hid_dev->data = NULL;
    9311025                }
    9321026        }
     
    9371031int usb_kbd_set_boot_protocol(usb_hid_dev_t *hid_dev)
    9381032{
    939         int rc = usb_hid_parse_report_descriptor(hid_dev->parser,
     1033        int rc = usb_hid_parse_report_descriptor(hid_dev->report,
    9401034            USB_KBD_BOOT_REPORT_DESCRIPTOR,
    9411035            USB_KBD_BOOT_REPORT_DESCRIPTOR_SIZE);
  • uspace/drv/usbhid/kbd/kbddev.h

    r152ec79 r9e929a0  
    6565 */
    6666typedef struct usb_kbd_t {
     67        /** Previously pressed keys (not translated to key codes). */
     68        int32_t *keys_old;
    6769        /** Currently pressed keys (not translated to key codes). */
    68         uint8_t *keys;
     70        int32_t *keys;
    6971        /** Count of stored keys (i.e. number of keys in the report). */
    7072        size_t key_count;
  • uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c

    r152ec79 r9e929a0  
    3838#include "lgtch-ultrax.h"
    3939#include "../usbhid.h"
     40#include "keymap.h"
    4041
    4142#include <usb/classes/hidparser.h>
    4243#include <usb/debug.h>
     44#include <usb/classes/hidut.h>
     45
    4346#include <errno.h>
    4447#include <str_error.h>
    4548
     49#include <ipc/kbd.h>
     50#include <io/console.h>
     51
    4652#define NAME "lgtch-ultrax"
    4753
    48 /*----------------------------------------------------------------------------*/
    49 
    50 static void usb_lgtch_process_keycodes(const uint8_t *key_codes, size_t count,
    51     uint8_t report_id, void *arg);
    52 
    53 static const usb_hid_report_in_callbacks_t usb_lgtch_parser_callbacks = {
    54         .keyboard = usb_lgtch_process_keycodes
     54typedef enum usb_lgtch_flags {
     55        USB_LGTCH_STATUS_UNINITIALIZED = 0,
     56        USB_LGTCH_STATUS_INITIALIZED = 1,
     57        USB_LGTCH_STATUS_TO_DESTROY = -1
     58} usb_lgtch_flags;
     59
     60
     61/*----------------------------------------------------------------------------*/
     62/**
     63 * Default handler for IPC methods not handled by DDF.
     64 *
     65 * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it
     66 * assumes the caller is the console and thus it stores IPC phone to it for
     67 * later use by the driver to notify about key events.
     68 *
     69 * @param fun Device function handling the call.
     70 * @param icallid Call id.
     71 * @param icall Call data.
     72 */
     73static void default_connection_handler(ddf_fun_t *fun,
     74    ipc_callid_t icallid, ipc_call_t *icall)
     75{
     76        usb_log_debug(NAME " default_connection_handler()\n");
     77       
     78        sysarg_t method = IPC_GET_IMETHOD(*icall);
     79       
     80        usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
     81       
     82        if (hid_dev == NULL || hid_dev->data == NULL) {
     83                async_answer_0(icallid, EINVAL);
     84                return;
     85        }
     86       
     87        assert(hid_dev != NULL);
     88        assert(hid_dev->data != NULL);
     89        usb_lgtch_ultrax_t *lgtch_dev = (usb_lgtch_ultrax_t *)hid_dev->data;
     90
     91        if (method == IPC_M_CONNECT_TO_ME) {
     92                int callback = IPC_GET_ARG5(*icall);
     93
     94                if (lgtch_dev->console_phone != -1) {
     95                        async_answer_0(icallid, ELIMIT);
     96                        return;
     97                }
     98
     99                lgtch_dev->console_phone = callback;
     100                usb_log_debug(NAME " Saved phone to console: %d\n", callback);
     101                async_answer_0(icallid, EOK);
     102                return;
     103        }
     104       
     105        async_answer_0(icallid, EINVAL);
     106}
     107
     108/*----------------------------------------------------------------------------*/
     109
     110static ddf_dev_ops_t lgtch_ultrax_ops = {
     111        .default_handler = default_connection_handler
    55112};
    56113
    57114/*----------------------------------------------------------------------------*/
    58115
    59 static void usb_lgtch_process_keycodes(const uint8_t *key_codes, size_t count,
    60     uint8_t report_id, void *arg)
    61 {
    62         // TODO: checks
    63        
    64         usb_log_debug(NAME " Got keys from parser (report id: %u): %s\n",
    65             report_id, usb_debug_str_buffer(key_codes, count, 0));
     116//static void usb_lgtch_process_keycodes(const uint8_t *key_codes, size_t count,
     117//    uint8_t report_id, void *arg);
     118
     119//static const usb_hid_report_in_callbacks_t usb_lgtch_parser_callbacks = {
     120//      .keyboard = usb_lgtch_process_keycodes
     121//};
     122
     123///*----------------------------------------------------------------------------*/
     124
     125//static void usb_lgtch_process_keycodes(const uint8_t *key_codes, size_t count,
     126//    uint8_t report_id, void *arg)
     127//{
     128//      // TODO: checks
     129       
     130//      usb_log_debug(NAME " Got keys from parser (report id: %u): %s\n",
     131//          report_id, usb_debug_str_buffer(key_codes, count, 0));
     132//}
     133
     134/*----------------------------------------------------------------------------*/
     135/**
     136 * Processes key events.
     137 *
     138 * @note This function was copied from AT keyboard driver and modified to suit
     139 *       USB keyboard.
     140 *
     141 * @note Lock keys are not sent to the console, as they are completely handled
     142 *       in the driver. It may, however, be required later that the driver
     143 *       sends also these keys to application (otherwise it cannot use those
     144 *       keys at all).
     145 *
     146 * @param hid_dev
     147 * @param lgtch_dev
     148 * @param type Type of the event (press / release). Recognized values:
     149 *             KEY_PRESS, KEY_RELEASE
     150 * @param key Key code of the key according to HID Usage Tables.
     151 */
     152static void usb_lgtch_push_ev(usb_hid_dev_t *hid_dev, int type,
     153    unsigned int key)
     154{
     155        assert(hid_dev != NULL);
     156        assert(hid_dev->data != NULL);
     157       
     158        usb_lgtch_ultrax_t *lgtch_dev = (usb_lgtch_ultrax_t *)hid_dev->data;
     159       
     160        console_event_t ev;
     161       
     162        ev.type = type;
     163        ev.key = key;
     164        ev.mods = 0;
     165
     166        ev.c = 0;
     167
     168        usb_log_debug2(NAME " Sending key %d to the console\n", ev.key);
     169        if (lgtch_dev->console_phone < 0) {
     170                usb_log_warning(
     171                    "Connection to console not ready, key discarded.\n");
     172                return;
     173        }
     174       
     175        async_msg_4(lgtch_dev->console_phone, KBD_EVENT, ev.type, ev.key,
     176            ev.mods, ev.c);
     177}
     178
     179/*----------------------------------------------------------------------------*/
     180
     181static void usb_lgtch_free(usb_lgtch_ultrax_t **lgtch_dev)
     182{
     183        if (lgtch_dev == NULL || *lgtch_dev == NULL) {
     184                return;
     185        }
     186       
     187        // hangup phone to the console
     188        async_hangup((*lgtch_dev)->console_phone);
     189       
     190//      if ((*lgtch_dev)->repeat_mtx != NULL) {
     191//              /* TODO: replace by some check and wait */
     192//              assert(!fibril_mutex_is_locked((*lgtch_dev)->repeat_mtx));
     193//              free((*lgtch_dev)->repeat_mtx);
     194//      }
     195       
     196        // free all buffers
     197        if ((*lgtch_dev)->keys != NULL) {
     198                free((*lgtch_dev)->keys);
     199        }
     200        if ((*lgtch_dev)->keys_old != NULL) {
     201                free((*lgtch_dev)->keys_old);
     202        }
     203
     204        free(*lgtch_dev);
     205        *lgtch_dev = NULL;
     206}
     207
     208/*----------------------------------------------------------------------------*/
     209
     210int usb_lgtch_init(struct usb_hid_dev *hid_dev)
     211{
     212        if (hid_dev == NULL || hid_dev->usb_dev == NULL) {
     213                return EINVAL; /*! @todo Other return code? */
     214        }
     215       
     216        usb_log_debug(NAME " Initializing HID/lgtch_ultrax structure...\n");
     217       
     218        usb_lgtch_ultrax_t *lgtch_dev = (usb_lgtch_ultrax_t *)malloc(
     219            sizeof(usb_lgtch_ultrax_t));
     220        if (lgtch_dev == NULL) {
     221                return ENOMEM;
     222        }
     223       
     224        lgtch_dev->console_phone = -1;
     225       
     226        usb_hid_report_path_t *path = usb_hid_report_path();
     227        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0);
     228       
     229        usb_hid_report_path_set_report_id(path, 1);
     230       
     231        lgtch_dev->key_count = usb_hid_report_input_length(
     232            hid_dev->report, path,
     233            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
     234        usb_hid_report_path_free(path);
     235       
     236        usb_log_debug(NAME " Size of the input report: %zu\n",
     237            lgtch_dev->key_count);
     238       
     239        lgtch_dev->keys = (int32_t *)calloc(lgtch_dev->key_count,
     240            sizeof(int32_t));
     241       
     242        if (lgtch_dev->keys == NULL) {
     243                usb_log_fatal("No memory!\n");
     244                free(lgtch_dev);
     245                return ENOMEM;
     246        }
     247       
     248        lgtch_dev->keys_old =
     249                (int32_t *)calloc(lgtch_dev->key_count, sizeof(int32_t));
     250       
     251        if (lgtch_dev->keys_old == NULL) {
     252                usb_log_fatal("No memory!\n");
     253                free(lgtch_dev->keys);
     254                free(lgtch_dev);
     255                return ENOMEM;
     256        }
     257       
     258        /*! @todo Autorepeat */
     259       
     260        // save the KBD device structure into the HID device structure
     261        hid_dev->data = lgtch_dev;
     262       
     263        /* Create the function exposed under /dev/devices. */
     264        ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
     265            NAME);
     266        if (fun == NULL) {
     267                usb_log_error("Could not create DDF function node.\n");
     268                return ENOMEM;
     269        }
     270       
     271        lgtch_dev->initialized = USB_LGTCH_STATUS_INITIALIZED;
     272        usb_log_debug(NAME " HID/lgtch_ultrax device structure initialized.\n");
     273       
     274        /*
     275         * Store the initialized HID device and HID ops
     276         * to the DDF function.
     277         */
     278        fun->ops = &lgtch_ultrax_ops;
     279        fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
     280       
     281        /*
     282         * 1) subdriver vytvori vlastnu ddf_fun, vlastne ddf_dev_ops, ktore da
     283         *    do nej.
     284         * 2) do tych ops do .interfaces[DEV_IFACE_USBHID (asi)] priradi
     285         *    vyplnenu strukturu usbhid_iface_t.
     286         * 3) klientska aplikacia - musi si rucne vytvorit telefon
     287         *    (devman_device_connect() - cesta k zariadeniu (/hw/pci0/...) az
     288         *    k tej fcii.
     289         *    pouzit usb/classes/hid/iface.h - prvy int je telefon
     290         */
     291
     292        int rc = ddf_fun_bind(fun);
     293        if (rc != EOK) {
     294                usb_log_error("Could not bind DDF function: %s.\n",
     295                    str_error(rc));
     296                // TODO: Can / should I destroy the DDF function?
     297                ddf_fun_destroy(fun);
     298                usb_lgtch_free(&lgtch_dev);
     299                return rc;
     300        }
     301       
     302        rc = ddf_fun_add_to_class(fun, "keyboard");
     303        if (rc != EOK) {
     304                usb_log_error(
     305                    "Could not add DDF function to class 'keyboard': %s.\n",
     306                    str_error(rc));
     307                // TODO: Can / should I destroy the DDF function?
     308                ddf_fun_destroy(fun);
     309                usb_lgtch_free(&lgtch_dev);
     310                return rc;
     311        }
     312       
     313        usb_log_debug(NAME " HID/lgtch_ultrax structure initialized.\n");
     314       
     315        return EOK;
     316}
     317
     318/*----------------------------------------------------------------------------*/
     319
     320void usb_lgtch_deinit(struct usb_hid_dev *hid_dev)
     321{
     322        if (hid_dev == NULL) {
     323                return;
     324        }
     325       
     326        if (hid_dev->data != NULL) {
     327                usb_lgtch_ultrax_t *lgtch_dev =
     328                    (usb_lgtch_ultrax_t *)hid_dev->data;
     329//              if (usb_kbd_is_initialized(kbd_dev)) {
     330//                      usb_kbd_mark_unusable(kbd_dev);
     331//              } else {
     332                        usb_lgtch_free(&lgtch_dev);
     333                        hid_dev->data = NULL;
     334//              }
     335        }
    66336}
    67337
     
    81351        usb_hid_report_path_t *path = usb_hid_report_path();
    82352        usb_hid_report_path_append_item(path, 0xc, 0);
    83         usb_hid_report_path_set_report_id(path, 1);
    84        
    85         int rc = usb_hid_parse_report(hid_dev->parser, buffer,
    86             buffer_size, path,
    87             USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    88             &usb_lgtch_parser_callbacks, hid_dev);
     353
     354        uint8_t report_id;
     355       
     356        int rc = usb_hid_parse_report(hid_dev->report, buffer, buffer_size,
     357            &report_id);
     358        usb_hid_report_path_set_report_id(path, report_id);
     359
     360        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
     361            hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END
     362            | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     363            USB_HID_REPORT_TYPE_INPUT);
     364       
     365        unsigned int key;
     366       
     367        /*! @todo Is this iterating OK if done multiple times?
     368         *  @todo The parsing is not OK
     369         */
     370        while (field != NULL) {
     371                usb_log_debug(NAME " KEY VALUE(%X) USAGE(%X)\n", field->value,
     372                    field->usage);
     373               
     374                key = usb_lgtch_map_usage(field->usage);
     375                usb_lgtch_push_ev(hid_dev, KEY_PRESS, key);
     376               
     377                field = usb_hid_report_get_sibling(
     378                    hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
     379                    | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     380                    USB_HID_REPORT_TYPE_INPUT);
     381        }       
    89382
    90383        usb_hid_report_path_free(path);
    91384       
    92385        if (rc != EOK) {
    93                 usb_log_warning("Error in usb_hid_boot_keyboard_input_report():"
     386                usb_log_warning(NAME "Error in usb_hid_boot_keyboard_input_report():"
    94387                    "%s\n", str_error(rc));
    95388        }
  • uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.h

    r152ec79 r9e929a0  
    4040
    4141struct usb_hid_dev;
    42 //struct usb_hid_subdriver_mapping;
     42
     43/*----------------------------------------------------------------------------*/
     44/**
     45 * USB/HID keyboard device type.
     46 *
     47 * Holds a reference to generic USB/HID device structure and keyboard-specific
     48 * data, such as currently pressed keys, modifiers and lock keys.
     49 *
     50 * Also holds a IPC phone to the console (since there is now no other way to
     51 * communicate with it).
     52 *
     53 * @note Storing active lock keys in this structure results in their setting
     54 *       being device-specific.
     55 */
     56typedef struct usb_lgtch_ultrax_t {
     57        /** Previously pressed keys (not translated to key codes). */
     58        int32_t *keys_old;
     59        /** Currently pressed keys (not translated to key codes). */
     60        int32_t *keys;
     61        /** Count of stored keys (i.e. number of keys in the report). */
     62        size_t key_count;
     63       
     64        /** IPC phone to the console device (for sending key events). */
     65        int console_phone;
     66
     67        /** Information for auto-repeat of keys. */
     68//      usb_kbd_repeat_t repeat;
     69       
     70        /** Mutex for accessing the information about auto-repeat. */
     71//      fibril_mutex_t *repeat_mtx;
     72
     73        /** State of the structure (for checking before use).
     74         *
     75         * 0 - not initialized
     76         * 1 - initialized
     77         * -1 - ready for destroying
     78         */
     79        int initialized;
     80} usb_lgtch_ultrax_t;
    4381
    4482/*----------------------------------------------------------------------------*/
    4583
    46 //extern struct usb_hid_subdriver_mapping usb_lgtch_mapping;
     84int usb_lgtch_init(struct usb_hid_dev *hid_dev);
    4785
    48 /*----------------------------------------------------------------------------*/
    49 
    50 //int usb_lgtch_init(struct usb_hid_dev *hid_dev);
     86void usb_lgtch_deinit(struct usb_hid_dev *hid_dev);
    5187
    5288bool usb_lgtch_polling_callback(struct usb_hid_dev *hid_dev, uint8_t *buffer,
  • uspace/drv/usbhid/main.c

    r152ec79 r9e929a0  
    114114        hid_fun->ops = &hid_dev->ops;
    115115        hid_fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
     116       
     117        /*
     118         * 1) subdriver vytvori vlastnu ddf_fun, vlastne ddf_dev_ops, ktore da
     119         *    do nej.
     120         * 2) do tych ops do .interfaces[DEV_IFACE_USBHID (asi)] priradi
     121         *    vyplnenu strukturu usbhid_iface_t.
     122         * 3) klientska aplikacia - musi si rucne vytvorit telefon
     123         *    (devman_device_connect() - cesta k zariadeniu (/hw/pci0/...) az
     124         *    k tej fcii.
     125         *    pouzit usb/classes/hid/iface.h - prvy int je telefon
     126         */
    116127
    117128        rc = ddf_fun_bind(hid_fun);
  • uspace/drv/usbhid/mouse/mousedev.c

    r152ec79 r9e929a0  
    296296int usb_mouse_set_boot_protocol(usb_hid_dev_t *hid_dev)
    297297{
    298         int rc = usb_hid_parse_report_descriptor(hid_dev->parser,
     298        int rc = usb_hid_parse_report_descriptor(hid_dev->report,
    299299            USB_MOUSE_BOOT_REPORT_DESCRIPTOR,
    300300            USB_MOUSE_BOOT_REPORT_DESCRIPTOR_SIZE);
  • uspace/drv/usbhid/subdrivers.c

    r152ec79 r9e929a0  
    5555                USB_HID_PATH_COMPARE_END
    5656                | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    57                 0,
    58                 0,
     57                -1,
     58                -1,
    5959                {
    6060                        .init = usb_kbd_init,
     
    7373                0xc30e,
    7474                {
    75                         .init = NULL,
    76                         .deinit = NULL,
     75                        .init = usb_lgtch_init,
     76                        .deinit = usb_lgtch_deinit,
    7777                        .poll = usb_lgtch_polling_callback,
    7878                        .poll_end = NULL
    7979                }
    8080        },
    81         {NULL, -1, 0, 0, 0, {NULL, NULL, NULL, NULL}}
     81        {NULL, -1, 0, -1, -1, {NULL, NULL, NULL, NULL}}
    8282};
    8383
  • uspace/drv/usbhid/subdrivers.h

    r152ec79 r9e929a0  
    5656        int report_id;
    5757        int compare;
    58         uint16_t vendor_id;
    59         uint16_t product_id;
     58        int vendor_id;
     59        int product_id;
    6060        usb_hid_subdriver_t subdriver;
    6161} usb_hid_subdriver_mapping_t;
  • uspace/drv/usbhid/usbhid.c

    r152ec79 r9e929a0  
    158158    const usb_hid_subdriver_mapping_t *mapping)
    159159{
    160         return false;
     160        assert(hid_dev != NULL);
     161        assert(hid_dev->usb_dev != NULL);
     162       
     163        return (hid_dev->usb_dev->descriptors.device.vendor_id
     164            == mapping->vendor_id
     165            && hid_dev->usb_dev->descriptors.device.product_id
     166            == mapping->product_id);
    161167}
    162168
     
    192198        }
    193199       
    194         assert(hid_dev->parser != NULL);
     200        assert(hid_dev->report != NULL);
    195201       
    196202        usb_log_debug("Compare flags: %d\n", mapping->compare);
    197         size_t size = usb_hid_report_input_length(hid_dev->parser, usage_path,
     203        size_t size = usb_hid_report_input_length(hid_dev->report, usage_path,
    198204            mapping->compare);
    199205        usb_log_debug("Size of the input report: %zuB\n", size);
     
    251257        while (count < USB_HID_MAX_SUBDRIVERS &&
    252258            (mapping->usage_path != NULL
    253             || mapping->vendor_id != 0 || mapping->product_id != 0)) {
     259            || mapping->vendor_id >= 0 || mapping->product_id >= 0)) {
    254260                // check the vendor & product ID
    255                 if (mapping->vendor_id != 0 && mapping->product_id == 0) {
    256                         usb_log_warning("Missing Product ID for Vendor ID %u\n",
     261                if (mapping->vendor_id >= 0 && mapping->product_id < 0) {
     262                        usb_log_warning("Missing Product ID for Vendor ID %d\n",
    257263                            mapping->vendor_id);
    258264                        return EINVAL;
    259265                }
    260                 if (mapping->product_id != 0 && mapping->vendor_id == 0) {
    261                         usb_log_warning("Missing Vendor ID for Product ID %u\n",
     266                if (mapping->product_id >= 0 && mapping->vendor_id < 0) {
     267                        usb_log_warning("Missing Vendor ID for Product ID %d\n",
    262268                            mapping->product_id);
    263269                        return EINVAL;
     
    267273                matched = false;
    268274               
    269                 if (mapping->vendor_id != 0) {
    270                         assert(mapping->product_id != 0);
     275                if (mapping->vendor_id >= 0) {
     276                        assert(mapping->product_id >= 0);
    271277                        usb_log_debug("Comparing device against vendor ID %u"
    272278                            " and product ID %u.\n", mapping->vendor_id,
     
    341347        }
    342348       
    343         hid_dev->parser = (usb_hid_report_parser_t *)(malloc(sizeof(
    344             usb_hid_report_parser_t)));
    345         if (hid_dev->parser == NULL) {
     349        hid_dev->report = (usb_hid_report_t *)(malloc(sizeof(
     350            usb_hid_report_t)));
     351        if (hid_dev->report == NULL) {
    346352                usb_log_fatal("No memory!\n");
    347353                free(hid_dev);
     
    382388                return rc;
    383389        }
    384        
    385         /* Initialize the report parser. */
    386         rc = usb_hid_parser_init(hid_dev->parser);
    387         if (rc != EOK) {
    388                 usb_log_error("Failed to initialize report parser.\n");
    389                 //usb_hid_free(&hid_dev);
    390                 return rc;
    391         }
    392        
     390               
    393391        /* Get the report descriptor and parse it. */
    394392        rc = usb_hid_process_report_descriptor(hid_dev->usb_dev,
    395             hid_dev->parser);
     393            hid_dev->report);
    396394       
    397395        bool fallback = false;
     
    591589
    592590        // destroy the parser
    593         if ((*hid_dev)->parser != NULL) {
    594                 usb_hid_free_report_parser((*hid_dev)->parser);
     591        if ((*hid_dev)->report != NULL) {
     592                usb_hid_free_report((*hid_dev)->report);
    595593        }
    596594
  • uspace/drv/usbhid/usbhid.h

    r152ec79 r9e929a0  
    9191       
    9292        /** HID Report parser. */
    93         usb_hid_report_parser_t *parser;
     93        usb_hid_report_t *report;
    9494       
    9595        /** Arbitrary data (e.g. a special structure for handling keyboard). */
  • uspace/drv/usbkbd/kbddev.c

    r152ec79 r9e929a0  
    128128        0x15, 0x00,  //   Logical Minimum (0),
    129129        0x25, 0x01,  //   Logical Maximum (1),
     130        //0x85, 0x00,  //   Report ID,
     131        //0xA4,      //   Push
    130132        0x81, 0x02,  //   Input (Data, Variable, Absolute),   ; Modifier byte
    131         0x95, 0x01,  //   Report Count (1),
    132         0x75, 0x08,  //   Report Size (8),
     133        //0xB4,      //   Pop
     134        0x75, 0x08,  //   Report Size (1),
     135        0x95, 0x01,  //   Report Count (8),       
    133136        0x81, 0x01,  //   Input (Constant),                   ; Reserved byte
    134137        0x95, 0x05,  //   Report Count (5),
     
    268271                return;
    269272        }
    270        
     273
    271274        unsigned i = 0;
    272275       
     
    290293       
    291294        usb_log_debug("Creating output report.\n");
    292        
    293         int rc = usb_hid_report_output_translate(kbd_dev->parser,
    294             kbd_dev->led_path,
    295             USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    296             kbd_dev->output_buffer,
    297             kbd_dev->output_size, kbd_dev->led_data, kbd_dev->led_output_size);
     295
     296        usb_hid_report_output_set_data(kbd_dev->parser, kbd_dev->led_path,
     297                                       USB_HID_PATH_COMPARE_END , kbd_dev->led_data,
     298                                       kbd_dev->led_output_size);
     299        int rc = usb_hid_report_output_translate(kbd_dev->parser, 0,
     300            kbd_dev->output_buffer, kbd_dev->output_size);
    298301       
    299302        if (rc != EOK) {
     
    563566        assert(kbd_dev != NULL);
    564567
    565         usb_log_debug("Got keys from parser (report id: %u): %s\n",
    566             report_id, usb_debug_str_buffer(key_codes, count, 0));
     568        usb_log_debug("Got keys from parser (report id: %d): %s\n", report_id,
     569            usb_debug_str_buffer(key_codes, count, 0));
    567570       
    568571        if (count != kbd_dev->key_count) {
     
    614617        usb_hid_report_path_t *path = usb_hid_report_path();
    615618        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
    616         usb_hid_report_path_set_report_id(path, 0);
    617        
    618         int rc = usb_hid_parse_report(kbd_dev->parser, buffer,
    619             actual_size, path,
    620             USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    621             callbacks, kbd_dev);
     619
     620        uint8_t report_id;
     621        int rc = usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, &report_id);
     622        usb_hid_descriptor_print (kbd_dev->parser);
    622623
    623624        usb_hid_report_path_free (path);
     
    663664        memset(kbd_dev, 0, sizeof(usb_kbd_t));
    664665       
    665         kbd_dev->parser = (usb_hid_report_parser_t *)(malloc(sizeof(
    666             usb_hid_report_parser_t)));
     666        kbd_dev->parser = (usb_hid_report_t *)(malloc(sizeof(
     667            usb_hid_report_t)));
    667668        if (kbd_dev->parser == NULL) {
    668669                usb_log_fatal("No memory!\n");
     
    732733       
    733734        /* Initialize the report parser. */
    734         rc = usb_hid_parser_init(kbd_dev->parser);
    735         if (rc != EOK) {
    736                 usb_log_error("Failed to initialize report parser.\n");
    737                 return rc;
    738         }
     735        //rc = usb_hid_parser_init(kbd_dev->parser);
     736        //if (rc != EOK) {
     737        //      usb_log_error("Failed to initialize report parser.\n");
     738        //      return rc;
     739        //}
    739740       
    740741        /* Get the report descriptor and parse it. */
     
    771772       
    772773        kbd_dev->key_count = usb_hid_report_input_length(
    773             kbd_dev->parser, path,
    774             USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
     774            kbd_dev->parser, path, USB_HID_PATH_COMPARE_END);
    775775        usb_hid_report_path_free (path);
    776776       
     
    789789        kbd_dev->output_size = 0;
    790790        kbd_dev->output_buffer = usb_hid_report_output(kbd_dev->parser,
    791             &kbd_dev->output_size);
    792         if (kbd_dev->output_buffer == NULL && kbd_dev->output_size != 0) {
     791            &kbd_dev->output_size, 0x00);
     792        if (kbd_dev->output_buffer == NULL) {
    793793                usb_log_warning("Error creating output report buffer.\n");
    794794                free(kbd_dev->keys);
     
    801801        usb_hid_report_path_append_item(
    802802            kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
     803        usb_hid_report_path_set_report_id(kbd_dev->led_path, 0x00);
    803804       
    804805        kbd_dev->led_output_size = usb_hid_report_output_size(kbd_dev->parser,
     
    849850         * Set Idle rate
    850851         */
    851         usb_kbd_set_led(kbd_dev);
     852        usb_kbd_set_led(kbd_dev);       
    852853       
    853854        usbhid_req_set_idle(&kbd_dev->usb_dev->ctrl_pipe,
     
    934935        // destroy the parser
    935936        if ((*kbd_dev)->parser != NULL) {
    936                 usb_hid_free_report_parser((*kbd_dev)->parser);
     937                usb_hid_free_report((*kbd_dev)->parser);
    937938        }
    938939       
  • uspace/drv/usbkbd/kbddev.h

    r152ec79 r9e929a0  
    106106
    107107        /** HID Report parser. */
    108         usb_hid_report_parser_t *parser;
     108        usb_hid_report_t *parser;
    109109       
    110110        /** State of the structure (for checking before use).
Note: See TracChangeset for help on using the changeset viewer.