Changeset a822cd8 in mainline for uspace/lib/usb
- Timestamp:
- 2010-12-12T14:16:57Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f3158c, c9113d2
- Parents:
- a59cdd2 (diff), 0c05496 (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. - Location:
- uspace/lib/usb
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/classes/hid.h
ra59cdd2 ra822cd8 36 36 #define LIBUSB_HID_H_ 37 37 38 #include <usb/usb.h> 39 #include <driver.h> 40 #include <usb/classes/hidparser.h> 41 38 42 /** USB/HID device requests. */ 39 43 typedef enum { … … 54 58 } usb_hid_protocol_t; 55 59 60 /** Part of standard USB HID descriptor specifying one class descriptor. 61 * 62 * (See HID Specification, p.22) 63 */ 64 typedef struct { 65 /** Type of class descriptor (Report or Physical). */ 66 uint8_t class_descriptor_type; 67 /** Length of class descriptor. */ 68 uint16_t class_descriptor_length; 69 } __attribute__ ((packed)) usb_standard_hid_descriptor_class_item_t; 70 71 /** Standard USB HID descriptor. 72 * 73 * (See HID Specification, p.22) 74 * 75 * It is actually only the "header" of the descriptor, as it may have arbitrary 76 * length if more than one class descritor is provided. 77 */ 78 typedef struct { 79 /** Size of this descriptor in bytes. */ 80 uint8_t length; 81 /** Descriptor type (USB_DESCTYPE_HID). */ 82 uint8_t descriptor_type; 83 /** HID Class Specification release. */ 84 uint16_t spec_release; 85 /** Country code of localized hardware. */ 86 uint8_t country_code; 87 /** Total number of class (i.e. Report and Physical) descriptors. */ 88 uint8_t class_count; 89 /** First mandatory class descriptor info. */ 90 usb_standard_hid_descriptor_class_item_t class_descriptor; 91 } __attribute__ ((packed)) usb_standard_hid_descriptor_t; 92 93 94 /** 95 * @brief USB/HID keyboard device type. 96 * 97 * Quite dummy right now. 98 */ 99 typedef struct { 100 device_t *device; 101 usb_address_t address; 102 usb_endpoint_t default_ep; 103 usb_hid_report_parser_t *parser; 104 } usb_hid_dev_kbd_t; 105 56 106 #endif 57 107 /** -
uspace/lib/usb/include/usb/classes/hidparser.h
ra59cdd2 ra822cd8 50 50 * @param arg Custom argument. 51 51 */ 52 void (*keyboard)(const uint 32_t *key_codes, size_t count, void *arg);52 void (*keyboard)(const uint16_t *key_codes, size_t count, void *arg); 53 53 } usb_hid_report_in_callbacks_t; 54 54 55 55 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, 56 const uint8_t *data );56 const uint8_t *data, size_t size); 57 57 58 58 int usb_hid_parse_report(const usb_hid_report_parser_t *parser, 59 const uint8_t *data, 59 const uint8_t *data, size_t size, 60 60 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 61 61 -
uspace/lib/usb/src/hidparser.c
ra59cdd2 ra822cd8 40 40 * @param parser Opaque HID report parser structure. 41 41 * @param data Data describing the report. 42 * @param size Size of the descriptor in bytes. 42 43 * @return Error code. 43 44 */ 44 45 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, 45 const uint8_t *data )46 const uint8_t *data, size_t size) 46 47 { 47 48 return ENOTSUP; … … 54 55 * @param parser Opaque HID report parser structure. 55 56 * @param data Data for the report. 57 * @param size Size of the data in bytes. 56 58 * @param callbacks Callbacks for report actions. 57 59 * @param arg Custom argument (passed through to the callbacks). … … 59 61 */ 60 62 int usb_hid_parse_report(const usb_hid_report_parser_t *parser, 61 const uint8_t *data, 63 const uint8_t *data, size_t size, 62 64 const usb_hid_report_in_callbacks_t *callbacks, void *arg) 63 65 { 64 return ENOTSUP; 66 int i; 67 68 // TODO: parse report 69 70 uint16_t keys[6]; 71 72 for (i = 0; i < 6; ++i) { 73 keys[i] = data[i]; 74 } 75 76 callbacks->keyboard(keys, 6, arg); 77 78 return EOK; 65 79 } 66 80 -
uspace/lib/usb/src/usbdrvreq.c
ra59cdd2 ra822cd8 162 162 .request = USB_DEVREQ_GET_DESCRIPTOR, 163 163 .index = 0, 164 .length = sizeof(usb_standard_ device_descriptor_t)164 .length = sizeof(usb_standard_configuration_descriptor_t) 165 165 }; 166 166 setup_packet.value_high = USB_DESCTYPE_CONFIGURATION; … … 225 225 .request = USB_DEVREQ_GET_DESCRIPTOR, 226 226 .index = 0, 227 .length = sizeof(usb_standard_device_descriptor_t)227 .length = buffer_size 228 228 }; 229 229 setup_packet.value_high = USB_DESCTYPE_CONFIGURATION;
Note:
See TracChangeset
for help on using the changeset viewer.