mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-28 04:23:37 +01:00
libfxlink: basic device enumeration without hotplug [Windows]
This commit is contained in:
parent
c3d7fd6efa
commit
9de441d0f4
2 changed files with 10 additions and 1 deletions
|
@ -817,13 +817,16 @@ bool fxlink_device_list_track(struct fxlink_device_list *list,
|
||||||
libusb_context *ctx)
|
libusb_context *ctx)
|
||||||
{
|
{
|
||||||
memset(list, 0, sizeof *list);
|
memset(list, 0, sizeof *list);
|
||||||
|
list->ctx = ctx;
|
||||||
|
|
||||||
if(!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
|
if(!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
|
||||||
elog("libusb doesn't handle hotplug; devices may not be detected\n");
|
elog("libusb doesn't handle hotplug; devices may not be detected\n");
|
||||||
|
list->hotplug_supported = false;
|
||||||
|
enumerate_devices(ctx, list);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
list->ctx = ctx;
|
list->hotplug_supported = true;
|
||||||
libusb_hotplug_register_callback(ctx,
|
libusb_hotplug_register_callback(ctx,
|
||||||
/* Both arriving and departing devices */
|
/* Both arriving and departing devices */
|
||||||
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT,
|
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT,
|
||||||
|
@ -839,6 +842,9 @@ bool fxlink_device_list_track(struct fxlink_device_list *list,
|
||||||
|
|
||||||
void fxlink_device_list_refresh(struct fxlink_device_list *list)
|
void fxlink_device_list_refresh(struct fxlink_device_list *list)
|
||||||
{
|
{
|
||||||
|
if(!list->hotplug_supported)
|
||||||
|
enumerate_devices(list->ctx, list);
|
||||||
|
|
||||||
for(int i = 0; i < list->count; i++) {
|
for(int i = 0; i < list->count; i++) {
|
||||||
struct fxlink_device *fdev = &list->devices[i];
|
struct fxlink_device *fdev = &list->devices[i];
|
||||||
/* Finish analysis */
|
/* Finish analysis */
|
||||||
|
|
|
@ -299,6 +299,9 @@ struct fxlink_device_list {
|
||||||
libusb_context *ctx;
|
libusb_context *ctx;
|
||||||
/* Callback handle */
|
/* Callback handle */
|
||||||
libusb_hotplug_callback_handle hotplug_handle;
|
libusb_hotplug_callback_handle hotplug_handle;
|
||||||
|
/* Whether the hotplug callback could be installed. If not, refreshes
|
||||||
|
will be made manually. */
|
||||||
|
bool hotplug_supported;
|
||||||
/* Array of connected devices */
|
/* Array of connected devices */
|
||||||
struct fxlink_device *devices;
|
struct fxlink_device *devices;
|
||||||
/* Number of elements in `devices` */
|
/* Number of elements in `devices` */
|
||||||
|
|
Loading…
Reference in a new issue