Changeset e1dbcbc in mainline for uspace/app/vuhid/virthid.h


Ignore:
Timestamp:
2011-04-29T13:43:01Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a81a1d09
Parents:
380e0364 (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 development/ changes

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/vuhid/virthid.h

    r380e0364 re1dbcbc  
    2727 */
    2828
    29 /** @addtogroup usbvirthub
     29/** @addtogroup usbvirthid
    3030 * @{
    3131 */
    32 /**
    33  * @file
    34  * @brief Virtual USB hub.
     32/** @file
     33 *
    3534 */
    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_
    4237
    4338#include <usb/usb.h>
    44 #include <usb/descriptor.h>
    45 #include <usb/classes/hub.h>
    4639#include <usbvirt/device.h>
    47 #include <usbvirt/hub.h>
    4840
    49 #include "vhc_hub/virthub.h"
     41#define VUHID_ENDPOINT_MAX USB11_ENDPOINT_MAX
     42#define VUHID_INTERFACE_MAX 8
    5043
    51 #define NAME "vuh"
     44typedef struct vuhid_interface vuhid_interface_t;
    5245
    53 static usbvirt_device_t hub_device;
     46struct vuhid_interface {
     47        const char *name;
     48        const char *id;
     49        int usb_subclass;
     50        int usb_protocol;
    5451
    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;
    6454
    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;
    7157
    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 *);
    7361
    74 int main(int argc, char * argv[])
    75 {
    76         int rc;
     62        int set_protocol;
    7763
    78         printf(NAME ": virtual USB hub.\n");
     64        void *interface_data;
     65};
    7966
    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);
     67typedef 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;
    9074
    91                 VERBOSE_SLEEP(8, "will pretend device un-plug...");
    92                 virthub_disconnect_device(&hub_device, &dev1);
    93         }
     75typedef 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;
    9484
    95         usbvirt_disconnect(&hub_device);
    96        
    97         return 0;
    98 }
     85int add_interface_by_id(vuhid_interface_t **, const char *, usbvirt_device_t *);
    9986
    100 
    101 /** @}
     87#endif
     88/**
     89 * @}
    10290 */
Note: See TracChangeset for help on using the changeset viewer.