Module: MyHIDAPI
- Defined in:
- lib/myhidapi.rb,
ext/myhidapi/myhidapi.c
Defined Under Namespace
Classes: DeviceInfo, Handle
Constant Summary collapse
- VERSION =
'1.0.2'
Class Method Summary collapse
- .build_device_info(*args) ⇒ Object
- .enumerate(vendor_id, product_id) ⇒ Object
- .open(vid, pid) ⇒ Object
- .open_path(path) ⇒ Object
Class Method Details
.build_device_info(*args) ⇒ Object
25 26 27 |
# File 'lib/myhidapi.rb', line 25 def self.build_device_info(*args) DeviceInfo.new(*args) end |
.enumerate(vendor_id, product_id) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'ext/myhidapi/myhidapi.c', line 38 static VALUE enumerate(VALUE mod, VALUE vendor_id, VALUE product_id) { VALUE devices; struct hid_device_info *devs, *cur_dev; devices = rb_ary_new(); devs = hid_enumerate(NUM2USHORT(vendor_id), NUM2USHORT(product_id)); cur_dev = devs; while (cur_dev) { rb_ary_push(devices, rb_funcall(mMyHIDAPI, rb_intern("build_device_info"), 8, INT2NUM(cur_dev->vendor_id), INT2NUM(cur_dev->product_id), rb_str_new2(cur_dev->path), rb_wcstombs(cur_dev->serial_number), rb_wcstombs(cur_dev->manufacturer_string), rb_wcstombs(cur_dev->product_string), INT2NUM(cur_dev->usage), INT2NUM(cur_dev->interface_number) )); cur_dev = cur_dev->next; } hid_free_enumeration(devs); return devices; } |
.open(vid, pid) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'ext/myhidapi/myhidapi.c', line 65 static VALUE rb_hid_open(VALUE mod, VALUE vid, VALUE pid) { hid_device *handle; handle = hid_open(NUM2USHORT(vid), NUM2USHORT(pid), NULL); if (handle) { return TypedData_Wrap_Struct(cMyHIDAPIHandle, &myhidapi_handle_type, handle); } else { return Qfalse; } } |
.open_path(path) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'ext/myhidapi/myhidapi.c', line 79 static VALUE rb_hid_open_path(VALUE mod, VALUE path) { hid_device *handle; handle = hid_open_path(StringValueCStr(path)); if (handle) { return TypedData_Wrap_Struct(cMyHIDAPIHandle, &myhidapi_handle_type, handle); } else { return Qfalse; } } |