Changeset 3d4aa055 in mainline for uspace/app/vuhid/virthid.h
- Timestamp:
- 2011-05-06T13:08:10Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 075c1eb, 3da17644
- Parents:
- a58dd620 (diff), 310c4df (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vuhid/virthid.h
ra58dd620 r3d4aa055 27 27 */ 28 28 29 /** @addtogroup usbvirth ub29 /** @addtogroup usbvirthid 30 30 * @{ 31 31 */ 32 /** 33 * @file 34 * @brief Virtual USB hub. 32 /** @file 33 * 35 34 */ 36 37 #include <stdio.h> 38 #include <stdlib.h> 39 #include <errno.h> 40 #include <str_error.h> 41 #include <bool.h> 35 #ifndef VUHID_VIRTHID_H_ 36 #define VUHID_VIRTHID_H_ 42 37 43 38 #include <usb/usb.h> 44 #include <usb/descriptor.h>45 #include <usb/classes/hub.h>46 39 #include <usbvirt/device.h> 47 #include <usbvirt/hub.h>48 40 49 #include "vhc_hub/virthub.h" 41 #define VUHID_ENDPOINT_MAX USB11_ENDPOINT_MAX 42 #define VUHID_INTERFACE_MAX 8 50 43 51 #define NAME "vuh" 44 typedef struct vuhid_interface vuhid_interface_t; 52 45 53 static usbvirt_device_t hub_device; 46 struct vuhid_interface { 47 const char *name; 48 const char *id; 49 int usb_subclass; 50 int usb_protocol; 54 51 55 #define VERBOSE_SLEEP(sec, msg, ...) \ 56 do { \ 57 char _status[HUB_PORT_COUNT + 2]; \ 58 printf(NAME ": doing nothing for %zu seconds...\n", \ 59 (size_t) (sec)); \ 60 fibril_sleep((sec)); \ 61 virthub_get_status(&hub_device, _status, HUB_PORT_COUNT + 1); \ 62 printf(NAME ": " msg " [%s]\n" #__VA_ARGS__, _status); \ 63 } while (0) 52 uint8_t *report_descriptor; 53 size_t report_descriptor_size; 64 54 65 static void fibril_sleep(size_t sec) 66 { 67 while (sec-- > 0) { 68 async_usleep(1000*1000); 69 } 70 } 55 size_t in_data_size; 56 size_t out_data_size; 71 57 72 static int dev1 = 1; 58 int (*on_data_in)(vuhid_interface_t *, void *, size_t, size_t *); 59 int (*on_data_out)(vuhid_interface_t *, void *, size_t); 60 void (*live)(vuhid_interface_t *); 73 61 74 int main(int argc, char * argv[]) 75 { 76 int rc; 62 int set_protocol; 77 63 78 printf(NAME ": virtual USB hub.\n"); 64 void *interface_data; 65 }; 79 66 80 rc = virthub_init(&hub_device); 81 if (rc != EOK) { 82 printf(NAME ": Unable to start communication with VHCD (%s).\n", 83 str_error(rc)); 84 return rc; 85 } 86 87 while (true) { 88 VERBOSE_SLEEP(8, "will pretend device plug-in..."); 89 virthub_connect_device(&hub_device, &dev1); 67 typedef struct { 68 vuhid_interface_t *in_endpoints_mapping[VUHID_ENDPOINT_MAX]; 69 size_t in_endpoint_first_free; 70 vuhid_interface_t *out_endpoints_mapping[VUHID_ENDPOINT_MAX]; 71 size_t out_endpoint_first_free; 72 vuhid_interface_t *interface_mapping[VUHID_INTERFACE_MAX]; 73 } vuhid_data_t; 90 74 91 VERBOSE_SLEEP(8, "will pretend device un-plug..."); 92 virthub_disconnect_device(&hub_device, &dev1); 93 } 75 typedef struct { 76 uint8_t length; 77 uint8_t type; 78 uint16_t hid_spec_release; 79 uint8_t country_code; 80 uint8_t descriptor_count; 81 uint8_t descriptor1_type; 82 uint16_t descriptor1_length; 83 } __attribute__ ((packed)) hid_descriptor_t; 94 84 95 usbvirt_disconnect(&hub_device); 96 97 return 0; 98 } 85 int add_interface_by_id(vuhid_interface_t **, const char *, usbvirt_device_t *); 99 86 100 101 /** @} 87 #endif 88 /** 89 * @} 102 90 */
Note:
See TracChangeset
for help on using the changeset viewer.