summaryrefslogtreecommitdiff
path: root/src/hid_osx.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hid_osx.c')
-rw-r--r--src/hid_osx.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/hid_osx.c b/src/hid_osx.c
index b705b43..5c40747 100644
--- a/src/hid_osx.c
+++ b/src/hid_osx.c
@@ -197,7 +197,7 @@ copy_info(fido_dev_info_t *di, IOHIDDeviceRef dev)
197} 197}
198 198
199int 199int
200fido_dev_info_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen) 200fido_hid_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen)
201{ 201{
202 IOHIDManagerRef manager = NULL; 202 IOHIDManagerRef manager = NULL;
203 CFSetRef devset = NULL; 203 CFSetRef devset = NULL;
@@ -240,6 +240,12 @@ fido_dev_info_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen)
240 240
241 for (CFIndex i = 0; i < devcnt; i++) { 241 for (CFIndex i = 0; i < devcnt; i++) {
242 if (copy_info(&devlist[*olen], devs[i]) == 0) { 242 if (copy_info(&devlist[*olen], devs[i]) == 0) {
243 devlist[*olen].io = (fido_dev_io_t) {
244 fido_hid_open,
245 fido_hid_close,
246 fido_hid_read,
247 fido_hid_write,
248 };
243 if (++(*olen) == ilen) 249 if (++(*olen) == ilen)
244 break; 250 break;
245 } 251 }
@@ -378,15 +384,18 @@ fido_hid_read(void *handle, unsigned char *buf, size_t len, int ms)
378 IOHIDDeviceScheduleWithRunLoop(dev->ref, CFRunLoopGetCurrent(), 384 IOHIDDeviceScheduleWithRunLoop(dev->ref, CFRunLoopGetCurrent(),
379 dev->loop_id); 385 dev->loop_id);
380 386
381 do 387 r = CFRunLoopRunInMode(dev->loop_id, 0.3, true);
382 r = CFRunLoopRunInMode(dev->loop_id, 0.003, true);
383 while (r != kCFRunLoopRunHandledSource);
384 388
385 IOHIDDeviceRegisterInputReportCallback(dev->ref, buf, len, NULL, NULL); 389 IOHIDDeviceRegisterInputReportCallback(dev->ref, buf, len, NULL, NULL);
386 IOHIDDeviceRegisterRemovalCallback(dev->ref, NULL, NULL); 390 IOHIDDeviceRegisterRemovalCallback(dev->ref, NULL, NULL);
387 IOHIDDeviceUnscheduleFromRunLoop(dev->ref, CFRunLoopGetCurrent(), 391 IOHIDDeviceUnscheduleFromRunLoop(dev->ref, CFRunLoopGetCurrent(),
388 dev->loop_id); 392 dev->loop_id);
389 393
394 if (r != kCFRunLoopRunHandledSource) {
395 fido_log_debug("%s: CFRunLoopRunInMode=%d", __func__, (int)r);
396 return (-1);
397 }
398
390 return (REPORT_LEN - 1); 399 return (REPORT_LEN - 1);
391} 400}
392 401