Changeset b8100da in mainline for uspace/app/virtusbkbd/virtusbkbd.c
- Timestamp:
- 2010-10-10T17:01:40Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6c1315b
- Parents:
- b371844
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/virtusbkbd/virtusbkbd.c
rb371844 rb8100da 46 46 47 47 #include <usb/hcd.h> 48 #include <usb/virtdev.h> 48 #include <usbvirt/device.h> 49 #include <usbvirt/hub.h> 50 #include <usbvirt/ids.h> 49 51 50 52 #define LOOPS 5 … … 59 61 (printf("%s: %s" fmt "\n", NAME, _QUOTEME(cmd), __VA_ARGS__), cmd(__VA_ARGS__)) 60 62 63 static int on_incoming_data(struct usbvirt_device *dev, 64 usb_endpoint_t endpoint, void *buffer, size_t size) 65 { 66 printf("%s: ignoring incomming data to endpoint %d\n", NAME, endpoint); 67 68 return EOK; 69 } 70 71 /** Keyboard callbacks. 72 * We abuse the fact that static variables are zero-filled. 73 */ 74 static usbvirt_device_ops_t keyboard_ops = { 75 .on_data = on_incoming_data 76 }; 77 78 /** Keyboard device. 79 * Rest of the items will be initialized later. 80 */ 81 static usbvirt_device_t keyboard_dev = { 82 .ops = &keyboard_ops, 83 .device_id_ = USBVIRT_DEV_KEYBOARD_ID 84 }; 85 86 61 87 static void fibril_sleep(size_t sec) 62 88 { … … 66 92 } 67 93 68 static void on_data_from_host(usb_endpoint_t endpoint, void *buffer, size_t len)69 {70 printf("%s: ignoring incomming data to endpoint %d\n", NAME, endpoint);71 }72 94 73 95 int main(int argc, char * argv[]) 74 96 { 75 int vhcd_phone = usb_virtdev_connect(DEV_HCD_NAME, 76 USB_VIRTDEV_KEYBOARD_ID, on_data_from_host); 77 78 if (vhcd_phone < 0) { 97 int rc = usbvirt_connect(&keyboard_dev, DEV_HCD_NAME); 98 if (rc != EOK) { 79 99 printf("%s: Unable to start comunication with VHCD at usb://%s (%s).\n", 80 NAME, DEV_HCD_NAME, str_error( vhcd_phone));81 return vhcd_phone;100 NAME, DEV_HCD_NAME, str_error(rc)); 101 return rc; 82 102 } 83 84 85 103 86 104 size_t i; … … 94 112 95 113 printf("%s: Will send data to VHCD...\n", NAME); 96 int rc = usb_virtdev_data_to_host(vhcd_phone, 0, data, size);114 int rc = keyboard_dev.send_data(&keyboard_dev, 0, data, size); 97 115 printf("%s: ...data sent (%s).\n", NAME, str_error(rc)); 98 116 } … … 101 119 printf("%s: Terminating...\n", NAME); 102 120 103 ipc_hangup(vhcd_phone);121 usbvirt_disconnect(); 104 122 105 123 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.