USB host support (#527)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include <tactility/drivers/usb_host_hid.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/driver.h>
|
||||
|
||||
#define USB_HID_API(driver) ((struct UsbHidApi*)(driver)->api)
|
||||
|
||||
extern "C" {
|
||||
|
||||
const struct DeviceType USB_HOST_HID_TYPE = {
|
||||
.name = "usb-host-hid",
|
||||
};
|
||||
|
||||
bool usb_host_hid_is_connected(struct Device* device) {
|
||||
auto* api = USB_HID_API(device_get_driver(device));
|
||||
return api->is_connected(device);
|
||||
}
|
||||
|
||||
bool usb_host_hid_subscribe(struct Device* device, UsbHidQueueHandle event_queue) {
|
||||
auto* api = USB_HID_API(device_get_driver(device));
|
||||
return api->subscribe(device, event_queue);
|
||||
}
|
||||
|
||||
void usb_host_hid_unsubscribe(struct Device* device, UsbHidQueueHandle event_queue) {
|
||||
auto* api = USB_HID_API(device_get_driver(device));
|
||||
api->unsubscribe(device, event_queue);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <tactility/drivers/usb_host_midi.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/driver.h>
|
||||
|
||||
#define USB_MIDI_API(driver) ((struct UsbMidiApi*)(driver)->api)
|
||||
|
||||
extern "C" {
|
||||
|
||||
const struct DeviceType USB_HOST_MIDI_TYPE = {
|
||||
.name = "usb-host-midi",
|
||||
};
|
||||
|
||||
void usb_midi_set_callback(struct Device* device, usb_midi_message_cb_t callback, void* user_data) {
|
||||
auto* api = USB_MIDI_API(device_get_driver(device));
|
||||
api->set_callback(device, callback, user_data);
|
||||
}
|
||||
|
||||
bool usb_midi_is_connected(struct Device* device) {
|
||||
auto* api = USB_MIDI_API(device_get_driver(device));
|
||||
return api->is_connected(device);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,18 @@
|
||||
#include <tactility/drivers/usb_host_msc.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/driver.h>
|
||||
|
||||
#define USB_MSC_API(driver) ((struct UsbMscApi*)(driver)->api)
|
||||
|
||||
extern "C" {
|
||||
|
||||
const struct DeviceType USB_HOST_MSC_TYPE = {
|
||||
.name = "usb-host-msc",
|
||||
};
|
||||
|
||||
bool usb_msc_eject(struct Device* device, const char* mount_path) {
|
||||
auto* api = USB_MSC_API(device_get_driver(device));
|
||||
return api->eject && api->eject(device, mount_path);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
Reference in New Issue
Block a user