Changeset a694a58 in mainline
- Timestamp:
- 2011-04-07T21:18:37Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cf81757
- Parents:
- c156c2d
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbkbd/kbddev.c
rc156c2d ra694a58 128 128 0x15, 0x00, // Logical Minimum (0), 129 129 0x25, 0x01, // Logical Maximum (1), 130 //0x85, 0x00, // Report ID, 131 //0xA4, // Push 130 132 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), 133 136 0x81, 0x01, // Input (Constant), ; Reserved byte 134 137 0x95, 0x05, // Report Count (5), … … 557 560 assert(kbd_dev != NULL); 558 561 559 usb_log_debug("Got keys from parser : %s\n",562 usb_log_debug("Got keys from parser (report id: %d): %s\n", modifiers, 560 563 usb_debug_str_buffer(key_codes, count, 0)); 561 564 … … 608 611 usb_hid_report_path_t *path = usb_hid_report_path(); 609 612 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 610 611 int rc = usb_hid_parse_report(kbd_dev->parser, buffer, 613 614 uint8_t *tmp_buf = malloc((actual_size+1)*sizeof(uint8_t)); 615 tmp_buf[0] = 0x00; 616 memcpy(tmp_buf+1, buffer, actual_size); 617 618 int rc = usb_hid_parse_report(kbd_dev->parser, tmp_buf, 612 619 actual_size, path, USB_HID_PATH_COMPARE_STRICT, callbacks, kbd_dev); 613 620 … … 730 737 731 738 /* Get the report descriptor and parse it. */ 732 rc = usb_hid_process_report_descriptor(kbd_dev->usb_dev,733 kbd_dev->parser);734 if ( rc != EOK) {739 //rc = usb_hid_process_report_descriptor(kbd_dev->usb_dev, 740 // kbd_dev->parser); 741 if (true || rc != EOK) { 735 742 usb_log_warning("Could not process report descriptor, " 736 743 "falling back to boot protocol.\n"); … … 776 783 kbd_dev->output_size = 0; 777 784 kbd_dev->output_buffer = usb_hid_report_output(kbd_dev->parser, 778 &kbd_dev->output_size );785 &kbd_dev->output_size, 0x00); 779 786 if (kbd_dev->output_buffer == NULL) { 780 787 usb_log_warning("Error creating output report buffer.\n"); … … 788 795 usb_hid_report_path_append_item( 789 796 kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0); 797 usb_hid_report_path_set_report_id(kbd_dev->led_path, 0x00); 790 798 791 799 kbd_dev->led_output_size = usb_hid_report_output_size(kbd_dev->parser, -
uspace/lib/usb/include/usb/classes/hidparser.h
rc156c2d ra694a58 240 240 void usb_hid_descriptor_print(usb_hid_report_parser_t *parser); 241 241 242 /*243 * Boot protocol functions244 */245 /** */246 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size,247 const usb_hid_report_in_callbacks_t *callbacks, void *arg);248 249 /** */250 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size);251 252 242 253 243 /* … … 301 291 */ 302 292 /** Allocates output report buffer*/ 303 uint8_t *usb_hid_report_output(usb_hid_report_parser_t *parser, size_t *size );293 uint8_t *usb_hid_report_output(usb_hid_report_parser_t *parser, size_t *size, uint8_t report_id); 304 294 305 295 /** Frees output report buffer*/ -
uspace/lib/usb/src/hidparser.c
rc156c2d ra694a58 40 40 #include <usb/debug.h> 41 41 42 /** */ 42 /** The new report item flag. Used to determine when the item is completly 43 * configured and should be added to the report structure 44 */ 43 45 #define USB_HID_NEW_REPORT_ITEM 1 44 46 45 /** */ 46 #define USB_HID_NO_ACTION 2 47 48 /** */ 47 /** No special action after the report descriptor tag is processed should be 48 * done 49 */ 50 #define USB_HID_NO_ACTION 2 51 52 /** Unknown tag was founded in report descriptor data*/ 49 53 #define USB_HID_UNKNOWN_TAG -99 50 54 … … 236 240 new_report_item->string_maximum = 0; 237 241 242 /* set the report id */ 243 new_report_item->id = report_item->id; 244 238 245 /* reset usage from current usage path */ 239 246 usb_hid_report_usage_path_t *path = list_get_instance(&usage_path->link, usb_hid_report_usage_path_t, link); … … 290 297 } 291 298 292 293 /**294 * Parse input report.295 *296 * @param data Data for report297 * @param size Size of report298 * @param callbacks Callbacks for report actions299 * @param arg Custom arguments300 *301 * @return Error code302 */303 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size,304 const usb_hid_report_in_callbacks_t *callbacks, void *arg)305 {306 int i;307 usb_hid_report_item_t item;308 309 /* fill item due to the boot protocol report descriptor */310 // modifier keys are in the first byte311 uint8_t modifiers = data[0];312 313 item.offset = 2; /* second byte is reserved */314 item.size = 8;315 item.count = 6;316 item.usage_minimum = 0;317 item.usage_maximum = 255;318 item.logical_minimum = 0;319 item.logical_maximum = 255;320 321 if (size != 8) {322 return -1; //ERANGE;323 }324 325 uint8_t keys[6];326 for (i = 0; i < item.count; i++) {327 keys[i] = data[i + item.offset];328 }329 330 callbacks->keyboard(keys, 6, modifiers, arg);331 return EOK;332 }333 334 /**335 * Makes output report for keyboard boot protocol336 *337 * @param leds338 * @param output Output report data buffer339 * @param size Size of the output buffer340 * @return Error code341 */342 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size)343 {344 if(size != 1){345 return -1;346 }347 348 /* used only first five bits, others are only padding*/349 *data = leds;350 return EOK;351 }352 299 353 300 /** … … 859 806 860 807 /** 861 * 862 * 863 * @param parser 864 * @param path 865 * @param flags 866 * @return 808 * Returns number of items in input report which are accessible by given usage path 809 * 810 * @param parser Opaque report descriptor structure 811 * @param path Usage path specification 812 * @param flags Usage path comparison flags 813 * @return Number of items in input report 867 814 */ 868 815 size_t usb_hid_report_input_length(const usb_hid_report_parser_t *parser, … … 893 840 894 841 /** 895 * 896 * @param usage_path 897 * @param usage_page 898 * @param usage 899 * @return 842 * Appends one item (couple of usage_path and usage) into the usage path 843 * structure 844 * 845 * @param usage_path Usage path structure 846 * @param usage_page Usage page constant 847 * @param usage Usage constant 848 * @return Error code 900 849 */ 901 850 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, … … 918 867 919 868 /** 920 * 921 * @param usage_path 922 * @return 869 * Removes last item from the usage path structure 870 * @param usage_path 871 * @return void 923 872 */ 924 873 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path) … … 935 884 936 885 /** 886 * Nulls last item of the usage path structure. 937 887 * 938 888 * @param usage_path 939 * @return 889 * @return void 940 890 */ 941 891 void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path) … … 950 900 951 901 /** 952 * 953 * @param usage_path 954 * @param tag 955 * @param data 956 * @return 902 * Modifies last item of usage path structure by given usage page or usage 903 * 904 * @param usage_path Opaque usage path structure 905 * @param tag Class of currently processed tag (Usage page tag falls into Global 906 * class but Usage tag into the Local) 907 * @param data Value of the processed tag 908 * @return void 957 909 */ 958 910 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, int32_t tag, int32_t data) … … 976 928 977 929 /** 978 * 979 * 980 * @param report_path 981 * @param path 982 * @param flags 983 * @return 930 * Compares two usage paths structures 931 * 932 * @param report_path usage path structure to compare 933 * @param path usage patrh structure to compare 934 * @param flags Flags determining the mode of comparison 935 * @return EOK if both paths are identical, non zero number otherwise 984 936 */ 985 937 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, … … 1082 1034 1083 1035 /** 1084 * 1085 * @return 1036 * Allocates and initializes new usage path structure. 1037 * 1038 * @return Initialized usage path structure 1086 1039 */ 1087 1040 usb_hid_report_path_t *usb_hid_report_path(void) … … 1101 1054 1102 1055 /** 1103 * 1104 * @param path 1056 * Releases given usage path structure. 1057 * 1058 * @param path usage path structure to release 1105 1059 * @return void 1106 1060 */ … … 1116 1070 * Clone content of given usage path to the new one 1117 1071 * 1118 * @param usage_path 1119 * @return 1072 * @param usage_path Usage path structure to clone 1073 * @return New copy of given usage path structure 1120 1074 */ 1121 1075 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path) … … 1147 1101 /*** OUTPUT API **/ 1148 1102 1149 /** Allocates output report buffer 1150 * 1151 * @param parser 1152 * @param size 1153 * @return 1154 */ 1155 uint8_t *usb_hid_report_output(usb_hid_report_parser_t *parser, size_t *size) 1103 /** 1104 * Allocates output report buffer for output report 1105 * 1106 * @param parser Report parsed structure 1107 * @param size Size of returned buffer 1108 * @param report_id Report id of created output report 1109 * @return Returns allocated output buffer for specified output 1110 */ 1111 uint8_t *usb_hid_report_output(usb_hid_report_parser_t *parser, size_t *size, uint8_t report_id) 1156 1112 { 1157 1113 if(parser == NULL) { … … 1165 1121 1166 1122 link = parser->output.prev; 1123 while((link != &parser->output)){ 1124 last = list_get_instance(link, usb_hid_report_item_t, link); 1125 1126 usb_log_debug("pro id: %d, posledni %d\n", report_id, last->id); 1127 if(last->id == report_id){ 1128 break; 1129 } 1130 else { 1131 link = link->prev; 1132 } 1133 } 1134 1135 1136 1167 1137 if(link != &parser->output) { 1168 1138 last = list_get_instance(link, usb_hid_report_item_t, link); … … 1189 1159 * 1190 1160 * @param output Output report buffer 1191 * @return 1161 * @return void 1192 1162 */ 1193 1163 void usb_hid_report_output_free(uint8_t *output) … … 1201 1171 /** Returns size of output for given usage path 1202 1172 * 1203 * @param parser 1204 * @param path 1205 * @param flags 1206 * @return 1173 * @param parser Opaque report parser structure 1174 * @param path Usage path specified which items will be thought for the output 1175 * @param flags Flags of usage path structure comparison 1176 * @return Number of items matching the given usage path 1207 1177 */ 1208 1178 size_t usb_hid_report_output_size(usb_hid_report_parser_t *parser, … … 1232 1202 } 1233 1203 1234 /** Updates the output report buffer by translatedgiven data1235 * 1236 * @param parser 1237 * @param path 1238 * @param flags 1239 * @param buffer 1240 * @param size 1241 * @param data 1242 * @param data_size 1243 * @return 1204 /** Updates the output report buffer by given data 1205 * 1206 * @param parser Opaque report parser structure 1207 * @param path Usage path specifing which parts of output will be set 1208 * @param flags Usage path structure comparison flags 1209 * @param buffer Output buffer 1210 * @param size Size of output buffer 1211 * @param data Data buffer 1212 * @param data_size Size of data buffer 1213 * @return Error code 1244 1214 */ 1245 1215 int usb_hid_report_output_translate(usb_hid_report_parser_t *parser, … … 1341 1311 1342 1312 /** 1343 * 1344 * @param item 1345 * @param value 1346 * @return 1313 * Translate given data for putting them into the outoput report 1314 * @param item Report item structure 1315 * @param value Value to translate 1316 * @return ranslated value 1347 1317 */ 1348 1318 int32_t usb_hid_translate_data_reverse(usb_hid_report_item_t *item, int value) … … 1389 1359 } 1390 1360 1391 1361 /** 1362 * Sets report id in usage path structure 1363 * 1364 * @param path Usage path structure 1365 * @param report_id Report id to set 1366 * @return Error code 1367 */ 1392 1368 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, uint8_t report_id) 1393 1369 { … … 1400 1376 } 1401 1377 1402 1378 /** 1379 * Clones given report item structure and returns the new one 1380 * 1381 * @param item Report item structure to clone 1382 * @return Clonned item 1383 */ 1403 1384 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item) 1404 1385 {
Note:
See TracChangeset
for help on using the changeset viewer.