Created
May 23, 2015 04:20
-
-
Save ajsb85/90b8006485a4ab709eb0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Components.utils.import("resource://gre/modules/ctypes.jsm"); | |
| Components.utils.import("resource://gre/modules/Services.jsm"); | |
| // Or using Services.jsm and Ci = Components.interfaces | |
| var file = Components.classes["@mozilla.org/file/directory_service;1"]. | |
| getService(Components.interfaces.nsIProperties). | |
| get("CurProcD", Components.interfaces.nsIFile); | |
| // Append the file name. | |
| file.append("hidapi.dll"); | |
| dump(file.path); | |
| var lib = ctypes.open(file.path); | |
| /* if (hid_init()) | |
| return -1; | |
| devs = hid_enumerate(0x0, 0x0); */ | |
| var hid = lib.declare("hid_init", | |
| ctypes.winapi_abi, | |
| ctypes.bool /* return type */); | |
| var struct_hid_device_info; | |
| struct_hid_device_info = ctypes.StructType('hid_device_info', [ | |
| {'path': ctypes.char.ptr}, | |
| {'vendor_id': ctypes.unsigned_short}, | |
| {'product_id': ctypes.unsigned_short}, | |
| {'serial_number': ctypes.jschar.ptr}, | |
| {'release_number': ctypes.unsigned_short}, | |
| {'manufacturer_string': ctypes.jschar.ptr}, | |
| {'product_string': ctypes.jschar.ptr}, | |
| {'usage_page': ctypes.unsigned_short}, | |
| {'usage': ctypes.unsigned_short}, | |
| {'interface_number': ctypes.int} | |
| ]); | |
| /* Declare the signature of the function we are going to call */ | |
| var enumerate = lib.declare("hid_enumerate", | |
| ctypes.winapi_abi, | |
| struct_hid_device_info, | |
| ctypes.int32_t, | |
| ctypes.int32_t); | |
| hid(); | |
| var log_enumerate = enumerate(0, 0); | |
| dump(struct_hid_device_info); | |
| lib.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment