Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/virtusbkbd/virtusbkbd.c

    r6cb58e6 r679a135  
    4848#include <usb/descriptor.h>
    4949#include <usb/classes/hid.h>
    50 #include <usb/debug.h>
    5150#include <usbvirt/device.h>
     51#include <usbvirt/hub.h>
    5252
    5353#include "kbdconfig.h"
     
    6767
    6868kb_status_t status;
     69
     70static int on_incoming_data(struct usbvirt_device *dev,
     71    usb_endpoint_t endpoint, void *buffer, size_t size)
     72{
     73        printf("%s: ignoring incomming data to endpoint %d\n", NAME, endpoint);
     74       
     75        return EOK;
     76}
     77
    6978
    7079/** Compares current and last status of pressed keys.
     
    91100}
    92101
    93 static int on_request_for_data(usbvirt_device_t *dev,
    94     usb_endpoint_t endpoint, usb_transfer_type_t transfer_type,
    95     void *buffer, size_t size, size_t *actual_size)
     102static int on_request_for_data(struct usbvirt_device *dev,
     103    usb_endpoint_t endpoint, void *buffer, size_t size, size_t *actual_size)
    96104{
    97105        static uint8_t last_data[2 + KB_MAX_KEYS_AT_ONCE];
     
    114122        if (keypress_check_with_last_request(data, last_data,
    115123            2 + KB_MAX_KEYS_AT_ONCE)) {
    116                 return ENAK;
     124                *actual_size = 0;
     125                return EOK;
    117126        }
    118127
     
    122131}
    123132
    124 static usbvirt_control_request_handler_t endpoint_zero_handlers[] = {
    125         {
    126                 .req_direction = USB_DIRECTION_IN,
    127                 .req_type = USB_REQUEST_TYPE_STANDARD,
    128                 .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE,
     133static usbvirt_control_transfer_handler_t endpoint_zero_handlers[] = {
     134        {
     135                .request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(
     136                    USB_DIRECTION_IN,
     137                    USBVIRT_REQUEST_TYPE_STANDARD,
     138                    USBVIRT_REQUEST_RECIPIENT_DEVICE),
    129139                .request = USB_DEVREQ_GET_DESCRIPTOR,
    130140                .name = "GetDescriptor",
    131                 .callback = req_get_descriptor
    132         },
    133         {
    134                 .callback = NULL
    135         }
     141                .callback = stdreq_on_get_descriptor
     142        },
     143        {
     144                .request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(
     145                    USB_DIRECTION_IN,
     146                    USBVIRT_REQUEST_TYPE_CLASS,
     147                    USBVIRT_REQUEST_RECIPIENT_DEVICE),
     148                .request = USB_DEVREQ_GET_DESCRIPTOR,
     149                .name = "GetDescriptor",
     150                .callback = stdreq_on_get_descriptor
     151        },
     152        USBVIRT_CONTROL_TRANSFER_HANDLER_LAST
    136153};
    137154
     
    140157 */
    141158static usbvirt_device_ops_t keyboard_ops = {
    142         .control = endpoint_zero_handlers,
    143         .data_in[1] = on_request_for_data
     159        .control_transfer_handlers = endpoint_zero_handlers,
     160        .on_data = on_incoming_data,
     161        .on_data_request = on_request_for_data
    144162};
    145163
     
    179197        .ops = &keyboard_ops,
    180198        .descriptors = &descriptors,
     199        .lib_debug_level = 3,
     200        .lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL,
    181201        .name = "keyboard"
    182202};
     
    242262       
    243263       
    244         int rc = usbvirt_device_plug(&keyboard_dev, "/virt/usbhc/hc");
     264        int rc = usbvirt_connect(&keyboard_dev);
    245265        if (rc != EOK) {
    246266                printf("%s: Unable to start communication with VHCD (%s).\n",
     
    258278        printf("%s: Terminating...\n", NAME);
    259279       
    260         //usbvirt_disconnect(&keyboard_dev);
     280        usbvirt_disconnect(&keyboard_dev);
    261281       
    262282        return 0;
Note: See TracChangeset for help on using the changeset viewer.