Ignore:
Timestamp:
2011-05-11T16:49:28Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
19387b61
Parents:
e1dbcbc (diff), 9212f8a (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 development/ changes

Location:
uspace/lib/usbhid/include/usb/classes
Files:
3 added
9 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhid/include/usb/classes/hid.h

    re1dbcbc ra81a1d09  
    2727 */
    2828
    29 /** @addtogroup usbvirtkbd
     29/** @addtogroup libusb
    3030 * @{
    3131 */
    3232/** @file
    33  * @brief USB keyboard configuration.
     33 * @brief USB HID device related types.
    3434 */
    35 #ifndef VUK_KBDCONFIG_H_
    36 #define VUK_KBDCONFIG_H_
     35#ifndef LIBUSB_HID_H_
     36#define LIBUSB_HID_H_
    3737
     38#include <usb/usb.h>
     39#include <usb/classes/hidparser.h>
    3840#include <usb/descriptor.h>
    39 #include "report.h"
    40 #include "descriptor.h"
    4141
    42 extern usb_standard_device_descriptor_t std_device_descriptor;
     42/** USB/HID device requests. */
     43typedef enum {
     44        USB_HIDREQ_GET_REPORT = 1,
     45        USB_HIDREQ_GET_IDLE = 2,
     46        USB_HIDREQ_GET_PROTOCOL = 3,
     47        /* Values 4 to 8 are reserved. */
     48        USB_HIDREQ_SET_REPORT = 9,
     49        USB_HIDREQ_SET_IDLE = 10,
     50        USB_HIDREQ_SET_PROTOCOL = 11
     51} usb_hid_request_t;
    4352
    44 extern usb_standard_configuration_descriptor_t std_configuration_descriptor;
     53typedef enum {
     54        USB_HID_PROTOCOL_BOOT = 0,
     55        USB_HID_PROTOCOL_REPORT = 1
     56} usb_hid_protocol_t;
    4557
    46 extern usb_standard_interface_descriptor_t std_interface_descriptor;
     58/** USB/HID subclass constants. */
     59typedef enum {
     60        USB_HID_SUBCLASS_NONE = 0,
     61        USB_HID_SUBCLASS_BOOT = 1
     62} usb_hid_subclass_t;
    4763
    48 extern usb_standard_endpoint_descriptor_t endpoint_descriptor;
    49 
    50 
    51 extern hid_descriptor_t hid_descriptor;
    52 
    53 extern report_descriptor_data_t report_descriptor;
    54 extern size_t report_descriptor_size;
     64/** USB/HID interface protocols. */
     65typedef enum {
     66        USB_HID_PROTOCOL_NONE = 0,
     67        USB_HID_PROTOCOL_KEYBOARD = 1,
     68        USB_HID_PROTOCOL_MOUSE = 2
     69} usb_hid_iface_protocol_t;
    5570
    5671
  • uspace/lib/usbhid/include/usb/classes/hid_report_items.h

    re1dbcbc ra81a1d09  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Matej Klonfar
    33 * All rights reserved.
    44 *
     
    3737
    3838#include <stdint.h>
     39
     40/**
     41 * Item prefix
     42 */
     43#define USB_HID_ITEM_SIZE(data)         ((uint8_t)(data & 0x3))
     44#define USB_HID_ITEM_TAG(data)          ((uint8_t)((data & 0xF0) >> 4))
     45#define USB_HID_ITEM_TAG_CLASS(data)    ((uint8_t)((data & 0xC) >> 2))
     46#define USB_HID_ITEM_IS_LONG(data)      (data == 0xFE)
     47
     48
     49/**
     50 * Input/Output/Feature Item flags
     51 */
     52/** Constant (1) / Variable (0) */
     53#define USB_HID_ITEM_FLAG_CONSTANT(flags)       ((flags & 0x1) == 0x1)
     54/** Variable (1) / Array (0) */
     55#define USB_HID_ITEM_FLAG_VARIABLE(flags)       ((flags & 0x2) == 0x2)
     56/** Absolute / Relative*/
     57#define USB_HID_ITEM_FLAG_RELATIVE(flags)       ((flags & 0x4) == 0x4)
     58/** Wrap / No Wrap */
     59#define USB_HID_ITEM_FLAG_WRAP(flags)           ((flags & 0x8) == 0x8)
     60#define USB_HID_ITEM_FLAG_LINEAR(flags)         ((flags & 0x10) == 0x10)
     61#define USB_HID_ITEM_FLAG_PREFERRED(flags)      ((flags & 0x20) == 0x20)
     62#define USB_HID_ITEM_FLAG_POSITION(flags)       ((flags & 0x40) == 0x40)
     63#define USB_HID_ITEM_FLAG_VOLATILE(flags)       ((flags & 0x80) == 0x80)
     64#define USB_HID_ITEM_FLAG_BUFFERED(flags)       ((flags & 0x100) == 0x100)
    3965
    4066/* MAIN ITEMS */
  • uspace/lib/usbhid/include/usb/classes/hidtypes.h

    re1dbcbc ra81a1d09  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Matej Klonfar
    33 * All rights reserved.
    44 *
     
    3333 * USB HID report descriptor and report data parser
    3434 */
    35 #ifndef LIBUSB_HIDPARSER_H_
    36 #define LIBUSB_HIDPARSER_H_
     35#ifndef LIBUSB_HIDTYPES_H_
     36#define LIBUSB_HIDTYPES_H_
    3737
    3838#include <stdint.h>
    3939#include <adt/list.h>
    40 #include <usb/classes/hid_report_items.h>
    41 
    42 /**
    43  * Item prefix
    44  */
    45 #define USB_HID_ITEM_SIZE(data)         ((uint8_t)(data & 0x3))
    46 #define USB_HID_ITEM_TAG(data)          ((uint8_t)((data & 0xF0) >> 4))
    47 #define USB_HID_ITEM_TAG_CLASS(data)    ((uint8_t)((data & 0xC) >> 2))
    48 #define USB_HID_ITEM_IS_LONG(data)      (data == 0xFE)
    49 
    50 
    51 /**
    52  * Input/Output/Feature Item flags
    53  */
    54 /** Constant (1) / Variable (0) */
    55 #define USB_HID_ITEM_FLAG_CONSTANT(flags)       ((flags & 0x1) == 0x1)
    56 /** Variable (1) / Array (0) */
    57 #define USB_HID_ITEM_FLAG_VARIABLE(flags)       ((flags & 0x2) == 0x2)
    58 /** Absolute / Relative*/
    59 #define USB_HID_ITEM_FLAG_RELATIVE(flags)       ((flags & 0x4) == 0x4)
    60 /** Wrap / No Wrap */
    61 #define USB_HID_ITEM_FLAG_WRAP(flags)           ((flags & 0x8) == 0x8)
    62 #define USB_HID_ITEM_FLAG_LINEAR(flags)         ((flags & 0x10) == 0x10)
    63 #define USB_HID_ITEM_FLAG_PREFERRED(flags)      ((flags & 0x20) == 0x20)
    64 #define USB_HID_ITEM_FLAG_POSITION(flags)       ((flags & 0x40) == 0x40)
    65 #define USB_HID_ITEM_FLAG_VOLATILE(flags)       ((flags & 0x80) == 0x80)
    66 #define USB_HID_ITEM_FLAG_BUFFERED(flags)       ((flags & 0x100) == 0x100)
    67 
    68 
    69 /**
    70  * Description of path of usage pages and usages in report descriptor
    71  */
    72 #define USB_HID_PATH_COMPARE_STRICT                             0
    73 #define USB_HID_PATH_COMPARE_END                                1
    74 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY    4
    75 #define USB_HID_PATH_COMPARE_COLLECTION_ONLY    2 /* porovnava jenom cestu z Kolekci */
    76 
    7740
    7841#define USB_HID_MAX_USAGES      20
     42
     43#define USB_HID_UINT32_TO_INT32(x, size)        ((((x) & (1 << ((size) - 1))) != 0) ? -(~(x - 1) & ((1 << size) - 1)) : (x)) //(-(~((x) - 1)))
     44#define USB_HID_INT32_TO_UINT32(x, size)        (((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
     45
    7946
    8047typedef enum {
     
    8350        USB_HID_REPORT_TYPE_FEATURE = 3
    8451} usb_hid_report_type_t;
    85 
    86 /** Collection usage path structure */
    87 typedef struct {
    88         /** */
    89         uint32_t usage_page;
    90         /** */ 
    91         uint32_t usage;
    92 
    93         uint8_t flags;
    94         /** */
    95         link_t link;
    96 } usb_hid_report_usage_path_t;
    97 
    98 /** */
    99 typedef struct {
    100         /** */ 
    101         int depth;     
    102         uint8_t report_id;
    103        
    104         /** */ 
    105         link_t link; /* list */
    106 
    107         link_t head; /* head of list of usage paths */
    108 
    109 } usb_hid_report_path_t;
    11052
    11153
     
    223165        /** */ 
    224166        link_t link;
     167
     168        int in_delimiter;
    225169} usb_hid_report_item_t;
    226170
     
    261205};
    262206
    263 /*
    264  * Descriptor parser functions
    265  */
    266 
    267 /** */
    268 int usb_hid_parse_report_descriptor(usb_hid_report_t *report,
    269     const uint8_t *data, size_t size);
    270 
    271 /** */
    272 void usb_hid_free_report(usb_hid_report_t *report);
    273 
    274 /** */
    275 void usb_hid_descriptor_print(usb_hid_report_t *report);
    276 
    277 
    278 /*
    279  * Input report parser functions
    280  */
    281 /** */
    282 int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, size_t size, uint8_t *report_id);
    283 
    284 /** */
    285 size_t usb_hid_report_input_length(const usb_hid_report_t *report,
    286         usb_hid_report_path_t *path, int flags);
    287 
    288 
    289 
    290 /*
    291  * usage path functions
    292  */
    293 /** */
    294 usb_hid_report_path_t *usb_hid_report_path(void);
    295 
    296 /** */
    297 void usb_hid_report_path_free(usb_hid_report_path_t *path);
    298 
    299 /** */
    300 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, uint8_t report_id);
    301 
    302 /** */
    303 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, int32_t usage_page, int32_t usage);
    304 
    305 /** */
    306 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path);
    307 
    308 /** */
    309 void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path);
    310 
    311 /** */
    312 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, int32_t tag, int32_t data);
    313 
    314 /** */
    315 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, usb_hid_report_path_t *path, int flags);
    316 
    317 /** */
    318 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path);
    319 
    320 usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report, usb_hid_report_field_t *field, usb_hid_report_path_t *path, int flags, usb_hid_report_type_t type);
    321 
    322 uint8_t usb_hid_report_get_report_id(usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type);
    323 
    324 
    325 /*
    326  * Output report parser functions
    327  */
    328 /** Allocates output report buffer*/
    329 uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, uint8_t report_id);
    330 
    331 /** Frees output report buffer*/
    332 void usb_hid_report_output_free(uint8_t *output);
    333 
    334 /** Returns size of output for given usage path */
    335 size_t usb_hid_report_output_size(usb_hid_report_t *report,
    336                                   usb_hid_report_path_t *path, int flags);
    337 
    338 /** Sets data in report structure */
    339 int usb_hid_report_output_set_data(usb_hid_report_t *report,
    340                                    usb_hid_report_path_t *path, int flags,
    341                                   int *data, size_t data_size);
    342 
    343 /** Makes the output report buffer by translated given data */
    344 int usb_hid_report_output_translate(usb_hid_report_t *report, uint8_t report_id, uint8_t *buffer, size_t size);
    345207#endif
    346208/**
  • uspace/lib/usbhid/include/usb/classes/hidut.h

    re1dbcbc ra81a1d09  
    5959        USB_HIDUT_USAGE_GENERIC_DESKTOP_GAMEPAD = 5,
    6060        USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD = 6,
    61         USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYPAD = 7
     61        USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYPAD = 7,
     62        USB_HIDUT_USAGE_GENERIC_DESKTOP_X = 0x30,
     63        USB_HIDUT_USAGE_GENERIC_DESKTOP_Y = 0x31,
     64        USB_HIDUT_USAGE_GENERIC_DESKTOP_WHEEL = 0x38
    6265        /* USB_HIDUT_USAGE_GENERIC_DESKTOP_ = , */
    6366       
Note: See TracChangeset for help on using the changeset viewer.