├── .gitignore ├── About.md ├── README.md ├── drivers ├── ch341ser_mac.zip └── node-hid │ ├── .gitmodules │ ├── .npmignore │ ├── README.md │ ├── binding.gyp │ ├── build │ ├── HID.target.mk │ ├── Makefile │ ├── Release │ │ ├── .deps │ │ │ └── Release │ │ │ │ ├── HID.node.d │ │ │ │ ├── hidapi.a.d │ │ │ │ └── obj.target │ │ │ │ ├── HID │ │ │ │ └── src │ │ │ │ │ └── HID.o.d │ │ │ │ └── hidapi │ │ │ │ └── hidapi │ │ │ │ └── mac │ │ │ │ └── hid.o.d │ │ ├── HID.node │ │ ├── hidapi.a │ │ ├── linker.lock │ │ └── obj.target │ │ │ ├── HID │ │ │ └── src │ │ │ │ └── HID.o │ │ │ └── hidapi │ │ │ └── hidapi │ │ │ └── mac │ │ │ └── hid.o │ ├── binding.Makefile │ ├── config.gypi │ ├── gyp-mac-tool │ └── hidapi.target.mk │ ├── hidapi │ ├── .gitattributes │ ├── .npmignore │ ├── AUTHORS.txt │ ├── HACKING.txt │ ├── LICENSE-bsd.txt │ ├── LICENSE-gpl3.txt │ ├── LICENSE-orig.txt │ ├── LICENSE.txt │ ├── Makefile.am │ ├── README.txt │ ├── android │ │ └── jni │ │ │ └── Android.mk │ ├── bootstrap │ ├── configure.ac │ ├── doxygen │ │ └── Doxyfile │ ├── hidapi │ │ └── hidapi.h │ ├── hidtest │ │ ├── .npmignore │ │ ├── Makefile.am │ │ └── hidtest.cpp │ ├── libusb │ │ ├── .npmignore │ │ ├── Makefile-manual │ │ ├── Makefile.am │ │ ├── Makefile.freebsd │ │ ├── Makefile.linux │ │ └── hid.c │ ├── linux │ │ ├── .npmignore │ │ ├── Makefile-manual │ │ ├── Makefile.am │ │ ├── README.txt │ │ └── hid.c │ ├── m4 │ │ ├── .npmignore │ │ ├── ax_pthread.m4 │ │ └── pkg.m4 │ ├── mac │ │ ├── .npmignore │ │ ├── Makefile-manual │ │ ├── Makefile.am │ │ └── hid.c │ ├── pc │ │ ├── .npmignore │ │ ├── hidapi-hidraw.pc.in │ │ ├── hidapi-libusb.pc.in │ │ └── hidapi.pc.in │ ├── testgui │ │ ├── .npmignore │ │ ├── Makefile-manual │ │ ├── Makefile.am │ │ ├── Makefile.freebsd │ │ ├── Makefile.linux │ │ ├── Makefile.mac │ │ ├── Makefile.mingw │ │ ├── TestGUI.app.in │ │ │ └── Contents │ │ │ │ ├── Info.plist │ │ │ │ ├── PkgInfo │ │ │ │ └── Resources │ │ │ │ ├── English.lproj │ │ │ │ └── InfoPlist.strings │ │ │ │ └── Signal11.icns │ │ ├── copy_to_bundle.sh │ │ ├── mac_support.cpp │ │ ├── mac_support.h │ │ ├── mac_support_cocoa.m │ │ ├── start.sh │ │ ├── test.cpp │ │ ├── testgui.sln │ │ └── testgui.vcproj │ ├── udev │ │ └── 99-hid.rules │ └── windows │ │ ├── .npmignore │ │ ├── Makefile-manual │ │ ├── Makefile.am │ │ ├── Makefile.mingw │ │ ├── ddk_build │ │ ├── .npmignore │ │ ├── hidapi.def │ │ ├── makefile │ │ └── sources │ │ ├── hid.c │ │ ├── hidapi.sln │ │ ├── hidapi.vcproj │ │ └── hidtest.vcproj │ ├── index.js │ ├── install.sh │ ├── package.json │ └── src │ ├── .npmignore │ ├── HID.cc │ ├── buzzers.js │ ├── powermate.js │ ├── show-devices.js │ ├── test-buzzers.js │ ├── test-powermate.js │ ├── test-ps3.js │ └── wscript ├── examples ├── button.js ├── leds.js ├── light.js ├── motors.js ├── piezo.js ├── reflectance.js ├── sonar.js └── wifi_motors.js ├── firmware └── mbotFirmata │ ├── Adafruit_NeoPixel.cpp │ ├── Adafruit_NeoPixel.h │ ├── Adafruit_NeoPixel_LICENSE │ ├── Boards.h │ ├── Firmata.cpp │ ├── Firmata.h │ ├── mbotFirmata.ino │ ├── ws2812.cpp │ └── ws2812.h ├── package.json └── schedule.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /About.md: -------------------------------------------------------------------------------- 1 | 深JS 硬件合作商合作建议 2 | ================== 3 | 4 | #### 关于深JS 5 | 6 | JavaScript中国开发者大会是国内最大的、最具知名度的年度JavaScript聚会,汇聚国内外JavaScript行业大牛(Github, Twitter, 淘宝,百度, 阿里巴巴, 腾讯), 分享JavaScript在各个领域的实践经验。 7 | 8 | ![hangjs](https://dchtm6r471mui.cloudfront.net/hackpad.com_Yf5jELqu14j_p.74490_1428500290695_Screen%20Shot%202015-04-08%20at%209.37.22%20pm.png) 9 | 10 | JavaScript社区是目前Github上最活跃的社区之一,同时拥有最广阔、最活跃的线下活动。在中国,JavaScript(JS)是目前互联网巨头们都逐步重视的编程语言,最初是淘宝, 而后是整个阿里体系、网易、盛大、腾讯、百度等。JS 在这两三年的时间里异军突起,并逐步扩展到各个领域(硬件、嵌入式等),甚至在新一代中,认为懂得 JS 的比懂得 Java或者懂得 VS.NET 更具吸引力。人才是互联网行业的基石,开发者大会就是技术人才的文化交流得具体体现。中国JS社区相比其他社区更活跃、更热情,ShenJS将会吸引到全国JS开发者的注意,对推动新技术在中国的推广和普及具有重要意义。 11 | 12 | #### JavaScript与硬件 - [NodeBots](http://nodebotsday.com/) 13 | 14 | * [Node Hardware Hacking with Tessel](http://dailyjs.com/2014/06/10/tessel) 15 | * [Espruino: JavaScript Hardware Hacking](http://dailyjs.com/2013/10/11/espruino) 16 | * [Why use JavaScript in Hardware?](http://www.slideshare.net/TechnicalMachine/why-use-javascript-in-hardware-goto-conf-berlin) 17 | * [http://2014.robotsconf.com/](http://2014.robotsconf.com/) 18 | 19 | ![http://2015.jsconf.us/img/building.jpg](http://2015.jsconf.us/img/building.jpg) 20 | 21 | 近年来, JavaScript更是涉及到浏览器之外的领域,涵盖了包括移动端各平台应用开发,智能硬件等各个方面。 22 | 23 | ![http://2014.robotsconf.com/img/robots2013_iancole_9.jpg](http://2014.robotsconf.com/img/robots2013_iancole_9.jpg) 24 | 25 | 深JS将会吸引国内行业内最优秀的开发者。吸取nodebots在国外的成功举办经验,我们也计划在此次活动中加入这一环节,邀请国外nodebots大牛现场分享开发经验并现场编写代码操作硬件。让每个开发者都能够参与其中,体验硬件编程的快乐。将创客的精神带入到JavaScript社区,创造更多的可能。 26 | 27 | 另外,我们近期内联系到了[nodebots.io](http://nodebots.io/)发起者, 同时也是JavaScript全球开发者大会jsconf创始人Chris Williams,他组织过多次全球性的JavaScript大会, 另外也创办了Nodebots, RobotsConf等相关的开源硬件交流活动,他将会帮助对本次nodebots session整个流程进行规划。同时我们还会邀请他本人或者核心团队成员到活动现场提供技术支持! 28 | 29 | *这边活动具体流程我们还在跟对方交流。因为硬件支持这边我们还没有跟你们确定好具体的合作细节,所以希望能够得到你们的支持,我们将会在最快的时间内制定详细的安排。* 30 | 31 | ![http://2014.jsconf.us/img/banner/drones.jpg](http://2014.jsconf.us/img/banner/drones.jpg) 32 | 33 | #### 深JS与硬件合作商空间合作建议 34 | 35 | 方案一: 36 | * 硬件合作商可派讲师做硬件相关开发分享 37 | * 硬件合作商提供30-50套Arduino/tessel/raspberry pi设备作为活动nodebots session的硬件支持 38 | * 硬件合作商将会作为活动唯一硬件赞助商,等同于活动A类赞助商,享有A类赞助商权益(活动会场Banner, 官网logo展示,免费门票等) 39 | * 赞助的硬件设备在活动期间或结束后可作为活动礼品赠送至开发者或折价销售 40 | 41 | 方案二: 42 | * 硬件合作商可派讲师做硬件相关开发分享 43 | * 硬件合作商以折扣价格出售50-100套Arduino/tessel/raspberry pi设备作为活动nodebots session的硬件支持 44 | * 硬件合作商将作为活动唯一硬件赞助商 45 | 46 | 以上活动方案可根据实际情况由双方进行协商。 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## ShenJS nodebots session instruction 2 | 3 | ## Please note: 4 | 5 | As many people really loved working with the mBot for NodeBots, the examples, 6 | drivers and firmware that have been developed have been moved to a new repository 7 | so that it can continue to be developed and improved. Ongoing development 8 | will continue at [MakeBlock Official NodeBots](https://github.com/Makeblock-official/mbot_nodebots). 9 | 10 | 11 | ### Hardware [mbot](http://mblock.cc/) from [makeblock](http://www.makeblock.cc/) 12 | 13 | > mBot is the easiest educational robot for kids to learn programming, Arduino and robotics. 14 | 15 | ![mbot](https://cloud.githubusercontent.com/assets/1183541/7513052/80e6dfc0-f4f4-11e4-94b8-76d3ee166cd2.jpg) 16 | 17 | *Photo from [Andrew Fisher](https://twitter.com/ajfisher)* 18 | 19 | ### Getting started 20 | 21 | Note that 22 | 23 | 1. Install [Arduino IDE](http://arduino.cc) 24 | 2. Install [Makeblock-USB-Driver](https://github.com/Makeblock-official/Makeblock-USB-Driver) Note for Mac users, use the driver included in this repo in the `drivers` folder as this one is signed. **This step will reboot your computer** 25 | 4. [Build the bot](http://www.instructables.com/id/How-to-make-a-mBot-with-Makeblock/) 26 | 5. Install depedencies (I presume you already have nodejs + npm installed.) 27 | 28 | ``` 29 | git clone git@github.com:jsconfcn/nodebots-session.git && cd nodebots-session 30 | npm install 31 | ``` 32 | 33 | 6. Install fimata. Open arduino and navigage to `firmware/mbotFirmata/mbotFirmata.ino` and open it. 34 | 35 | Compile and then upload to the board. 36 | 37 | ## Examples 38 | 39 | Examples are in the examples directory. You can run using `node examples/file.js` like 40 | normal. Information about the examples is below 41 | 42 | ### Motors 43 | 44 | Use `examples/motors.js` this will drive the mbot around using the arrow keys on 45 | your keyboard. You may need to change the details of the directions depending on 46 | how you wired up the motors. 47 | 48 | ### Buzzer 49 | 50 | Use `examples/piezo.js` - this will make your mbot play some tunes. 51 | 52 | ### Obstacle detection 53 | 54 | Use `examples/sonar.js` to detect the distance to an object. You can use this to 55 | stop your robot from running into this. 56 | 57 | ### Button 58 | 59 | Your mbot has a little button that you can use to trigger something maybe. Use 60 | `examples/button.js` to detect the button press and do something with it. 61 | 62 | ### Light Sensor 63 | 64 | You can read the light level near the mbot - maybe you can make your mbot 65 | run away from too much light or move towards more light? Use `examples/light.js` 66 | 67 | ### LEDs 68 | 69 | There are 2 LEDs on the mbot which are RGB LEDs. These are connected in a strip 70 | so you can use node-pixel to control them. An example is `examples\leds.js` 71 | 72 | ### Reflectance sensor 73 | 74 | Under your mbot is a sensor which you can use to detect lines. Look at 75 | `examples\reflectance.js` to see how to get the data. You can detect lines by 76 | getting one of the two sensors to be bright and one to be dark so it can follow 77 | an edge. 78 | 79 | ## 2.4GHz wireless module 80 | 81 | Install using: 82 | 83 | ``` 84 | npm install drivers/node-hid 85 | ``` 86 | 87 | Run example 88 | 89 | ``` 90 | node examples/wifi_motors.js 91 | ``` 92 | 93 | ### [Schedule](https://github.com/jsconfcn/nodebots-session/blob/master/schedule.md) 94 | 95 | ### License 96 | MIT 97 | -------------------------------------------------------------------------------- /drivers/ch341ser_mac.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsconfcn/nodebots-session/60e2806507d95a9679fd1df9de4d29719164da94/drivers/ch341ser_mac.zip -------------------------------------------------------------------------------- /drivers/node-hid/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "hidapi"] 2 | path = hidapi 3 | url = https://github.com/signal11/hidapi.git 4 | -------------------------------------------------------------------------------- /drivers/node-hid/.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build 3 | node_modules 4 | -------------------------------------------------------------------------------- /drivers/node-hid/README.md: -------------------------------------------------------------------------------- 1 | # node-hid - Access USB HID devices from node.js # 2 | 3 | ## Installation 4 | 5 | ### Prerequisites: 6 | 7 | * Mac OS (I use 10.6.8) or Linux (kernel 2.6+) or Windows XP+ 8 | * node.js v0.8 9 | * libudev-dev (Linux only) 10 | * libusb-1.0-0-dev (Ubuntu versions missing `libusb.h` only) 11 | * git 12 | 13 | ### Compile from source on Linux or OSX 14 | 15 | To develop locally you'll need the following commands: 16 | 17 | ``` 18 | git submodule update --init # done automatically on publish, but you'll need it locally 19 | npm install # rebuilds the module 20 | ``` 21 | 22 | ### Compile from source on Windows 23 | 24 | Use node-gyp to compile the extension. 25 | 26 | Please note that Windows support is incomplete and needs some work 27 | to pull it to the same level as on Linux and OSX. See issues #10 28 | and #15 in github for discussion. Pull requests to improve Windows 29 | support would be welcome. 30 | 31 | ## Test it 32 | 33 | In the ```src/``` directory, various JavaScript programs can be found 34 | that talk to specific devices in some way. The ```show-devices.js``` 35 | program can be used to display all HID devices in the system. 36 | 37 | ## How to Use 38 | 39 | ### Load the extension 40 | 41 | ``` 42 | var HID = require('node-hid'); 43 | ``` 44 | 45 | ### Get a list of all HID devices in the system: 46 | 47 | ``` 48 | var devices = HID.devices() 49 | ``` 50 | 51 | devices will contain an array of objects, one for each HID device 52 | available. Of particular interest are the ```vendorId``` and 53 | ```productId```, as they uniquely identify a device, and the 54 | ```path```, which is needed to open a particular device. 55 | 56 | Here is some sample output: 57 | ``` 58 | HID.devices(); 59 | [ { vendorId: 1452, 60 | productId: 595, 61 | path: 'USB_05ac_0253_0x100a148e0', 62 | serialNumber: '', 63 | manufacturer: 'Apple Inc.', 64 | product: 'Apple Internal Keyboard / Trackpad', 65 | release: 280, 66 | interface: -1 }, 67 | { vendorId: 1452, 68 | productId: 595, 69 | path: 'USB_05ac_0253_0x100a14e20', 70 | serialNumber: '', 71 | manufacturer: 'Apple Inc.', 72 | product: 'Apple Internal Keyboard / Trackpad', 73 | release: 280, 74 | interface: -1 }, 75 | 76 | ``` 77 | 78 | ### Opening a device 79 | 80 | Before a device can be read from or written to, it must be opened: 81 | 82 | ``` 83 | var device = new HID.HID(path); 84 | ``` 85 | 86 | ```device``` will contain a handle to the device. The ```path``` can 87 | be determined by a prior HID.devices() call. If an error occurs 88 | opening the device, an exception will be thrown. 89 | 90 | ### Reading from a device 91 | 92 | Reading from a device is performed by registering a "data" event 93 | handler: 94 | 95 | ``` 96 | device.on("data", function(data) {}); 97 | ``` 98 | 99 | You can also listen for errors like this: 100 | 101 | ``` 102 | device.on("error", function(err) {}); 103 | ``` 104 | 105 | All reading is asynchronous. 106 | 107 | ### Writing to a device 108 | 109 | Writing to a device is performed using the write call in a device 110 | handle. All writing is synchronous. 111 | 112 | ``` 113 | device.write([0x00, 0x01, 0x01, 0x05, 0xff, 0xff]); 114 | ``` 115 | 116 | ### Support 117 | 118 | I can only provide limited support, in particular for operating 119 | systems and devices that I don't know. Please use the 120 | [node-hid Google Group](https://groups.google.com/d/forum/node-hid) 121 | for general support inquiries (node-hid@googlegroups.com). 122 | 123 | ## Complete API 124 | 125 | ``` 126 | var device = new HID.HID(path); 127 | ``` 128 | 129 | ### Event: "data" 130 | 131 | - `chunk` - Buffer - the data read from the device 132 | 133 | ### Event: "error" 134 | 135 | - `error` - The error Object emitted 136 | 137 | ### device.write(data) 138 | 139 | - `data` - the data to be synchronously written to the device 140 | 141 | ### device.close() 142 | 143 | Closes the device. Subsequent reads will raise an error. 144 | 145 | ### device.pause() 146 | 147 | Pauses reading and the emission of `data` events. 148 | 149 | ### device.resume() 150 | 151 | This method will cause the HID device to resume emmitting `data` events. 152 | If no listeners are registered for the `data` event, data will be lost. 153 | 154 | When a `data` event is registered for this HID device, this method will 155 | be automatically called. 156 | 157 | ### device.read(callback) 158 | 159 | Low-level function call to initiate an asynchronous read from the device. 160 | `callback` is of the form `callback(err, data)` 161 | -------------------------------------------------------------------------------- /drivers/node-hid/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'variables': { 3 | 'driver%': 'libusb' 4 | }, 5 | 'targets': [ 6 | { 7 | 'target_name': 'hidapi', 8 | 'type': 'static_library', 9 | 'conditions': [ 10 | [ 'OS=="mac"', { 11 | 'sources': [ 'hidapi/mac/hid.c' ], 12 | 'include_dirs+': [ 13 | '/usr/include/libusb-1.0/' 14 | ] 15 | }], 16 | [ 'OS=="linux"', { 17 | 'conditions': [ 18 | [ 'driver=="libusb"', { 19 | 'sources': [ 'hidapi/libusb/hid.c' ], 20 | 'include_dirs+': [ 21 | '/usr/include/libusb-1.0/' 22 | ] 23 | }], 24 | [ 'driver=="hidraw"', { 25 | 'sources': [ 'hidapi/linux/hid.c' ] 26 | }] 27 | ] 28 | }], 29 | [ 'OS=="win"', { 30 | 'sources': [ 'hidapi/windows/hid.c' ], 31 | 'msvs_settings': { 32 | 'VCLinkerTool': { 33 | 'AdditionalDependencies': [ 34 | 'setupapi.lib', 35 | ] 36 | } 37 | } 38 | }] 39 | ], 40 | 'direct_dependent_settings': { 41 | 'include_dirs': [ 42 | 'hidapi/hidapi', 43 | "> $(depfile) 116 | # Add extra rules as in (2). 117 | # We remove slashes and replace spaces with new lines; 118 | # remove blank lines; 119 | # delete the first line and append a colon to the remaining lines. 120 | sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ 121 | grep -v '^$$' |\ 122 | sed -e 1d -e 's|$$|:|' \ 123 | >> $(depfile) 124 | rm $(depfile).raw 125 | endef 126 | 127 | # Command definitions: 128 | # - cmd_foo is the actual command to run; 129 | # - quiet_cmd_foo is the brief-output summary of the command. 130 | 131 | quiet_cmd_cc = CC($(TOOLSET)) $@ 132 | cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< 133 | 134 | quiet_cmd_cxx = CXX($(TOOLSET)) $@ 135 | cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< 136 | 137 | quiet_cmd_objc = CXX($(TOOLSET)) $@ 138 | cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< 139 | 140 | quiet_cmd_objcxx = CXX($(TOOLSET)) $@ 141 | cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< 142 | 143 | # Commands for precompiled header files. 144 | quiet_cmd_pch_c = CXX($(TOOLSET)) $@ 145 | cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< 146 | quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ 147 | cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< 148 | quiet_cmd_pch_m = CXX($(TOOLSET)) $@ 149 | cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< 150 | quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ 151 | cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< 152 | 153 | # gyp-mac-tool is written next to the root Makefile by gyp. 154 | # Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd 155 | # already. 156 | quiet_cmd_mac_tool = MACTOOL $(4) $< 157 | cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" 158 | 159 | quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ 160 | cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) 161 | 162 | quiet_cmd_infoplist = INFOPLIST $@ 163 | cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" 164 | 165 | quiet_cmd_touch = TOUCH $@ 166 | cmd_touch = touch $@ 167 | 168 | quiet_cmd_copy = COPY $@ 169 | # send stderr to /dev/null to ignore messages when linking directories. 170 | cmd_copy = rm -rf "$@" && cp -af "$<" "$@" 171 | 172 | quiet_cmd_alink = LIBTOOL-STATIC $@ 173 | cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^) 174 | 175 | quiet_cmd_link = LINK($(TOOLSET)) $@ 176 | cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) 177 | 178 | quiet_cmd_solink = SOLINK($(TOOLSET)) $@ 179 | cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) 180 | 181 | quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ 182 | cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) 183 | 184 | 185 | # Define an escape_quotes function to escape single quotes. 186 | # This allows us to handle quotes properly as long as we always use 187 | # use single quotes and escape_quotes. 188 | escape_quotes = $(subst ','\'',$(1)) 189 | # This comment is here just to include a ' to unconfuse syntax highlighting. 190 | # Define an escape_vars function to escape '$' variable syntax. 191 | # This allows us to read/write command lines with shell variables (e.g. 192 | # $LD_LIBRARY_PATH), without triggering make substitution. 193 | escape_vars = $(subst $$,$$$$,$(1)) 194 | # Helper that expands to a shell command to echo a string exactly as it is in 195 | # make. This uses printf instead of echo because printf's behaviour with respect 196 | # to escape sequences is more portable than echo's across different shells 197 | # (e.g., dash, bash). 198 | exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' 199 | 200 | # Helper to compare the command we're about to run against the command 201 | # we logged the last time we ran the command. Produces an empty 202 | # string (false) when the commands match. 203 | # Tricky point: Make has no string-equality test function. 204 | # The kernel uses the following, but it seems like it would have false 205 | # positives, where one string reordered its arguments. 206 | # arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ 207 | # $(filter-out $(cmd_$@), $(cmd_$(1)))) 208 | # We instead substitute each for the empty string into the other, and 209 | # say they're equal if both substitutions produce the empty string. 210 | # .d files contain ? instead of spaces, take that into account. 211 | command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ 212 | $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) 213 | 214 | # Helper that is non-empty when a prerequisite changes. 215 | # Normally make does this implicitly, but we force rules to always run 216 | # so we can check their command lines. 217 | # $? -- new prerequisites 218 | # $| -- order-only dependencies 219 | prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) 220 | 221 | # Helper that executes all postbuilds until one fails. 222 | define do_postbuilds 223 | @E=0;\ 224 | for p in $(POSTBUILDS); do\ 225 | eval $$p;\ 226 | E=$$?;\ 227 | if [ $$E -ne 0 ]; then\ 228 | break;\ 229 | fi;\ 230 | done;\ 231 | if [ $$E -ne 0 ]; then\ 232 | rm -rf "$@";\ 233 | exit $$E;\ 234 | fi 235 | endef 236 | 237 | # do_cmd: run a command via the above cmd_foo names, if necessary. 238 | # Should always run for a given target to handle command-line changes. 239 | # Second argument, if non-zero, makes it do asm/C/C++ dependency munging. 240 | # Third argument, if non-zero, makes it do POSTBUILDS processing. 241 | # Note: We intentionally do NOT call dirx for depfile, since it contains ? for 242 | # spaces already and dirx strips the ? characters. 243 | define do_cmd 244 | $(if $(or $(command_changed),$(prereq_changed)), 245 | @$(call exact_echo, $($(quiet)cmd_$(1))) 246 | @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" 247 | $(if $(findstring flock,$(word 2,$(cmd_$1))), 248 | @$(cmd_$(1)) 249 | @echo " $(quiet_cmd_$(1)): Finished", 250 | @$(cmd_$(1)) 251 | ) 252 | @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) 253 | @$(if $(2),$(fixup_dep)) 254 | $(if $(and $(3), $(POSTBUILDS)), 255 | $(call do_postbuilds) 256 | ) 257 | ) 258 | endef 259 | 260 | # Declare the "all" target first so it is the default, 261 | # even though we don't have the deps yet. 262 | .PHONY: all 263 | all: 264 | 265 | # make looks for ways to re-generate included makefiles, but in our case, we 266 | # don't have a direct way. Explicitly telling make that it has nothing to do 267 | # for them makes it go faster. 268 | %.d: ; 269 | 270 | # Use FORCE_DO_CMD to force a target to run. Should be coupled with 271 | # do_cmd. 272 | .PHONY: FORCE_DO_CMD 273 | FORCE_DO_CMD: 274 | 275 | TOOLSET := target 276 | # Suffix rules, putting all outputs into $(obj). 277 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD 278 | @$(call do_cmd,cc,1) 279 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD 280 | @$(call do_cmd,cxx,1) 281 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD 282 | @$(call do_cmd,cxx,1) 283 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD 284 | @$(call do_cmd,cxx,1) 285 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD 286 | @$(call do_cmd,objc,1) 287 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD 288 | @$(call do_cmd,objcxx,1) 289 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD 290 | @$(call do_cmd,cc,1) 291 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD 292 | @$(call do_cmd,cc,1) 293 | 294 | # Try building from generated source, too. 295 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD 296 | @$(call do_cmd,cc,1) 297 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD 298 | @$(call do_cmd,cxx,1) 299 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD 300 | @$(call do_cmd,cxx,1) 301 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD 302 | @$(call do_cmd,cxx,1) 303 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD 304 | @$(call do_cmd,objc,1) 305 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD 306 | @$(call do_cmd,objcxx,1) 307 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD 308 | @$(call do_cmd,cc,1) 309 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD 310 | @$(call do_cmd,cc,1) 311 | 312 | $(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD 313 | @$(call do_cmd,cc,1) 314 | $(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD 315 | @$(call do_cmd,cxx,1) 316 | $(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD 317 | @$(call do_cmd,cxx,1) 318 | $(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD 319 | @$(call do_cmd,cxx,1) 320 | $(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD 321 | @$(call do_cmd,objc,1) 322 | $(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD 323 | @$(call do_cmd,objcxx,1) 324 | $(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD 325 | @$(call do_cmd,cc,1) 326 | $(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD 327 | @$(call do_cmd,cc,1) 328 | 329 | 330 | ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ 331 | $(findstring $(join ^,$(prefix)),\ 332 | $(join ^,HID.target.mk)))),) 333 | include HID.target.mk 334 | endif 335 | ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ 336 | $(findstring $(join ^,$(prefix)),\ 337 | $(join ^,hidapi.target.mk)))),) 338 | include hidapi.target.mk 339 | endif 340 | 341 | quiet_cmd_regen_makefile = ACTION Regenerating $@ 342 | cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/ajfisher/dev/nodebots-session/drivers/node-hid/build/config.gypi -I/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/ajfisher/.node-gyp/0.12.2/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/ajfisher/.node-gyp/0.12.2" "-Dmodule_root_dir=/Users/ajfisher/dev/nodebots-session/drivers/node-hid" binding.gyp 343 | Makefile: $(srcdir)/../../../../.node-gyp/0.12.2/common.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi 344 | $(call do_cmd,regen_makefile) 345 | 346 | # "all" is a concatenation of the "all" targets from all the included 347 | # sub-makefiles. This is just here to clarify. 348 | all: 349 | 350 | # Add in dependency-tracking rules. $(all_deps) is the list of every single 351 | # target in our tree. Only consider the ones with .d (dependency) info: 352 | d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) 353 | ifneq ($(d_files),) 354 | include $(d_files) 355 | endif 356 | -------------------------------------------------------------------------------- /drivers/node-hid/build/Release/.deps/Release/HID.node.d: -------------------------------------------------------------------------------- 1 | cmd_Release/HID.node := ./gyp-mac-tool flock ./Release/linker.lock c++ -bundle -framework IOKit -framework CoreFoundation -Wl,-search_paths_first -mmacosx-version-min=10.5 -arch x86_64 -L./Release -o Release/HID.node Release/obj.target/HID/src/HID.o Release/hidapi.a -undefined dynamic_lookup 2 | -------------------------------------------------------------------------------- /drivers/node-hid/build/Release/.deps/Release/hidapi.a.d: -------------------------------------------------------------------------------- 1 | cmd_Release/hidapi.a := rm -f Release/hidapi.a && ./gyp-mac-tool filter-libtool libtool -static -o Release/hidapi.a Release/obj.target/hidapi/hidapi/mac/hid.o 2 | -------------------------------------------------------------------------------- /drivers/node-hid/build/Release/.deps/Release/obj.target/HID/src/HID.o.d: -------------------------------------------------------------------------------- 1 | cmd_Release/obj.target/HID/src/HID.o := c++ '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/Users/ajfisher/.node-gyp/0.12.2/src -I/Users/ajfisher/.node-gyp/0.12.2/deps/uv/include -I/Users/ajfisher/.node-gyp/0.12.2/deps/v8/include -I../hidapi/hidapi -I../node_modules/nan -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-rtti -fno-threadsafe-statics -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/HID/src/HID.o.d.raw -c -o Release/obj.target/HID/src/HID.o ../src/HID.cc 2 | Release/obj.target/HID/src/HID.o: ../src/HID.cc \ 3 | /Users/ajfisher/.node-gyp/0.12.2/deps/v8/include/v8.h \ 4 | /Users/ajfisher/.node-gyp/0.12.2/deps/v8/include/v8stdint.h \ 5 | /Users/ajfisher/.node-gyp/0.12.2/deps/v8/include/v8config.h \ 6 | /Users/ajfisher/.node-gyp/0.12.2/src/node.h \ 7 | /Users/ajfisher/.node-gyp/0.12.2/src/node_version.h \ 8 | /Users/ajfisher/.node-gyp/0.12.2/src/node_buffer.h \ 9 | /Users/ajfisher/.node-gyp/0.12.2/src/smalloc.h \ 10 | ../hidapi/hidapi/hidapi.h ../node_modules/nan/nan.h \ 11 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv.h \ 12 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv-errno.h \ 13 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv-version.h \ 14 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv-unix.h \ 15 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv-threadpool.h \ 16 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv-darwin.h \ 17 | /Users/ajfisher/.node-gyp/0.12.2/src/node_object_wrap.h \ 18 | ../node_modules/nan/nan_new.h \ 19 | ../node_modules/nan/nan_implementation_12_inl.h 20 | ../src/HID.cc: 21 | /Users/ajfisher/.node-gyp/0.12.2/deps/v8/include/v8.h: 22 | /Users/ajfisher/.node-gyp/0.12.2/deps/v8/include/v8stdint.h: 23 | /Users/ajfisher/.node-gyp/0.12.2/deps/v8/include/v8config.h: 24 | /Users/ajfisher/.node-gyp/0.12.2/src/node.h: 25 | /Users/ajfisher/.node-gyp/0.12.2/src/node_version.h: 26 | /Users/ajfisher/.node-gyp/0.12.2/src/node_buffer.h: 27 | /Users/ajfisher/.node-gyp/0.12.2/src/smalloc.h: 28 | ../hidapi/hidapi/hidapi.h: 29 | ../node_modules/nan/nan.h: 30 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv.h: 31 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv-errno.h: 32 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv-version.h: 33 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv-unix.h: 34 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv-threadpool.h: 35 | /Users/ajfisher/.node-gyp/0.12.2/deps/uv/include/uv-darwin.h: 36 | /Users/ajfisher/.node-gyp/0.12.2/src/node_object_wrap.h: 37 | ../node_modules/nan/nan_new.h: 38 | ../node_modules/nan/nan_implementation_12_inl.h: 39 | -------------------------------------------------------------------------------- /drivers/node-hid/build/Release/.deps/Release/obj.target/hidapi/hidapi/mac/hid.o.d: -------------------------------------------------------------------------------- 1 | cmd_Release/obj.target/hidapi/hidapi/mac/hid.o := cc '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' -I/Users/ajfisher/.node-gyp/0.12.2/src -I/Users/ajfisher/.node-gyp/0.12.2/deps/uv/include -I/Users/ajfisher/.node-gyp/0.12.2/deps/v8/include -I/usr/include/libusb-1.0 -I../hidapi/hidapi -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/hidapi/hidapi/mac/hid.o.d.raw -c -o Release/obj.target/hidapi/hidapi/mac/hid.o ../hidapi/mac/hid.c 2 | Release/obj.target/hidapi/hidapi/mac/hid.o: ../hidapi/mac/hid.c \ 3 | ../hidapi/hidapi/hidapi.h 4 | ../hidapi/mac/hid.c: 5 | ../hidapi/hidapi/hidapi.h: 6 | -------------------------------------------------------------------------------- /drivers/node-hid/build/Release/HID.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsconfcn/nodebots-session/60e2806507d95a9679fd1df9de4d29719164da94/drivers/node-hid/build/Release/HID.node -------------------------------------------------------------------------------- /drivers/node-hid/build/Release/hidapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsconfcn/nodebots-session/60e2806507d95a9679fd1df9de4d29719164da94/drivers/node-hid/build/Release/hidapi.a -------------------------------------------------------------------------------- /drivers/node-hid/build/Release/linker.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsconfcn/nodebots-session/60e2806507d95a9679fd1df9de4d29719164da94/drivers/node-hid/build/Release/linker.lock -------------------------------------------------------------------------------- /drivers/node-hid/build/Release/obj.target/HID/src/HID.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsconfcn/nodebots-session/60e2806507d95a9679fd1df9de4d29719164da94/drivers/node-hid/build/Release/obj.target/HID/src/HID.o -------------------------------------------------------------------------------- /drivers/node-hid/build/Release/obj.target/hidapi/hidapi/mac/hid.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsconfcn/nodebots-session/60e2806507d95a9679fd1df9de4d29719164da94/drivers/node-hid/build/Release/obj.target/hidapi/hidapi/mac/hid.o -------------------------------------------------------------------------------- /drivers/node-hid/build/binding.Makefile: -------------------------------------------------------------------------------- 1 | # This file is generated by gyp; do not edit. 2 | 3 | export builddir_name ?= ./build/. 4 | .PHONY: all 5 | all: 6 | $(MAKE) hidapi HID 7 | -------------------------------------------------------------------------------- /drivers/node-hid/build/config.gypi: -------------------------------------------------------------------------------- 1 | # Do not edit. File was generated by node-gyp's "configure" step 2 | { 3 | "target_defaults": { 4 | "cflags": [], 5 | "default_configuration": "Release", 6 | "defines": [], 7 | "include_dirs": [], 8 | "libraries": [] 9 | }, 10 | "variables": { 11 | "clang": 1, 12 | "host_arch": "x64", 13 | "icu_small": "false", 14 | "node_install_npm": "false", 15 | "node_prefix": "/usr/local/Cellar/node/0.12.2_1", 16 | "node_shared_cares": "false", 17 | "node_shared_http_parser": "false", 18 | "node_shared_libuv": "false", 19 | "node_shared_openssl": "false", 20 | "node_shared_v8": "false", 21 | "node_shared_zlib": "false", 22 | "node_tag": "", 23 | "node_use_dtrace": "true", 24 | "node_use_etw": "false", 25 | "node_use_mdb": "false", 26 | "node_use_openssl": "true", 27 | "node_use_perfctr": "false", 28 | "openssl_no_asm": 0, 29 | "python": "/usr/local/opt/python/bin/python2.7", 30 | "target_arch": "x64", 31 | "uv_library": "static_library", 32 | "uv_parent_path": "/deps/uv/", 33 | "uv_use_dtrace": "true", 34 | "v8_enable_gdbjit": 0, 35 | "v8_enable_i18n_support": 0, 36 | "v8_no_strict_aliasing": 1, 37 | "v8_optimized_debug": 0, 38 | "v8_random_seed": 0, 39 | "v8_use_snapshot": "true", 40 | "want_separate_host_toolset": 0, 41 | "nodedir": "/Users/ajfisher/.node-gyp/0.12.2", 42 | "copy_dev_lib": "true", 43 | "standalone_static_library": 1, 44 | "save_dev": "", 45 | "browser": "", 46 | "viewer": "man", 47 | "rollback": "true", 48 | "usage": "", 49 | "__registry_npmjs_org___authToken": "0a57abcd-22bd-489e-b123-63d5e50c25c2", 50 | "globalignorefile": "/usr/local/etc/npmignore", 51 | "init_author_url": "", 52 | "shell": "/bin/bash", 53 | "parseable": "", 54 | "shrinkwrap": "true", 55 | "init_license": "ISC", 56 | "if_present": "", 57 | "cache_max": "Infinity", 58 | "init_author_email": "", 59 | "sign_git_tag": "", 60 | "cert": "", 61 | "git_tag_version": "true", 62 | "local_address": "", 63 | "long": "", 64 | "fetch_retries": "2", 65 | "npat": "", 66 | "registry": "https://registry.npmjs.org/", 67 | "key": "", 68 | "message": "%s", 69 | "versions": "", 70 | "globalconfig": "/usr/local/etc/npmrc", 71 | "always_auth": "", 72 | "spin": "true", 73 | "cache_lock_retries": "10", 74 | "cafile": "", 75 | "heading": "npm", 76 | "fetch_retry_mintimeout": "10000", 77 | "proprietary_attribs": "true", 78 | "access": "", 79 | "json": "", 80 | "description": "true", 81 | "engine_strict": "", 82 | "https_proxy": "", 83 | "init_module": "/Users/ajfisher/.npm-init.js", 84 | "userconfig": "/Users/ajfisher/.npmrc", 85 | "node_version": "0.12.2", 86 | "user": "", 87 | "editor": "vi", 88 | "save": "", 89 | "tag": "latest", 90 | "global": "", 91 | "optional": "true", 92 | "bin_links": "true", 93 | "force": "", 94 | "searchopts": "", 95 | "depth": "Infinity", 96 | "rebuild_bundle": "true", 97 | "searchsort": "name", 98 | "unicode": "true", 99 | "fetch_retry_maxtimeout": "60000", 100 | "ca": "", 101 | "save_prefix": "^", 102 | "strict_ssl": "true", 103 | "tag_version_prefix": "v", 104 | "dev": "", 105 | "fetch_retry_factor": "10", 106 | "group": "20", 107 | "save_exact": "", 108 | "cache_lock_stale": "60000", 109 | "version": "", 110 | "cache_min": "10", 111 | "cache": "/Users/ajfisher/.npm", 112 | "searchexclude": "", 113 | "color": "true", 114 | "save_optional": "", 115 | "user_agent": "npm/2.10.0 node/v0.12.2 darwin x64", 116 | "ignore_scripts": "", 117 | "cache_lock_wait": "10000", 118 | "production": "", 119 | "save_bundle": "", 120 | "init_version": "1.0.0", 121 | "umask": "0022", 122 | "git": "git", 123 | "init_author_name": "", 124 | "scope": "", 125 | "onload_script": "", 126 | "tmp": "/var/folders/bd/369p_cm53tsb7yzzdmppbnw80000gn/T", 127 | "unsafe_perm": "true", 128 | "prefix": "/usr/local", 129 | "link": "" 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /drivers/node-hid/build/hidapi.target.mk: -------------------------------------------------------------------------------- 1 | # This file is generated by gyp; do not edit. 2 | 3 | TOOLSET := target 4 | TARGET := hidapi 5 | DEFS_Debug := \ 6 | '-D_DARWIN_USE_64_BIT_INODE=1' \ 7 | '-D_LARGEFILE_SOURCE' \ 8 | '-D_FILE_OFFSET_BITS=64' \ 9 | '-DDEBUG' \ 10 | '-D_DEBUG' 11 | 12 | # Flags passed to all source files. 13 | CFLAGS_Debug := \ 14 | -O0 \ 15 | -gdwarf-2 \ 16 | -mmacosx-version-min=10.5 \ 17 | -arch x86_64 \ 18 | -Wall \ 19 | -Wendif-labels \ 20 | -W \ 21 | -Wno-unused-parameter 22 | 23 | # Flags passed to only C files. 24 | CFLAGS_C_Debug := \ 25 | -fno-strict-aliasing 26 | 27 | # Flags passed to only C++ files. 28 | CFLAGS_CC_Debug := \ 29 | -fno-rtti \ 30 | -fno-exceptions \ 31 | -fno-threadsafe-statics \ 32 | -fno-strict-aliasing 33 | 34 | # Flags passed to only ObjC files. 35 | CFLAGS_OBJC_Debug := 36 | 37 | # Flags passed to only ObjC++ files. 38 | CFLAGS_OBJCC_Debug := 39 | 40 | INCS_Debug := \ 41 | -I/Users/ajfisher/.node-gyp/0.12.2/src \ 42 | -I/Users/ajfisher/.node-gyp/0.12.2/deps/uv/include \ 43 | -I/Users/ajfisher/.node-gyp/0.12.2/deps/v8/include \ 44 | -I/usr/include/libusb-1.0 \ 45 | -I$(srcdir)/hidapi/hidapi 46 | 47 | DEFS_Release := \ 48 | '-D_DARWIN_USE_64_BIT_INODE=1' \ 49 | '-D_LARGEFILE_SOURCE' \ 50 | '-D_FILE_OFFSET_BITS=64' 51 | 52 | # Flags passed to all source files. 53 | CFLAGS_Release := \ 54 | -Os \ 55 | -gdwarf-2 \ 56 | -mmacosx-version-min=10.5 \ 57 | -arch x86_64 \ 58 | -Wall \ 59 | -Wendif-labels \ 60 | -W \ 61 | -Wno-unused-parameter 62 | 63 | # Flags passed to only C files. 64 | CFLAGS_C_Release := \ 65 | -fno-strict-aliasing 66 | 67 | # Flags passed to only C++ files. 68 | CFLAGS_CC_Release := \ 69 | -fno-rtti \ 70 | -fno-exceptions \ 71 | -fno-threadsafe-statics \ 72 | -fno-strict-aliasing 73 | 74 | # Flags passed to only ObjC files. 75 | CFLAGS_OBJC_Release := 76 | 77 | # Flags passed to only ObjC++ files. 78 | CFLAGS_OBJCC_Release := 79 | 80 | INCS_Release := \ 81 | -I/Users/ajfisher/.node-gyp/0.12.2/src \ 82 | -I/Users/ajfisher/.node-gyp/0.12.2/deps/uv/include \ 83 | -I/Users/ajfisher/.node-gyp/0.12.2/deps/v8/include \ 84 | -I/usr/include/libusb-1.0 \ 85 | -I$(srcdir)/hidapi/hidapi 86 | 87 | OBJS := \ 88 | $(obj).target/$(TARGET)/hidapi/mac/hid.o 89 | 90 | # Add to the list of files we specially track dependencies for. 91 | all_deps += $(OBJS) 92 | 93 | # CFLAGS et al overrides must be target-local. 94 | # See "Target-specific Variable Values" in the GNU Make manual. 95 | $(OBJS): TOOLSET := $(TOOLSET) 96 | $(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) 97 | $(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) 98 | $(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) 99 | $(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) 100 | 101 | # Suffix rules, putting all outputs into $(obj). 102 | 103 | $(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD 104 | @$(call do_cmd,cc,1) 105 | 106 | # Try building from generated source, too. 107 | 108 | $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD 109 | @$(call do_cmd,cc,1) 110 | 111 | $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD 112 | @$(call do_cmd,cc,1) 113 | 114 | # End of this set of suffix rules 115 | ### Rules for final target. 116 | LDFLAGS_Debug := \ 117 | -mmacosx-version-min=10.5 \ 118 | -arch x86_64 \ 119 | -L$(builddir) 120 | 121 | LIBTOOLFLAGS_Debug := 122 | 123 | LDFLAGS_Release := \ 124 | -mmacosx-version-min=10.5 \ 125 | -arch x86_64 \ 126 | -L$(builddir) 127 | 128 | LIBTOOLFLAGS_Release := 129 | 130 | LIBS := \ 131 | -undefined dynamic_lookup 132 | 133 | $(builddir)/hidapi.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) 134 | $(builddir)/hidapi.a: LIBS := $(LIBS) 135 | $(builddir)/hidapi.a: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE)) 136 | $(builddir)/hidapi.a: TOOLSET := $(TOOLSET) 137 | $(builddir)/hidapi.a: $(OBJS) FORCE_DO_CMD 138 | $(call do_cmd,alink) 139 | 140 | all_deps += $(builddir)/hidapi.a 141 | # Add target alias 142 | .PHONY: hidapi 143 | hidapi: $(builddir)/hidapi.a 144 | 145 | # Add target alias to "all" target. 146 | .PHONY: all 147 | all: hidapi 148 | 149 | # Add target alias 150 | .PHONY: hidapi 151 | hidapi: $(builddir)/hidapi.a 152 | 153 | # Short alias for building this static library. 154 | .PHONY: hidapi.a 155 | hidapi.a: $(builddir)/hidapi.a 156 | 157 | # Add static library to "all" target. 158 | .PHONY: all 159 | all: $(builddir)/hidapi.a 160 | 161 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.sln text eol=crlf 4 | *.vcproj text eol=crlf 5 | 6 | bootstrap text eol=lf 7 | configure.ac text eol=lf 8 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/.npmignore: -------------------------------------------------------------------------------- 1 | 2 | # Autotools-added generated files 3 | Makefile.in 4 | aclocal.m4 5 | autom4te.cache/ 6 | config.* 7 | configure 8 | depcomp 9 | install-sh 10 | libusb/Makefile.in 11 | linux/Makefile.in 12 | ltmain.sh 13 | mac/Makefile.in 14 | missing 15 | testgui/Makefile.in 16 | windows/Makefile.in 17 | 18 | Makefile 19 | stamp-h1 20 | libtool 21 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/AUTHORS.txt: -------------------------------------------------------------------------------- 1 | 2 | HIDAPI Authors: 3 | 4 | Alan Ott : 5 | Original Author and Maintainer 6 | Linux, Windows, and Mac implementations 7 | 8 | Ludovic Rousseau : 9 | Formatting for Doxygen documentation 10 | Bug fixes 11 | Correctness fixes 12 | 13 | 14 | For a comprehensive list of contributions, see the commit list at github: 15 | http://github.com/signal11/hidapi/commits/master 16 | 17 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/HACKING.txt: -------------------------------------------------------------------------------- 1 | This file is mostly for the maintainer. 2 | 3 | 1. Build hidapi.dll 4 | 2. Build hidtest.exe in DEBUG and RELEASE 5 | 3. Commit all 6 | 7 | 4. Run the Following 8 | export VERSION=0.1.0 9 | export TAG_NAME=hidapi-$VERSION 10 | git tag $TAG_NAME 11 | git archive --format zip --prefix $TAG_NAME/ $TAG_NAME >../$TAG_NAME.zip 12 | 5. Test the zip file. 13 | 6. Run the following: 14 | git push origin $TAG_NAME 15 | 16 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/LICENSE-bsd.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Alan Ott, Signal 11 Software 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Signal 11 Software nor the names of its 13 | contributors may be used to endorse or promote products derived from 14 | this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/LICENSE-orig.txt: -------------------------------------------------------------------------------- 1 | HIDAPI - Multi-Platform library for 2 | communication with HID devices. 3 | 4 | Copyright 2009, Alan Ott, Signal 11 Software. 5 | All Rights Reserved. 6 | 7 | This software may be used by anyone for any reason so 8 | long as the copyright notice in the source files 9 | remains intact. 10 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/LICENSE.txt: -------------------------------------------------------------------------------- 1 | HIDAPI can be used under one of three licenses. 2 | 3 | 1. The GNU General Public License, version 3.0, in LICENSE-gpl3.txt 4 | 2. A BSD-Style License, in LICENSE-bsd.txt. 5 | 3. The more liberal original HIDAPI license. LICENSE-orig.txt 6 | 7 | The license chosen is at the discretion of the user of HIDAPI. For example: 8 | 1. An author of GPL software would likely use HIDAPI under the terms of the 9 | GPL. 10 | 11 | 2. An author of commercial closed-source software would likely use HIDAPI 12 | under the terms of the BSD-style license or the original HIDAPI license. 13 | 14 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | ACLOCAL_AMFLAGS = -I m4 3 | 4 | if OS_FREEBSD 5 | pkgconfigdir=$(prefix)/libdata/pkgconfig 6 | else 7 | pkgconfigdir=$(libdir)/pkgconfig 8 | endif 9 | 10 | if OS_LINUX 11 | pkgconfig_DATA=pc/hidapi-hidraw.pc pc/hidapi-libusb.pc 12 | else 13 | pkgconfig_DATA=pc/hidapi.pc 14 | endif 15 | 16 | SUBDIRS= 17 | 18 | if OS_LINUX 19 | SUBDIRS += linux libusb 20 | endif 21 | 22 | if OS_DARWIN 23 | SUBDIRS += mac 24 | endif 25 | 26 | if OS_FREEBSD 27 | SUBDIRS += libusb 28 | endif 29 | 30 | if OS_KFREEBSD 31 | SUBDIRS += libusb 32 | endif 33 | 34 | if OS_WINDOWS 35 | SUBDIRS += windows 36 | endif 37 | 38 | SUBDIRS += hidtest 39 | 40 | if BUILD_TESTGUI 41 | SUBDIRS += testgui 42 | endif 43 | 44 | EXTRA_DIST = udev doxygen 45 | 46 | dist_doc_DATA = \ 47 | README.txt \ 48 | AUTHORS.txt \ 49 | LICENSE-bsd.txt \ 50 | LICENSE-gpl3.txt \ 51 | LICENSE-orig.txt \ 52 | LICENSE.txt 53 | 54 | SCMCLEAN_TARGETS= \ 55 | aclocal.m4 \ 56 | config.guess \ 57 | config.sub \ 58 | configure \ 59 | config.h.in \ 60 | depcomp \ 61 | install-sh \ 62 | ltmain.sh \ 63 | missing \ 64 | mac/Makefile.in \ 65 | testgui/Makefile.in \ 66 | libusb/Makefile.in \ 67 | Makefile.in \ 68 | linux/Makefile.in \ 69 | windows/Makefile.in \ 70 | m4/libtool.m4 \ 71 | m4/lt~obsolete.m4 \ 72 | m4/ltoptions.m4 \ 73 | m4/ltsugar.m4 \ 74 | m4/ltversion.m4 75 | 76 | SCMCLEAN_DIR_TARGETS = \ 77 | autom4te.cache 78 | 79 | scm-clean: distclean 80 | rm -f $(SCMCLEAN_TARGETS) 81 | rm -Rf $(SCMCLEAN_DIR_TARGETS) 82 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/README.txt: -------------------------------------------------------------------------------- 1 | HIDAPI library for Windows, Linux, FreeBSD and Mac OS X 2 | ========================================================= 3 | 4 | About 5 | ====== 6 | 7 | HIDAPI is a multi-platform library which allows an application to interface 8 | with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and Mac 9 | OS X. HIDAPI can be either built as a shared library (.so or .dll) or 10 | can be embedded directly into a target application by adding a single source 11 | file (per platform) and a single header. 12 | 13 | HIDAPI has four back-ends: 14 | * Windows (using hid.dll) 15 | * Linux/hidraw (using the Kernel's hidraw driver) 16 | * Linux/libusb (using libusb-1.0) 17 | * FreeBSD (using libusb-1.0) 18 | * Mac (using IOHidManager) 19 | 20 | On Linux, either the hidraw or the libusb back-end can be used. There are 21 | tradeoffs, and the functionality supported is slightly different. 22 | 23 | Linux/hidraw (linux/hid.c): 24 | This back-end uses the hidraw interface in the Linux kernel. While this 25 | back-end will support both USB and Bluetooth, it has some limitations on 26 | kernels prior to 2.6.39, including the inability to send or receive feature 27 | reports. In addition, it will only communicate with devices which have 28 | hidraw nodes associated with them. Keyboards, mice, and some other devices 29 | which are blacklisted from having hidraw nodes will not work. Fortunately, 30 | for nearly all the uses of hidraw, this is not a problem. 31 | 32 | Linux/FreeBSD/libusb (libusb/hid-libusb.c): 33 | This back-end uses libusb-1.0 to communicate directly to a USB device. This 34 | back-end will of course not work with Bluetooth devices. 35 | 36 | HIDAPI also comes with a Test GUI. The Test GUI is cross-platform and uses 37 | Fox Toolkit (http://www.fox-toolkit.org). It will build on every platform 38 | which HIDAPI supports. Since it relies on a 3rd party library, building it 39 | is optional but recommended because it is so useful when debugging hardware. 40 | 41 | What Does the API Look Like? 42 | ============================= 43 | The API provides the the most commonly used HID functions including sending 44 | and receiving of input, output, and feature reports. The sample program, 45 | which communicates with a heavily hacked up version of the Microchip USB 46 | Generic HID sample looks like this (with error checking removed for 47 | simplicity): 48 | 49 | #ifdef WIN32 50 | #include 51 | #endif 52 | #include 53 | #include 54 | #include "hidapi.h" 55 | 56 | #define MAX_STR 255 57 | 58 | int main(int argc, char* argv[]) 59 | { 60 | int res; 61 | unsigned char buf[65]; 62 | wchar_t wstr[MAX_STR]; 63 | hid_device *handle; 64 | int i; 65 | 66 | // Initialize the hidapi library 67 | res = hid_init(); 68 | 69 | // Open the device using the VID, PID, 70 | // and optionally the Serial number. 71 | handle = hid_open(0x4d8, 0x3f, NULL); 72 | 73 | // Read the Manufacturer String 74 | res = hid_get_manufacturer_string(handle, wstr, MAX_STR); 75 | wprintf(L"Manufacturer String: %s\n", wstr); 76 | 77 | // Read the Product String 78 | res = hid_get_product_string(handle, wstr, MAX_STR); 79 | wprintf(L"Product String: %s\n", wstr); 80 | 81 | // Read the Serial Number String 82 | res = hid_get_serial_number_string(handle, wstr, MAX_STR); 83 | wprintf(L"Serial Number String: (%d) %s\n", wstr[0], wstr); 84 | 85 | // Read Indexed String 1 86 | res = hid_get_indexed_string(handle, 1, wstr, MAX_STR); 87 | wprintf(L"Indexed String 1: %s\n", wstr); 88 | 89 | // Toggle LED (cmd 0x80). The first byte is the report number (0x0). 90 | buf[0] = 0x0; 91 | buf[1] = 0x80; 92 | res = hid_write(handle, buf, 65); 93 | 94 | // Request state (cmd 0x81). The first byte is the report number (0x0). 95 | buf[0] = 0x0; 96 | buf[1] = 0x81; 97 | res = hid_write(handle, buf, 65); 98 | 99 | // Read requested state 100 | res = hid_read(handle, buf, 65); 101 | 102 | // Print out the returned buffer. 103 | for (i = 0; i < 4; i++) 104 | printf("buf[%d]: %d\n", i, buf[i]); 105 | 106 | // Finalize the hidapi library 107 | res = hid_exit(); 108 | 109 | return 0; 110 | } 111 | 112 | If you have your own simple test programs which communicate with standard 113 | hardware development boards (such as those from Microchip, TI, Atmel, 114 | FreeScale and others), please consider sending me something like the above 115 | for inclusion into the HIDAPI source. This will help others who have the 116 | same hardware as you do. 117 | 118 | License 119 | ======== 120 | HIDAPI may be used by one of three licenses as outlined in LICENSE.txt. 121 | 122 | Download 123 | ========= 124 | HIDAPI can be downloaded from github 125 | git clone git://github.com/signal11/hidapi.git 126 | 127 | Build Instructions 128 | =================== 129 | 130 | This section is long. Don't be put off by this. It's not long because it's 131 | complicated to build HIDAPI; it's quite the opposite. This section is long 132 | because of the flexibility of HIDAPI and the large number of ways in which 133 | it can be built and used. You will likely pick a single build method. 134 | 135 | HIDAPI can be built in several different ways. If you elect to build a 136 | shared library, you will need to build it from the HIDAPI source 137 | distribution. If you choose instead to embed HIDAPI directly into your 138 | application, you can skip the building and look at the provided platform 139 | Makefiles for guidance. These platform Makefiles are located in linux/ 140 | libusb/ mac/ and windows/ and are called Makefile-manual. In addition, 141 | Visual Studio projects are provided. Even if you're going to embed HIDAPI 142 | into your project, it is still beneficial to build the example programs. 143 | 144 | 145 | Prerequisites: 146 | --------------- 147 | 148 | Linux: 149 | ------- 150 | On Linux, you will need to install development packages for libudev, 151 | libusb and optionally Fox-toolkit (for the test GUI). On 152 | Debian/Ubuntu systems these can be installed by running: 153 | sudo apt-get install libudev-dev libusb-1.0-0-dev libfox-1.6-dev 154 | 155 | If you downloaded the source directly from the git repository (using 156 | git clone), you'll need Autotools: 157 | sudo apt-get install autotools-dev autoconf automake libtool 158 | 159 | FreeBSD: 160 | --------- 161 | On FreeBSD you will need to install GNU make, libiconv, and 162 | optionally Fox-Toolkit (for the test GUI). This is done by running 163 | the following: 164 | pkg_add -r gmake libiconv fox16 165 | 166 | If you downloaded the source directly from the git repository (using 167 | git clone), you'll need Autotools: 168 | pkg_add -r autotools 169 | 170 | Mac: 171 | ----- 172 | On Mac, you will need to install Fox-Toolkit if you wish to build 173 | the Test GUI. There are two ways to do this, and each has a slight 174 | complication. Which method you use depends on your use case. 175 | 176 | If you wish to build the Test GUI just for your own testing on your 177 | own computer, then the easiest method is to install Fox-Toolkit 178 | using ports: 179 | sudo port install fox 180 | 181 | If you wish to build the TestGUI app bundle to redistribute to 182 | others, you will need to install Fox-toolkit from source. This is 183 | because the version of fox that gets installed using ports uses the 184 | ports X11 libraries which are not compatible with the Apple X11 185 | libraries. If you install Fox with ports and then try to distribute 186 | your built app bundle, it will simply fail to run on other systems. 187 | To install Fox-Toolkit manually, download the source package from 188 | http://www.fox-toolkit.org, extract it, and run the following from 189 | within the extracted source: 190 | ./configure && make && make install 191 | 192 | Windows: 193 | --------- 194 | On Windows, if you want to build the test GUI, you will need to get 195 | the hidapi-externals.zip package from the download site. This 196 | contains pre-built binaries for Fox-toolkit. Extract 197 | hidapi-externals.zip just outside of hidapi, so that 198 | hidapi-externals and hidapi are on the same level, as shown: 199 | 200 | Parent_Folder 201 | | 202 | +hidapi 203 | +hidapi-externals 204 | 205 | Again, this step is not required if you do not wish to build the 206 | test GUI. 207 | 208 | 209 | Building HIDAPI into a shared library on Unix Platforms: 210 | --------------------------------------------------------- 211 | 212 | On Unix-like systems such as Linux, FreeBSD, Mac, and even Windows, using 213 | Mingw or Cygwin, the easiest way to build a standard system-installed shared 214 | library is to use the GNU Autotools build system. If you checked out the 215 | source from the git repository, run the following: 216 | 217 | ./bootstrap 218 | ./configure 219 | make 220 | make install <----- as root, or using sudo 221 | 222 | If you downloaded a source package (ie: if you did not run git clone), you 223 | can skip the ./bootstrap step. 224 | 225 | ./configure can take several arguments which control the build. The two most 226 | likely to be used are: 227 | --enable-testgui 228 | Enable build of the Test GUI. This requires Fox toolkit to 229 | be installed. Instructions for installing Fox-Toolkit on 230 | each platform are in the Prerequisites section above. 231 | 232 | --prefix=/usr 233 | Specify where you want the output headers and libraries to 234 | be installed. The example above will put the headers in 235 | /usr/include and the binaries in /usr/lib. The default is to 236 | install into /usr/local which is fine on most systems. 237 | 238 | Building the manual way on Unix platforms: 239 | ------------------------------------------- 240 | 241 | Manual Makefiles are provided mostly to give the user and idea what it takes 242 | to build a program which embeds HIDAPI directly inside of it. These should 243 | really be used as examples only. If you want to build a system-wide shared 244 | library, use the Autotools method described above. 245 | 246 | To build HIDAPI using the manual makefiles, change to the directory 247 | of your platform and run make. For example, on Linux run: 248 | cd linux/ 249 | make -f Makefile-manual 250 | 251 | To build the Test GUI using the manual makefiles: 252 | cd testgui/ 253 | make -f Makefile-manual 254 | 255 | Building on Windows: 256 | --------------------- 257 | 258 | To build the HIDAPI DLL on Windows using Visual Studio, build the .sln file 259 | in the windows/ directory. 260 | 261 | To build the Test GUI on windows using Visual Studio, build the .sln file in 262 | the testgui/ directory. 263 | 264 | To build HIDAPI using MinGW or Cygwin using Autotools, use the instructions 265 | in the section titled "Building HIDAPI into a shared library on Unix 266 | Platforms" above. Note that building the Test GUI with MinGW or Cygwin will 267 | require the Windows procedure in the Prerequisites section above (ie: 268 | hidapi-externals.zip). 269 | 270 | To build HIDAPI using MinGW using the Manual Makefiles, see the section 271 | "Building the manual way on Unix platforms" above. 272 | 273 | HIDAPI can also be built using the Windows DDK (now also called the Windows 274 | Driver Kit or WDK). This method was originally required for the HIDAPI build 275 | but not anymore. However, some users still prefer this method. It is not as 276 | well supported anymore but should still work. Patches are welcome if it does 277 | not. To build using the DDK: 278 | 279 | 1. Install the Windows Driver Kit (WDK) from Microsoft. 280 | 2. From the Start menu, in the Windows Driver Kits folder, select Build 281 | Environments, then your operating system, then the x86 Free Build 282 | Environment (or one that is appropriate for your system). 283 | 3. From the console, change directory to the windows/ddk_build/ directory, 284 | which is part of the HIDAPI distribution. 285 | 4. Type build. 286 | 5. You can find the output files (DLL and LIB) in a subdirectory created 287 | by the build system which is appropriate for your environment. On 288 | Windows XP, this directory is objfre_wxp_x86/i386. 289 | 290 | Cross Compiling 291 | ================ 292 | 293 | This section talks about cross compiling HIDAPI for Linux using autotools. 294 | This is useful for using HIDAPI on embedded Linux targets. These 295 | instructions assume the most raw kind of embedded Linux build, where all 296 | prerequisites will need to be built first. This process will of course vary 297 | based on your embedded Linux build system if you are using one, such as 298 | OpenEmbedded or Buildroot. 299 | 300 | For the purpose of this section, it will be assumed that the following 301 | environment variables are exported. 302 | 303 | $ export STAGING=$HOME/out 304 | $ export HOST=arm-linux 305 | 306 | STAGING and HOST can be modified to suit your setup. 307 | 308 | Prerequisites 309 | -------------- 310 | 311 | Note that the build of libudev is the very basic configuration. 312 | 313 | Build Libusb. From the libusb source directory, run: 314 | ./configure --host=$HOST --prefix=$STAGING 315 | make 316 | make install 317 | 318 | Build libudev. From the libudev source directory, run: 319 | ./configure --disable-gudev --disable-introspection --disable-hwdb \ 320 | --host=$HOST --prefix=$STAGING 321 | make 322 | make install 323 | 324 | Building HIDAPI 325 | ---------------- 326 | 327 | Build HIDAPI: 328 | 329 | PKG_CONFIG_DIR= \ 330 | PKG_CONFIG_LIBDIR=$STAGING/lib/pkgconfig:$STAGING/share/pkgconfig \ 331 | PKG_CONFIG_SYSROOT_DIR=$STAGING \ 332 | ./configure --host=$HOST --prefix=$STAGING 333 | 334 | 335 | Signal 11 Software - 2010-04-11 336 | 2010-07-28 337 | 2011-09-10 338 | 2012-05-01 339 | 2012-07-03 340 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/android/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | HIDAPI_ROOT_REL:= ../.. 4 | HIDAPI_ROOT_ABS:= $(LOCAL_PATH)/../.. 5 | 6 | include $(CLEAR_VARS) 7 | 8 | LOCAL_SRC_FILES := \ 9 | $(HIDAPI_ROOT_REL)/libusb/hid.c 10 | 11 | LOCAL_C_INCLUDES += \ 12 | $(HIDAPI_ROOT_ABS)/hidapi \ 13 | $(HIDAPI_ROOT_ABS)/android 14 | 15 | LOCAL_SHARED_LIBRARIES := libusb1.0 16 | 17 | LOCAL_MODULE := libhidapi 18 | 19 | include $(BUILD_SHARED_LIBRARY) 20 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | autoreconf --install --verbose --force 3 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ(2.63) 2 | 3 | # Version number. This is currently the only place. 4 | m4_define([HIDAPI_MAJOR], 0) 5 | m4_define([HIDAPI_MINOR], 8) 6 | m4_define([HIDAPI_RELEASE], 0) 7 | m4_define([HIDAPI_RC], -rc1) 8 | m4_define([VERSION_STRING], HIDAPI_MAJOR[.]HIDAPI_MINOR[.]HIDAPI_RELEASE[]HIDAPI_RC) 9 | 10 | AC_INIT([hidapi],[VERSION_STRING],[alan@signal11.us]) 11 | 12 | # Library soname version 13 | # Follow the following rules (particularly the ones in the second link): 14 | # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html 15 | # http://sourceware.org/autobook/autobook/autobook_91.html 16 | lt_current="0" 17 | lt_revision="0" 18 | lt_age="0" 19 | LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}" 20 | 21 | AC_CONFIG_MACRO_DIR([m4]) 22 | AM_INIT_AUTOMAKE([foreign -Wall -Werror]) 23 | AC_CONFIG_MACRO_DIR([m4]) 24 | 25 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) 26 | LT_INIT 27 | 28 | AC_PROG_CC 29 | AC_PROG_CXX 30 | AC_PROG_OBJC 31 | PKG_PROG_PKG_CONFIG 32 | 33 | 34 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 35 | 36 | hidapi_lib_error() { 37 | echo "" 38 | echo " Library $1 was not found on this system." 39 | echo " Please install it and re-run ./configure" 40 | echo "" 41 | exit 1 42 | } 43 | 44 | hidapi_prog_error() { 45 | echo "" 46 | echo " Program $1 was not found on this system." 47 | echo " This program is part of $2." 48 | echo " Please install it and re-run ./configure" 49 | echo "" 50 | exit 1 51 | } 52 | 53 | AC_MSG_CHECKING([operating system]) 54 | AC_MSG_RESULT($host) 55 | case $host in 56 | *-linux*) 57 | AC_MSG_RESULT([ (Linux back-end)]) 58 | AC_DEFINE(OS_LINUX, 1, [Linux implementations]) 59 | AC_SUBST(OS_LINUX) 60 | backend="linux" 61 | os="linux" 62 | threads="pthreads" 63 | 64 | # HIDAPI/hidraw libs 65 | PKG_CHECK_MODULES([libudev], [libudev], true, [hidapi_lib_error libudev]) 66 | LIBS_HIDRAW_PR+=" $libudev_LIBS" 67 | CFLAGS_HIDRAW+=" $libudev_CFLAGS" 68 | 69 | # HIDAPI/libusb libs 70 | AC_CHECK_LIB([rt], [clock_gettime], [LIBS_LIBUSB_PRIVATE+=" -lrt"], [hidapi_lib_error librt]) 71 | PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.9], true, [hidapi_lib_error libusb-1.0]) 72 | LIBS_LIBUSB_PRIVATE+=" $libusb_LIBS" 73 | CFLAGS_LIBUSB+=" $libusb_CFLAGS" 74 | ;; 75 | *-darwin*) 76 | AC_MSG_RESULT([ (Mac OS X back-end)]) 77 | AC_DEFINE(OS_DARWIN, 1, [Mac implementation]) 78 | AC_SUBST(OS_DARWIN) 79 | backend="mac" 80 | os="darwin" 81 | threads="pthreads" 82 | LIBS="${LIBS} -framework IOKit -framework CoreFoundation" 83 | ;; 84 | *-freebsd*) 85 | AC_MSG_RESULT([ (FreeBSD back-end)]) 86 | AC_DEFINE(OS_FREEBSD, 1, [FreeBSD implementation]) 87 | AC_SUBST(OS_FREEBSD) 88 | backend="libusb" 89 | os="freebsd" 90 | threads="pthreads" 91 | 92 | CFLAGS="$CFLAGS -I/usr/local/include" 93 | LDFLAGS="$LDFLAGS -L/usr/local/lib" 94 | LIBS="${LIBS}" 95 | AC_CHECK_LIB([usb], [libusb_init], [LIBS_LIBUSB_PRIVATE="${LIBS_LIBUSB_PRIVATE} -lusb"], [hidapi_lib_error libusb]) 96 | AC_CHECK_LIB([iconv], [iconv_open], [LIBS_LIBUSB_PRIVATE="${LIBS_LIBUSB_PRIVATE} -liconv"], [hidapi_lib_error libiconv]) 97 | echo libs_priv: $LIBS_LIBUSB_PRIVATE 98 | ;; 99 | *-kfreebsd*) 100 | AC_MSG_RESULT([ (kFreeBSD back-end)]) 101 | AC_DEFINE(OS_KFREEBSD, 1, [kFreeBSD implementation]) 102 | AC_SUBST(OS_KFREEBSD) 103 | backend="libusb" 104 | os="kfreebsd" 105 | threads="pthreads" 106 | 107 | AC_CHECK_LIB([usb], [libusb_init], [LIBS_LIBUSB_PRIVATE="${LIBS_LIBUSB_PRIVATE} -lusb"], [hidapi_lib_error libusb]) 108 | echo libs_priv: $LIBS_LIBUSB_PRIVATE 109 | ;; 110 | *-mingw*) 111 | AC_MSG_RESULT([ (Windows back-end, using MinGW)]) 112 | backend="windows" 113 | os="windows" 114 | threads="windows" 115 | win_implementation="mingw" 116 | ;; 117 | *-cygwin*) 118 | AC_MSG_RESULT([ (Windows back-end, using Cygwin)]) 119 | backend="windows" 120 | os="windows" 121 | threads="windows" 122 | win_implementation="cygwin" 123 | ;; 124 | *) 125 | AC_MSG_ERROR([HIDAPI is not supported on your operating system yet]) 126 | esac 127 | 128 | LIBS_HIDRAW="${LIBS} ${LIBS_HIDRAW_PR}" 129 | LIBS_LIBUSB="${LIBS} ${LIBS_LIBUSB_PRIVATE}" 130 | AC_SUBST([LIBS_HIDRAW]) 131 | AC_SUBST([LIBS_LIBUSB]) 132 | AC_SUBST([CFLAGS_LIBUSB]) 133 | AC_SUBST([CFLAGS_HIDRAW]) 134 | 135 | if test "x$os" = xwindows; then 136 | AC_DEFINE(OS_WINDOWS, 1, [Windows implementations]) 137 | AC_SUBST(OS_WINDOWS) 138 | LDFLAGS="${LDFLAGS} -no-undefined" 139 | LIBS="${LIBS} -lsetupapi" 140 | fi 141 | 142 | if test "x$threads" = xpthreads; then 143 | AX_PTHREAD([found_pthreads=yes], [found_pthreads=no]) 144 | 145 | if test "x$found_pthreads" = xyes; then 146 | if test "x$os" = xlinux; then 147 | # Only use pthreads for libusb implementation on Linux. 148 | LIBS_LIBUSB="$PTHREAD_LIBS $LIBS_LIBUSB" 149 | CFLAGS_LIBUSB="$CFLAGS_LIBUSB $PTHREAD_CFLAGS" 150 | # There's no separate CC on Linux for threading, 151 | # so it's ok that both implementations use $PTHREAD_CC 152 | CC="$PTHREAD_CC" 153 | else 154 | LIBS="$PTHREAD_LIBS $LIBS" 155 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 156 | CC="$PTHREAD_CC" 157 | fi 158 | fi 159 | fi 160 | 161 | # Test GUI 162 | AC_ARG_ENABLE([testgui], 163 | [AS_HELP_STRING([--enable-testgui], 164 | [enable building of test GUI (default n)])], 165 | [testgui_enabled=$enableval], 166 | [testgui_enabled='no']) 167 | AM_CONDITIONAL([BUILD_TESTGUI], [test "x$testgui_enabled" != "xno"]) 168 | 169 | # Configure the MacOS TestGUI app bundle 170 | rm -Rf testgui/TestGUI.app 171 | mkdir -p testgui/TestGUI.app 172 | cp -R ${srcdir}/testgui/TestGUI.app.in/* testgui/TestGUI.app 173 | chmod -R u+w testgui/TestGUI.app 174 | mkdir testgui/TestGUI.app/Contents/MacOS/ 175 | 176 | if test "x$testgui_enabled" != "xno"; then 177 | if test "x$os" = xdarwin; then 178 | # On Mac OS, don't use pkg-config. 179 | AC_CHECK_PROG([foxconfig], [fox-config], [fox-config], false) 180 | if test "x$foxconfig" = "xfalse"; then 181 | hidapi_prog_error fox-config "FOX Toolkit" 182 | fi 183 | LIBS_TESTGUI+=`$foxconfig --libs` 184 | LIBS_TESTGUI+=" -framework Cocoa -L/usr/X11R6/lib" 185 | CFLAGS_TESTGUI+=`$foxconfig --cflags` 186 | OBJCFLAGS+=" -x objective-c++" 187 | elif test "x$os" = xwindows; then 188 | # On Windows, just set the paths for Fox toolkit 189 | if test "x$win_implementation" = xmingw; then 190 | CFLAGS_TESTGUI="-I\$(srcdir)/../../hidapi-externals/fox/include -g -c" 191 | LIBS_TESTGUI=" -mwindows \$(srcdir)/../../hidapi-externals/fox/lib/libFOX-1.6.a -lgdi32 -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32" 192 | else 193 | # Cygwin 194 | CFLAGS_TESTGUI="-DWIN32 -I\$(srcdir)/../../hidapi-externals/fox/include -g -c" 195 | LIBS_TESTGUI="\$(srcdir)/../../hidapi-externals/fox/lib/libFOX-cygwin-1.6.a -lgdi32 -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32" 196 | fi 197 | else 198 | # On Linux and FreeBSD platforms, use pkg-config to find fox. 199 | PKG_CHECK_MODULES([fox], [fox17], [], [PKG_CHECK_MODULES([fox], [fox])]) 200 | LIBS_TESTGUI="${LIBS_TESTGUI} $fox_LIBS" 201 | if test "x$os" = xfreebsd; then 202 | LIBS_TESTGUI="${LIBS_TESTGUI} -L/usr/local/lib" 203 | fi 204 | CFLAGS_TESTGUI="${CFLAGS_TESTGUI} $fox_CFLAGS" 205 | fi 206 | fi 207 | AC_SUBST([LIBS_TESTGUI]) 208 | AC_SUBST([CFLAGS_TESTGUI]) 209 | AC_SUBST([backend]) 210 | 211 | # OS info for Automake 212 | AM_CONDITIONAL(OS_LINUX, test "x$os" = xlinux) 213 | AM_CONDITIONAL(OS_DARWIN, test "x$os" = xdarwin) 214 | AM_CONDITIONAL(OS_FREEBSD, test "x$os" = xfreebsd) 215 | AM_CONDITIONAL(OS_KFREEBSD, test "x$os" = xkfreebsd) 216 | AM_CONDITIONAL(OS_WINDOWS, test "x$os" = xwindows) 217 | 218 | AC_CONFIG_HEADERS([config.h]) 219 | 220 | if test "x$os" = "xlinux"; then 221 | AC_CONFIG_FILES([pc/hidapi-hidraw.pc]) 222 | AC_CONFIG_FILES([pc/hidapi-libusb.pc]) 223 | else 224 | AC_CONFIG_FILES([pc/hidapi.pc]) 225 | fi 226 | 227 | AC_SUBST(LTLDFLAGS) 228 | 229 | AC_CONFIG_FILES([Makefile \ 230 | hidtest/Makefile \ 231 | libusb/Makefile \ 232 | linux/Makefile \ 233 | mac/Makefile \ 234 | testgui/Makefile \ 235 | windows/Makefile]) 236 | AC_OUTPUT 237 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/hidapi/hidapi.h: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | HIDAPI - Multi-Platform library for 3 | communication with HID devices. 4 | 5 | Alan Ott 6 | Signal 11 Software 7 | 8 | 8/22/2009 9 | 10 | Copyright 2009, All Rights Reserved. 11 | 12 | At the discretion of the user of this library, 13 | this software may be licensed under the terms of the 14 | GNU General Public License v3, a BSD-Style license, or the 15 | original HIDAPI license as outlined in the LICENSE.txt, 16 | LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt 17 | files located at the root of the source distribution. 18 | These files may also be found in the public source 19 | code repository located at: 20 | http://github.com/signal11/hidapi . 21 | ********************************************************/ 22 | 23 | /** @file 24 | * @defgroup API hidapi API 25 | */ 26 | 27 | #ifndef HIDAPI_H__ 28 | #define HIDAPI_H__ 29 | 30 | #include 31 | 32 | #ifdef _WIN32 33 | #define HID_API_EXPORT __declspec(dllexport) 34 | #define HID_API_CALL 35 | #else 36 | #define HID_API_EXPORT /**< API export macro */ 37 | #define HID_API_CALL /**< API call macro */ 38 | #endif 39 | 40 | #define HID_API_EXPORT_CALL HID_API_EXPORT HID_API_CALL /**< API export and call macro*/ 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | struct hid_device_; 46 | typedef struct hid_device_ hid_device; /**< opaque hidapi structure */ 47 | 48 | /** hidapi info structure */ 49 | struct hid_device_info { 50 | /** Platform-specific device path */ 51 | char *path; 52 | /** Device Vendor ID */ 53 | unsigned short vendor_id; 54 | /** Device Product ID */ 55 | unsigned short product_id; 56 | /** Serial Number */ 57 | wchar_t *serial_number; 58 | /** Device Release Number in binary-coded decimal, 59 | also known as Device Version Number */ 60 | unsigned short release_number; 61 | /** Manufacturer String */ 62 | wchar_t *manufacturer_string; 63 | /** Product string */ 64 | wchar_t *product_string; 65 | /** Usage Page for this Device/Interface 66 | (Windows/Mac only). */ 67 | unsigned short usage_page; 68 | /** Usage for this Device/Interface 69 | (Windows/Mac only).*/ 70 | unsigned short usage; 71 | /** The USB interface which this logical device 72 | represents. Valid on both Linux implementations 73 | in all cases, and valid on the Windows implementation 74 | only if the device contains more than one interface. */ 75 | int interface_number; 76 | 77 | /** Pointer to the next device */ 78 | struct hid_device_info *next; 79 | }; 80 | 81 | 82 | /** @brief Initialize the HIDAPI library. 83 | 84 | This function initializes the HIDAPI library. Calling it is not 85 | strictly necessary, as it will be called automatically by 86 | hid_enumerate() and any of the hid_open_*() functions if it is 87 | needed. This function should be called at the beginning of 88 | execution however, if there is a chance of HIDAPI handles 89 | being opened by different threads simultaneously. 90 | 91 | @ingroup API 92 | 93 | @returns 94 | This function returns 0 on success and -1 on error. 95 | */ 96 | int HID_API_EXPORT HID_API_CALL hid_init(void); 97 | 98 | /** @brief Finalize the HIDAPI library. 99 | 100 | This function frees all of the static data associated with 101 | HIDAPI. It should be called at the end of execution to avoid 102 | memory leaks. 103 | 104 | @ingroup API 105 | 106 | @returns 107 | This function returns 0 on success and -1 on error. 108 | */ 109 | int HID_API_EXPORT HID_API_CALL hid_exit(void); 110 | 111 | /** @brief Enumerate the HID Devices. 112 | 113 | This function returns a linked list of all the HID devices 114 | attached to the system which match vendor_id and product_id. 115 | If @p vendor_id is set to 0 then any vendor matches. 116 | If @p product_id is set to 0 then any product matches. 117 | If @p vendor_id and @p product_id are both set to 0, then 118 | all HID devices will be returned. 119 | 120 | @ingroup API 121 | @param vendor_id The Vendor ID (VID) of the types of device 122 | to open. 123 | @param product_id The Product ID (PID) of the types of 124 | device to open. 125 | 126 | @returns 127 | This function returns a pointer to a linked list of type 128 | struct #hid_device, containing information about the HID devices 129 | attached to the system, or NULL in the case of failure. Free 130 | this linked list by calling hid_free_enumeration(). 131 | */ 132 | struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id); 133 | 134 | /** @brief Free an enumeration Linked List 135 | 136 | This function frees a linked list created by hid_enumerate(). 137 | 138 | @ingroup API 139 | @param devs Pointer to a list of struct_device returned from 140 | hid_enumerate(). 141 | */ 142 | void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs); 143 | 144 | /** @brief Open a HID device using a Vendor ID (VID), Product ID 145 | (PID) and optionally a serial number. 146 | 147 | If @p serial_number is NULL, the first device with the 148 | specified VID and PID is opened. 149 | 150 | @ingroup API 151 | @param vendor_id The Vendor ID (VID) of the device to open. 152 | @param product_id The Product ID (PID) of the device to open. 153 | @param serial_number The Serial Number of the device to open 154 | (Optionally NULL). 155 | 156 | @returns 157 | This function returns a pointer to a #hid_device object on 158 | success or NULL on failure. 159 | */ 160 | HID_API_EXPORT hid_device * HID_API_CALL hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number); 161 | 162 | /** @brief Open a HID device by its path name. 163 | 164 | The path name be determined by calling hid_enumerate(), or a 165 | platform-specific path name can be used (eg: /dev/hidraw0 on 166 | Linux). 167 | 168 | @ingroup API 169 | @param path The path name of the device to open 170 | 171 | @returns 172 | This function returns a pointer to a #hid_device object on 173 | success or NULL on failure. 174 | */ 175 | HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path); 176 | 177 | /** @brief Write an Output report to a HID device. 178 | 179 | The first byte of @p data[] must contain the Report ID. For 180 | devices which only support a single report, this must be set 181 | to 0x0. The remaining bytes contain the report data. Since 182 | the Report ID is mandatory, calls to hid_write() will always 183 | contain one more byte than the report contains. For example, 184 | if a hid report is 16 bytes long, 17 bytes must be passed to 185 | hid_write(), the Report ID (or 0x0, for devices with a 186 | single report), followed by the report data (16 bytes). In 187 | this example, the length passed in would be 17. 188 | 189 | hid_write() will send the data on the first OUT endpoint, if 190 | one exists. If it does not, it will send the data through 191 | the Control Endpoint (Endpoint 0). 192 | 193 | @ingroup API 194 | @param device A device handle returned from hid_open(). 195 | @param data The data to send, including the report number as 196 | the first byte. 197 | @param length The length in bytes of the data to send. 198 | 199 | @returns 200 | This function returns the actual number of bytes written and 201 | -1 on error. 202 | */ 203 | int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length); 204 | 205 | /** @brief Read an Input report from a HID device with timeout. 206 | 207 | Input reports are returned 208 | to the host through the INTERRUPT IN endpoint. The first byte will 209 | contain the Report number if the device uses numbered reports. 210 | 211 | @ingroup API 212 | @param device A device handle returned from hid_open(). 213 | @param data A buffer to put the read data into. 214 | @param length The number of bytes to read. For devices with 215 | multiple reports, make sure to read an extra byte for 216 | the report number. 217 | @param milliseconds timeout in milliseconds or -1 for blocking wait. 218 | 219 | @returns 220 | This function returns the actual number of bytes read and 221 | -1 on error. If no packet was available to be read within 222 | the timeout period, this function returns 0. 223 | */ 224 | int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds); 225 | 226 | /** @brief Read an Input report from a HID device. 227 | 228 | Input reports are returned 229 | to the host through the INTERRUPT IN endpoint. The first byte will 230 | contain the Report number if the device uses numbered reports. 231 | 232 | @ingroup API 233 | @param device A device handle returned from hid_open(). 234 | @param data A buffer to put the read data into. 235 | @param length The number of bytes to read. For devices with 236 | multiple reports, make sure to read an extra byte for 237 | the report number. 238 | 239 | @returns 240 | This function returns the actual number of bytes read and 241 | -1 on error. If no packet was available to be read and 242 | the handle is in non-blocking mode, this function returns 0. 243 | */ 244 | int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length); 245 | 246 | /** @brief Set the device handle to be non-blocking. 247 | 248 | In non-blocking mode calls to hid_read() will return 249 | immediately with a value of 0 if there is no data to be 250 | read. In blocking mode, hid_read() will wait (block) until 251 | there is data to read before returning. 252 | 253 | Nonblocking can be turned on and off at any time. 254 | 255 | @ingroup API 256 | @param device A device handle returned from hid_open(). 257 | @param nonblock enable or not the nonblocking reads 258 | - 1 to enable nonblocking 259 | - 0 to disable nonblocking. 260 | 261 | @returns 262 | This function returns 0 on success and -1 on error. 263 | */ 264 | int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock); 265 | 266 | /** @brief Send a Feature report to the device. 267 | 268 | Feature reports are sent over the Control endpoint as a 269 | Set_Report transfer. The first byte of @p data[] must 270 | contain the Report ID. For devices which only support a 271 | single report, this must be set to 0x0. The remaining bytes 272 | contain the report data. Since the Report ID is mandatory, 273 | calls to hid_send_feature_report() will always contain one 274 | more byte than the report contains. For example, if a hid 275 | report is 16 bytes long, 17 bytes must be passed to 276 | hid_send_feature_report(): the Report ID (or 0x0, for 277 | devices which do not use numbered reports), followed by the 278 | report data (16 bytes). In this example, the length passed 279 | in would be 17. 280 | 281 | @ingroup API 282 | @param device A device handle returned from hid_open(). 283 | @param data The data to send, including the report number as 284 | the first byte. 285 | @param length The length in bytes of the data to send, including 286 | the report number. 287 | 288 | @returns 289 | This function returns the actual number of bytes written and 290 | -1 on error. 291 | */ 292 | int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length); 293 | 294 | /** @brief Get a feature report from a HID device. 295 | 296 | Set the first byte of @p data[] to the Report ID of the 297 | report to be read. Make sure to allow space for this 298 | extra byte in @p data[]. Upon return, the first byte will 299 | still contain the Report ID, and the report data will 300 | start in data[1]. 301 | 302 | @ingroup API 303 | @param device A device handle returned from hid_open(). 304 | @param data A buffer to put the read data into, including 305 | the Report ID. Set the first byte of @p data[] to the 306 | Report ID of the report to be read, or set it to zero 307 | if your device does not use numbered reports. 308 | @param length The number of bytes to read, including an 309 | extra byte for the report ID. The buffer can be longer 310 | than the actual report. 311 | 312 | @returns 313 | This function returns the number of bytes read plus 314 | one for the report ID (which is still in the first 315 | byte), or -1 on error. 316 | */ 317 | int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length); 318 | 319 | /** @brief Close a HID device. 320 | 321 | @ingroup API 322 | @param device A device handle returned from hid_open(). 323 | */ 324 | void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device); 325 | 326 | /** @brief Get The Manufacturer String from a HID device. 327 | 328 | @ingroup API 329 | @param device A device handle returned from hid_open(). 330 | @param string A wide string buffer to put the data into. 331 | @param maxlen The length of the buffer in multiples of wchar_t. 332 | 333 | @returns 334 | This function returns 0 on success and -1 on error. 335 | */ 336 | int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen); 337 | 338 | /** @brief Get The Product String from a HID device. 339 | 340 | @ingroup API 341 | @param device A device handle returned from hid_open(). 342 | @param string A wide string buffer to put the data into. 343 | @param maxlen The length of the buffer in multiples of wchar_t. 344 | 345 | @returns 346 | This function returns 0 on success and -1 on error. 347 | */ 348 | int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen); 349 | 350 | /** @brief Get The Serial Number String from a HID device. 351 | 352 | @ingroup API 353 | @param device A device handle returned from hid_open(). 354 | @param string A wide string buffer to put the data into. 355 | @param maxlen The length of the buffer in multiples of wchar_t. 356 | 357 | @returns 358 | This function returns 0 on success and -1 on error. 359 | */ 360 | int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen); 361 | 362 | /** @brief Get a string from a HID device, based on its string index. 363 | 364 | @ingroup API 365 | @param device A device handle returned from hid_open(). 366 | @param string_index The index of the string to get. 367 | @param string A wide string buffer to put the data into. 368 | @param maxlen The length of the buffer in multiples of wchar_t. 369 | 370 | @returns 371 | This function returns 0 on success and -1 on error. 372 | */ 373 | int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen); 374 | 375 | /** @brief Get a string describing the last error which occurred. 376 | 377 | @ingroup API 378 | @param device A device handle returned from hid_open(). 379 | 380 | @returns 381 | This function returns a string containing the last error 382 | which occurred or NULL if none has occurred. 383 | */ 384 | HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device); 385 | 386 | #ifdef __cplusplus 387 | } 388 | #endif 389 | 390 | #endif 391 | 392 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/hidtest/.npmignore: -------------------------------------------------------------------------------- 1 | Debug 2 | Release 3 | *.exp 4 | *.ilk 5 | *.lib 6 | *.suo 7 | *.vcproj.* 8 | *.ncb 9 | *.suo 10 | *.dll 11 | *.pdb 12 | *.o 13 | .deps/ 14 | .libs/ 15 | hidtest-hidraw 16 | hidtest-libusb 17 | hidtest 18 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/hidtest/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ 2 | 3 | ## Linux 4 | if OS_LINUX 5 | noinst_PROGRAMS = hidtest-libusb hidtest-hidraw 6 | 7 | hidtest_hidraw_SOURCES = hidtest.cpp 8 | hidtest_hidraw_LDADD = $(top_builddir)/linux/libhidapi-hidraw.la 9 | 10 | hidtest_libusb_SOURCES = hidtest.cpp 11 | hidtest_libusb_LDADD = $(top_builddir)/libusb/libhidapi-libusb.la 12 | else 13 | 14 | # Other OS's 15 | noinst_PROGRAMS = hidtest 16 | 17 | hidtest_SOURCES = hidtest.cpp 18 | hidtest_LDADD = $(top_builddir)/$(backend)/libhidapi.la 19 | 20 | endif 21 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/hidtest/hidtest.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | Windows HID simplification 3 | 4 | Alan Ott 5 | Signal 11 Software 6 | 7 | 8/22/2009 8 | 9 | Copyright 2009 10 | 11 | This contents of this file may be used by anyone 12 | for any reason without any conditions and may be 13 | used as a starting point for your own applications 14 | which use HIDAPI. 15 | ********************************************************/ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "hidapi.h" 22 | 23 | // Headers needed for sleeping. 24 | #ifdef _WIN32 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | int main(int argc, char* argv[]) 31 | { 32 | int res; 33 | unsigned char buf[256]; 34 | #define MAX_STR 255 35 | wchar_t wstr[MAX_STR]; 36 | hid_device *handle; 37 | int i; 38 | 39 | #ifdef WIN32 40 | UNREFERENCED_PARAMETER(argc); 41 | UNREFERENCED_PARAMETER(argv); 42 | #endif 43 | 44 | struct hid_device_info *devs, *cur_dev; 45 | 46 | if (hid_init()) 47 | return -1; 48 | 49 | devs = hid_enumerate(0x0, 0x0); 50 | cur_dev = devs; 51 | while (cur_dev) { 52 | printf("Device Found\n type: %04hx %04hx\n path: %s\n serial_number: %ls", cur_dev->vendor_id, cur_dev->product_id, cur_dev->path, cur_dev->serial_number); 53 | printf("\n"); 54 | printf(" Manufacturer: %ls\n", cur_dev->manufacturer_string); 55 | printf(" Product: %ls\n", cur_dev->product_string); 56 | printf(" Release: %hx\n", cur_dev->release_number); 57 | printf(" Interface: %d\n", cur_dev->interface_number); 58 | printf("\n"); 59 | cur_dev = cur_dev->next; 60 | } 61 | hid_free_enumeration(devs); 62 | 63 | // Set up the command buffer. 64 | memset(buf,0x00,sizeof(buf)); 65 | buf[0] = 0x01; 66 | buf[1] = 0x81; 67 | 68 | 69 | // Open the device using the VID, PID, 70 | // and optionally the Serial number. 71 | ////handle = hid_open(0x4d8, 0x3f, L"12345"); 72 | handle = hid_open(0x4d8, 0x3f, NULL); 73 | if (!handle) { 74 | printf("unable to open device\n"); 75 | return 1; 76 | } 77 | 78 | // Read the Manufacturer String 79 | wstr[0] = 0x0000; 80 | res = hid_get_manufacturer_string(handle, wstr, MAX_STR); 81 | if (res < 0) 82 | printf("Unable to read manufacturer string\n"); 83 | printf("Manufacturer String: %ls\n", wstr); 84 | 85 | // Read the Product String 86 | wstr[0] = 0x0000; 87 | res = hid_get_product_string(handle, wstr, MAX_STR); 88 | if (res < 0) 89 | printf("Unable to read product string\n"); 90 | printf("Product String: %ls\n", wstr); 91 | 92 | // Read the Serial Number String 93 | wstr[0] = 0x0000; 94 | res = hid_get_serial_number_string(handle, wstr, MAX_STR); 95 | if (res < 0) 96 | printf("Unable to read serial number string\n"); 97 | printf("Serial Number String: (%d) %ls", wstr[0], wstr); 98 | printf("\n"); 99 | 100 | // Read Indexed String 1 101 | wstr[0] = 0x0000; 102 | res = hid_get_indexed_string(handle, 1, wstr, MAX_STR); 103 | if (res < 0) 104 | printf("Unable to read indexed string 1\n"); 105 | printf("Indexed String 1: %ls\n", wstr); 106 | 107 | // Set the hid_read() function to be non-blocking. 108 | hid_set_nonblocking(handle, 1); 109 | 110 | // Try to read from the device. There shoud be no 111 | // data here, but execution should not block. 112 | res = hid_read(handle, buf, 17); 113 | 114 | // Send a Feature Report to the device 115 | buf[0] = 0x2; 116 | buf[1] = 0xa0; 117 | buf[2] = 0x0a; 118 | buf[3] = 0x00; 119 | buf[4] = 0x00; 120 | res = hid_send_feature_report(handle, buf, 17); 121 | if (res < 0) { 122 | printf("Unable to send a feature report.\n"); 123 | } 124 | 125 | memset(buf,0,sizeof(buf)); 126 | 127 | // Read a Feature Report from the device 128 | buf[0] = 0x2; 129 | res = hid_get_feature_report(handle, buf, sizeof(buf)); 130 | if (res < 0) { 131 | printf("Unable to get a feature report.\n"); 132 | printf("%ls", hid_error(handle)); 133 | } 134 | else { 135 | // Print out the returned buffer. 136 | printf("Feature Report\n "); 137 | for (i = 0; i < res; i++) 138 | printf("%02hhx ", buf[i]); 139 | printf("\n"); 140 | } 141 | 142 | memset(buf,0,sizeof(buf)); 143 | 144 | // Toggle LED (cmd 0x80). The first byte is the report number (0x1). 145 | buf[0] = 0x1; 146 | buf[1] = 0x80; 147 | res = hid_write(handle, buf, 17); 148 | if (res < 0) { 149 | printf("Unable to write()\n"); 150 | printf("Error: %ls\n", hid_error(handle)); 151 | } 152 | 153 | 154 | // Request state (cmd 0x81). The first byte is the report number (0x1). 155 | buf[0] = 0x1; 156 | buf[1] = 0x81; 157 | hid_write(handle, buf, 17); 158 | if (res < 0) 159 | printf("Unable to write() (2)\n"); 160 | 161 | // Read requested state. hid_read() has been set to be 162 | // non-blocking by the call to hid_set_nonblocking() above. 163 | // This loop demonstrates the non-blocking nature of hid_read(). 164 | res = 0; 165 | while (res == 0) { 166 | res = hid_read(handle, buf, sizeof(buf)); 167 | if (res == 0) 168 | printf("waiting...\n"); 169 | if (res < 0) 170 | printf("Unable to read()\n"); 171 | #ifdef WIN32 172 | Sleep(500); 173 | #else 174 | usleep(500*1000); 175 | #endif 176 | } 177 | 178 | printf("Data read:\n "); 179 | // Print out the returned buffer. 180 | for (i = 0; i < res; i++) 181 | printf("%02hhx ", buf[i]); 182 | printf("\n"); 183 | 184 | hid_close(handle); 185 | 186 | /* Free static HIDAPI objects. */ 187 | hid_exit(); 188 | 189 | #ifdef WIN32 190 | system("pause"); 191 | #endif 192 | 193 | return 0; 194 | } 195 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/libusb/.npmignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | *.la 4 | *.lo 5 | *.a 6 | .libs 7 | .deps 8 | hidtest-libusb 9 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/libusb/Makefile-manual: -------------------------------------------------------------------------------- 1 | 2 | 3 | OS=$(shell uname) 4 | 5 | ifeq ($(OS), Linux) 6 | FILE=Makefile.linux 7 | endif 8 | 9 | ifeq ($(OS), FreeBSD) 10 | FILE=Makefile.freebsd 11 | endif 12 | 13 | ifeq ($(FILE), ) 14 | all: 15 | $(error Your platform ${OS} is not supported by hidapi/libusb at this time.) 16 | endif 17 | 18 | include $(FILE) 19 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/libusb/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi $(CFLAGS_LIBUSB) 2 | 3 | if OS_LINUX 4 | lib_LTLIBRARIES = libhidapi-libusb.la 5 | libhidapi_libusb_la_SOURCES = hid.c 6 | libhidapi_libusb_la_LDFLAGS = $(LTLDFLAGS) $(PTHREAD_CFLAGS) 7 | libhidapi_libusb_la_LIBADD = $(LIBS_LIBUSB) 8 | endif 9 | 10 | if OS_FREEBSD 11 | lib_LTLIBRARIES = libhidapi.la 12 | libhidapi_la_SOURCES = hid.c 13 | libhidapi_la_LDFLAGS = $(LTLDFLAGS) 14 | libhidapi_la_LIBADD = $(LIBS_LIBUSB) 15 | endif 16 | 17 | if OS_KFREEBSD 18 | lib_LTLIBRARIES = libhidapi.la 19 | libhidapi_la_SOURCES = hid.c 20 | libhidapi_la_LDFLAGS = $(LTLDFLAGS) 21 | libhidapi_la_LIBADD = $(LIBS_LIBUSB) 22 | endif 23 | 24 | hdrdir = $(includedir)/hidapi 25 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h 26 | 27 | EXTRA_DIST = Makefile-manual 28 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/libusb/Makefile.freebsd: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Simple Makefile for HIDAPI test program 3 | # 4 | # Alan Ott 5 | # Signal 11 Software 6 | # 2010-06-01 7 | ########################################### 8 | 9 | all: hidtest libs 10 | 11 | libs: libhidapi.so 12 | 13 | CC ?= cc 14 | CFLAGS ?= -Wall -g -fPIC 15 | 16 | CXX ?= c++ 17 | CXXFLAGS ?= -Wall -g 18 | 19 | COBJS = hid.o 20 | CPPOBJS = ../hidtest/hidtest.o 21 | OBJS = $(COBJS) $(CPPOBJS) 22 | INCLUDES = -I../hidapi -I/usr/local/include 23 | LDFLAGS = -L/usr/local/lib 24 | LIBS = -lusb -liconv -pthread 25 | 26 | 27 | # Console Test Program 28 | hidtest: $(OBJS) 29 | $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS) 30 | 31 | # Shared Libs 32 | libhidapi.so: $(COBJS) 33 | $(CC) $(LDFLAGS) -shared -Wl,-soname,$@.0 $^ -o $@ $(LIBS) 34 | 35 | # Objects 36 | $(COBJS): %.o: %.c 37 | $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@ 38 | 39 | $(CPPOBJS): %.o: %.cpp 40 | $(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@ 41 | 42 | 43 | clean: 44 | rm -f $(OBJS) hidtest libhidapi.so ../hidtest/hidtest.o 45 | 46 | .PHONY: clean libs 47 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/libusb/Makefile.linux: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Simple Makefile for HIDAPI test program 3 | # 4 | # Alan Ott 5 | # Signal 11 Software 6 | # 2010-06-01 7 | ########################################### 8 | 9 | all: hidtest-libusb libs 10 | 11 | libs: libhidapi-libusb.so 12 | 13 | CC ?= gcc 14 | CFLAGS ?= -Wall -g -fpic 15 | 16 | CXX ?= g++ 17 | CXXFLAGS ?= -Wall -g -fpic 18 | 19 | LDFLAGS ?= -Wall -g 20 | 21 | COBJS_LIBUSB = hid.o 22 | COBJS = $(COBJS_LIBUSB) 23 | CPPOBJS = ../hidtest/hidtest.o 24 | OBJS = $(COBJS) $(CPPOBJS) 25 | LIBS_USB = `pkg-config libusb-1.0 --libs` -lrt -lpthread 26 | LIBS = $(LIBS_USB) 27 | INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags` 28 | 29 | 30 | # Console Test Program 31 | hidtest-libusb: $(COBJS_LIBUSB) $(CPPOBJS) 32 | $(CXX) $(LDFLAGS) $^ $(LIBS_USB) -o $@ 33 | 34 | # Shared Libs 35 | libhidapi-libusb.so: $(COBJS_LIBUSB) 36 | $(CC) $(LDFLAGS) $(LIBS_USB) -shared -fpic -Wl,-soname,$@.0 $^ -o $@ 37 | 38 | # Objects 39 | $(COBJS): %.o: %.c 40 | $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@ 41 | 42 | $(CPPOBJS): %.o: %.cpp 43 | $(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@ 44 | 45 | 46 | clean: 47 | rm -f $(OBJS) hidtest-libusb libhidapi-libusb.so ../hidtest/hidtest.o 48 | 49 | .PHONY: clean libs 50 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/linux/.npmignore: -------------------------------------------------------------------------------- 1 | Debug 2 | Release 3 | *.exp 4 | *.ilk 5 | *.lib 6 | *.suo 7 | *.vcproj.* 8 | *.ncb 9 | *.suo 10 | *.dll 11 | *.pdb 12 | *.o 13 | *.so 14 | hidtest-hidraw 15 | .deps 16 | .libs 17 | *.lo 18 | *.la 19 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/linux/Makefile-manual: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Simple Makefile for HIDAPI test program 3 | # 4 | # Alan Ott 5 | # Signal 11 Software 6 | # 2010-06-01 7 | ########################################### 8 | 9 | all: hidtest-hidraw libs 10 | 11 | libs: libhidapi-hidraw.so 12 | 13 | CC ?= gcc 14 | CFLAGS ?= -Wall -g -fpic 15 | 16 | CXX ?= g++ 17 | CXXFLAGS ?= -Wall -g -fpic 18 | 19 | LDFLAGS ?= -Wall -g 20 | 21 | 22 | COBJS = hid.o 23 | CPPOBJS = ../hidtest/hidtest.o 24 | OBJS = $(COBJS) $(CPPOBJS) 25 | LIBS_UDEV = `pkg-config libudev --libs` -lrt 26 | LIBS = $(LIBS_UDEV) 27 | INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags` 28 | 29 | 30 | # Console Test Program 31 | hidtest-hidraw: $(COBJS) $(CPPOBJS) 32 | $(CXX) $(LDFLAGS) $^ $(LIBS_UDEV) -o $@ 33 | 34 | # Shared Libs 35 | libhidapi-hidraw.so: $(COBJS) 36 | $(CC) $(LDFLAGS) $(LIBS_UDEV) -shared -fpic -Wl,-soname,$@.0 $^ -o $@ 37 | 38 | # Objects 39 | $(COBJS): %.o: %.c 40 | $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@ 41 | 42 | $(CPPOBJS): %.o: %.cpp 43 | $(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@ 44 | 45 | 46 | clean: 47 | rm -f $(OBJS) hidtest-hidraw libhidapi-hidraw.so ../hidtest/hidtest.o 48 | 49 | .PHONY: clean libs 50 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/linux/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libhidapi-hidraw.la 2 | libhidapi_hidraw_la_SOURCES = hid.c 3 | libhidapi_hidraw_la_LDFLAGS = $(LTLDFLAGS) 4 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ $(CFLAGS_HIDRAW) 5 | libhidapi_hidraw_la_LIBADD = $(LIBS_HIDRAW) 6 | 7 | hdrdir = $(includedir)/hidapi 8 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h 9 | 10 | EXTRA_DIST = Makefile-manual 11 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/linux/README.txt: -------------------------------------------------------------------------------- 1 | 2 | There are two implementations of HIDAPI for Linux. One (hid.c) uses the 3 | Linux hidraw driver, and the other (hid-libusb.c) uses libusb. Which one you 4 | use depends on your application. Complete functionality of the hidraw 5 | version depends on patches to the Linux kernel which are not currently in 6 | the mainline. These patches have to do with sending and receiving feature 7 | reports. The libusb implementation uses libusb to talk directly to the 8 | device, bypassing any Linux HID driver. The disadvantage of the libusb 9 | version is that it will only work with USB devices, while the hidraw 10 | implementation will work with Bluetooth devices as well. 11 | 12 | To use HIDAPI, simply drop either hid.c or hid-libusb.c into your 13 | application and build using the build parameters in the Makefile. 14 | 15 | By default, on Linux, the Makefile in this directory is configured to use 16 | the libusb implementation. To switch to the hidraw implementation, simply 17 | change hid-libusb.c to hid.c in the Makefile. 18 | 19 | 20 | Libusb Implementation notes 21 | ---------------------------- 22 | For the libusb implementation, libusb-1.0 must be installed. Libusb 1.0 is 23 | different than the legacy libusb 0.1 which is installed on many systems. To 24 | install libusb-1.0 on Ubuntu and other Debian-based systems, run: 25 | sudo apt-get install libusb-1.0-0-dev 26 | 27 | 28 | Hidraw Implementation notes 29 | ---------------------------- 30 | For the hidraw implementation, libudev headers and libraries are required to 31 | build hidapi programs. To install libudev libraries on Ubuntu, 32 | and other Debian-based systems, run: 33 | sudo apt-get install libudev-dev 34 | 35 | On Redhat-based systems, run the following as root: 36 | yum install libudev-devel 37 | 38 | Unfortunately, the hidraw driver, which the linux version of hidapi is based 39 | on, contains bugs in kernel versions < 2.6.36, which the client application 40 | should be aware of. 41 | 42 | Bugs (hidraw implementation only): 43 | ----------------------------------- 44 | On Kernel versions < 2.6.34, if your device uses numbered reports, an extra 45 | byte will be returned at the beginning of all reports returned from read() 46 | for hidraw devices. This is worked around in the libary. No action should be 47 | necessary in the client library. 48 | 49 | On Kernel versions < 2.6.35, reports will only be sent using a Set_Report 50 | transfer on the CONTROL endpoint. No data will ever be sent on an Interrupt 51 | Out endpoint if one exists. This is fixed in 2.6.35. In 2.6.35, OUTPUT 52 | reports will be sent to the device on the first INTERRUPT OUT endpoint if it 53 | exists; If it does not exist, OUTPUT reports will be sent on the CONTROL 54 | endpoint. 55 | 56 | On Kernel versions < 2.6.36, add an extra byte containing the report number 57 | to sent reports if numbered reports are used, and the device does not 58 | contain an INTERRPUT OUT endpoint for OUTPUT transfers. For example, if 59 | your device uses numbered reports and wants to send {0x2 0xff 0xff 0xff} to 60 | the device (0x2 is the report number), you must send {0x2 0x2 0xff 0xff 61 | 0xff}. If your device has the optional Interrupt OUT endpoint, this does not 62 | apply (but really on 2.6.35 only, because 2.6.34 won't use the interrupt 63 | out endpoint). 64 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/m4/.npmignore: -------------------------------------------------------------------------------- 1 | # Ignore All, except pkg.m4, and of course this file. 2 | * 3 | !.gitignore 4 | !pkg.m4 5 | !ax_pthread.m4 6 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/m4/ax_pthread.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_pthread.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # This macro figures out how to build C programs using POSIX threads. It 12 | # sets the PTHREAD_LIBS output variable to the threads library and linker 13 | # flags, and the PTHREAD_CFLAGS output variable to any special C compiler 14 | # flags that are needed. (The user can also force certain compiler 15 | # flags/libs to be tested by setting these environment variables.) 16 | # 17 | # Also sets PTHREAD_CC to any special C compiler that is needed for 18 | # multi-threaded programs (defaults to the value of CC otherwise). (This 19 | # is necessary on AIX to use the special cc_r compiler alias.) 20 | # 21 | # NOTE: You are assumed to not only compile your program with these flags, 22 | # but also link it with them as well. e.g. you should link with 23 | # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS 24 | # 25 | # If you are only building threads programs, you may wish to use these 26 | # variables in your default LIBS, CFLAGS, and CC: 27 | # 28 | # LIBS="$PTHREAD_LIBS $LIBS" 29 | # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 30 | # CC="$PTHREAD_CC" 31 | # 32 | # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant 33 | # has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name 34 | # (e.g. PTHREAD_CREATE_UNDETACHED on AIX). 35 | # 36 | # Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the 37 | # PTHREAD_PRIO_INHERIT symbol is defined when compiling with 38 | # PTHREAD_CFLAGS. 39 | # 40 | # ACTION-IF-FOUND is a list of shell commands to run if a threads library 41 | # is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it 42 | # is not found. If ACTION-IF-FOUND is not specified, the default action 43 | # will define HAVE_PTHREAD. 44 | # 45 | # Please let the authors know if this macro fails on any platform, or if 46 | # you have any other suggestions or comments. This macro was based on work 47 | # by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help 48 | # from M. Frigo), as well as ac_pthread and hb_pthread macros posted by 49 | # Alejandro Forero Cuervo to the autoconf macro repository. We are also 50 | # grateful for the helpful feedback of numerous users. 51 | # 52 | # Updated for Autoconf 2.68 by Daniel Richard G. 53 | # 54 | # LICENSE 55 | # 56 | # Copyright (c) 2008 Steven G. Johnson 57 | # Copyright (c) 2011 Daniel Richard G. 58 | # 59 | # This program is free software: you can redistribute it and/or modify it 60 | # under the terms of the GNU General Public License as published by the 61 | # Free Software Foundation, either version 3 of the License, or (at your 62 | # option) any later version. 63 | # 64 | # This program is distributed in the hope that it will be useful, but 65 | # WITHOUT ANY WARRANTY; without even the implied warranty of 66 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 67 | # Public License for more details. 68 | # 69 | # You should have received a copy of the GNU General Public License along 70 | # with this program. If not, see . 71 | # 72 | # As a special exception, the respective Autoconf Macro's copyright owner 73 | # gives unlimited permission to copy, distribute and modify the configure 74 | # scripts that are the output of Autoconf when processing the Macro. You 75 | # need not follow the terms of the GNU General Public License when using 76 | # or distributing such scripts, even though portions of the text of the 77 | # Macro appear in them. The GNU General Public License (GPL) does govern 78 | # all other use of the material that constitutes the Autoconf Macro. 79 | # 80 | # This special exception to the GPL applies to versions of the Autoconf 81 | # Macro released by the Autoconf Archive. When you make and distribute a 82 | # modified version of the Autoconf Macro, you may extend this special 83 | # exception to the GPL to apply to your modified version as well. 84 | 85 | #serial 18 86 | 87 | AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) 88 | AC_DEFUN([AX_PTHREAD], [ 89 | AC_REQUIRE([AC_CANONICAL_HOST]) 90 | AC_LANG_PUSH([C]) 91 | ax_pthread_ok=no 92 | 93 | # We used to check for pthread.h first, but this fails if pthread.h 94 | # requires special compiler flags (e.g. on True64 or Sequent). 95 | # It gets checked for in the link test anyway. 96 | 97 | # First of all, check if the user has set any of the PTHREAD_LIBS, 98 | # etcetera environment variables, and if threads linking works using 99 | # them: 100 | if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then 101 | save_CFLAGS="$CFLAGS" 102 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 103 | save_LIBS="$LIBS" 104 | LIBS="$PTHREAD_LIBS $LIBS" 105 | AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) 106 | AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes) 107 | AC_MSG_RESULT($ax_pthread_ok) 108 | if test x"$ax_pthread_ok" = xno; then 109 | PTHREAD_LIBS="" 110 | PTHREAD_CFLAGS="" 111 | fi 112 | LIBS="$save_LIBS" 113 | CFLAGS="$save_CFLAGS" 114 | fi 115 | 116 | # We must check for the threads library under a number of different 117 | # names; the ordering is very important because some systems 118 | # (e.g. DEC) have both -lpthread and -lpthreads, where one of the 119 | # libraries is broken (non-POSIX). 120 | 121 | # Create a list of thread flags to try. Items starting with a "-" are 122 | # C compiler flags, and other items are library names, except for "none" 123 | # which indicates that we try without any flags at all, and "pthread-config" 124 | # which is a program returning the flags for the Pth emulation library. 125 | 126 | ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" 127 | 128 | # The ordering *is* (sometimes) important. Some notes on the 129 | # individual items follow: 130 | 131 | # pthreads: AIX (must check this before -lpthread) 132 | # none: in case threads are in libc; should be tried before -Kthread and 133 | # other compiler flags to prevent continual compiler warnings 134 | # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) 135 | # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) 136 | # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) 137 | # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) 138 | # -pthreads: Solaris/gcc 139 | # -mthreads: Mingw32/gcc, Lynx/gcc 140 | # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it 141 | # doesn't hurt to check since this sometimes defines pthreads too; 142 | # also defines -D_REENTRANT) 143 | # ... -mt is also the pthreads flag for HP/aCC 144 | # pthread: Linux, etcetera 145 | # --thread-safe: KAI C++ 146 | # pthread-config: use pthread-config program (for GNU Pth library) 147 | 148 | case ${host_os} in 149 | solaris*) 150 | 151 | # On Solaris (at least, for some versions), libc contains stubbed 152 | # (non-functional) versions of the pthreads routines, so link-based 153 | # tests will erroneously succeed. (We need to link with -pthreads/-mt/ 154 | # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather 155 | # a function called by this macro, so we could check for that, but 156 | # who knows whether they'll stub that too in a future libc.) So, 157 | # we'll just look for -pthreads and -lpthread first: 158 | 159 | ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" 160 | ;; 161 | 162 | darwin*) 163 | ax_pthread_flags="-pthread $ax_pthread_flags" 164 | ;; 165 | esac 166 | 167 | if test x"$ax_pthread_ok" = xno; then 168 | for flag in $ax_pthread_flags; do 169 | 170 | case $flag in 171 | none) 172 | AC_MSG_CHECKING([whether pthreads work without any flags]) 173 | ;; 174 | 175 | -*) 176 | AC_MSG_CHECKING([whether pthreads work with $flag]) 177 | PTHREAD_CFLAGS="$flag" 178 | ;; 179 | 180 | pthread-config) 181 | AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no) 182 | if test x"$ax_pthread_config" = xno; then continue; fi 183 | PTHREAD_CFLAGS="`pthread-config --cflags`" 184 | PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" 185 | ;; 186 | 187 | *) 188 | AC_MSG_CHECKING([for the pthreads library -l$flag]) 189 | PTHREAD_LIBS="-l$flag" 190 | ;; 191 | esac 192 | 193 | save_LIBS="$LIBS" 194 | save_CFLAGS="$CFLAGS" 195 | LIBS="$PTHREAD_LIBS $LIBS" 196 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 197 | 198 | # Check for various functions. We must include pthread.h, 199 | # since some functions may be macros. (On the Sequent, we 200 | # need a special flag -Kthread to make this header compile.) 201 | # We check for pthread_join because it is in -lpthread on IRIX 202 | # while pthread_create is in libc. We check for pthread_attr_init 203 | # due to DEC craziness with -lpthreads. We check for 204 | # pthread_cleanup_push because it is one of the few pthread 205 | # functions on Solaris that doesn't have a non-functional libc stub. 206 | # We try pthread_create on general principles. 207 | AC_LINK_IFELSE([AC_LANG_PROGRAM([#include 208 | static void routine(void *a) { a = 0; } 209 | static void *start_routine(void *a) { return a; }], 210 | [pthread_t th; pthread_attr_t attr; 211 | pthread_create(&th, 0, start_routine, 0); 212 | pthread_join(th, 0); 213 | pthread_attr_init(&attr); 214 | pthread_cleanup_push(routine, 0); 215 | pthread_cleanup_pop(0) /* ; */])], 216 | [ax_pthread_ok=yes], 217 | []) 218 | 219 | LIBS="$save_LIBS" 220 | CFLAGS="$save_CFLAGS" 221 | 222 | AC_MSG_RESULT($ax_pthread_ok) 223 | if test "x$ax_pthread_ok" = xyes; then 224 | break; 225 | fi 226 | 227 | PTHREAD_LIBS="" 228 | PTHREAD_CFLAGS="" 229 | done 230 | fi 231 | 232 | # Various other checks: 233 | if test "x$ax_pthread_ok" = xyes; then 234 | save_LIBS="$LIBS" 235 | LIBS="$PTHREAD_LIBS $LIBS" 236 | save_CFLAGS="$CFLAGS" 237 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 238 | 239 | # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. 240 | AC_MSG_CHECKING([for joinable pthread attribute]) 241 | attr_name=unknown 242 | for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do 243 | AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], 244 | [int attr = $attr; return attr /* ; */])], 245 | [attr_name=$attr; break], 246 | []) 247 | done 248 | AC_MSG_RESULT($attr_name) 249 | if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then 250 | AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, 251 | [Define to necessary symbol if this constant 252 | uses a non-standard name on your system.]) 253 | fi 254 | 255 | AC_MSG_CHECKING([if more special flags are required for pthreads]) 256 | flag=no 257 | case ${host_os} in 258 | aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; 259 | osf* | hpux*) flag="-D_REENTRANT";; 260 | solaris*) 261 | if test "$GCC" = "yes"; then 262 | flag="-D_REENTRANT" 263 | else 264 | flag="-mt -D_REENTRANT" 265 | fi 266 | ;; 267 | esac 268 | AC_MSG_RESULT(${flag}) 269 | if test "x$flag" != xno; then 270 | PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" 271 | fi 272 | 273 | AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], 274 | ax_cv_PTHREAD_PRIO_INHERIT, [ 275 | AC_LINK_IFELSE([ 276 | AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_PRIO_INHERIT;]])], 277 | [ax_cv_PTHREAD_PRIO_INHERIT=yes], 278 | [ax_cv_PTHREAD_PRIO_INHERIT=no]) 279 | ]) 280 | AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], 281 | AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.])) 282 | 283 | LIBS="$save_LIBS" 284 | CFLAGS="$save_CFLAGS" 285 | 286 | # More AIX lossage: must compile with xlc_r or cc_r 287 | if test x"$GCC" != xyes; then 288 | AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) 289 | else 290 | PTHREAD_CC=$CC 291 | fi 292 | else 293 | PTHREAD_CC="$CC" 294 | fi 295 | 296 | AC_SUBST(PTHREAD_LIBS) 297 | AC_SUBST(PTHREAD_CFLAGS) 298 | AC_SUBST(PTHREAD_CC) 299 | 300 | # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: 301 | if test x"$ax_pthread_ok" = xyes; then 302 | ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) 303 | : 304 | else 305 | ax_pthread_ok=no 306 | $2 307 | fi 308 | AC_LANG_POP 309 | ])dnl AX_PTHREAD 310 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/m4/pkg.m4: -------------------------------------------------------------------------------- 1 | # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- 2 | # 3 | # Copyright © 2004 Scott James Remnant . 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | # 19 | # As a special exception to the GNU General Public License, if you 20 | # distribute this file as part of a program that contains a 21 | # configuration script generated by Autoconf, you may include it under 22 | # the same distribution terms that you use for the rest of that program. 23 | 24 | # PKG_PROG_PKG_CONFIG([MIN-VERSION]) 25 | # ---------------------------------- 26 | AC_DEFUN([PKG_PROG_PKG_CONFIG], 27 | [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) 28 | m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) 29 | AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl 30 | if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then 31 | AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) 32 | fi 33 | if test -n "$PKG_CONFIG"; then 34 | _pkg_min_version=m4_default([$1], [0.9.0]) 35 | AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) 36 | if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then 37 | AC_MSG_RESULT([yes]) 38 | else 39 | AC_MSG_RESULT([no]) 40 | PKG_CONFIG="" 41 | fi 42 | 43 | fi[]dnl 44 | ])# PKG_PROG_PKG_CONFIG 45 | 46 | # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 47 | # 48 | # Check to see whether a particular set of modules exists. Similar 49 | # to PKG_CHECK_MODULES(), but does not set variables or print errors. 50 | # 51 | # 52 | # Similar to PKG_CHECK_MODULES, make sure that the first instance of 53 | # this or PKG_CHECK_MODULES is called, or make sure to call 54 | # PKG_CHECK_EXISTS manually 55 | # -------------------------------------------------------------- 56 | AC_DEFUN([PKG_CHECK_EXISTS], 57 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 58 | if test -n "$PKG_CONFIG" && \ 59 | AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then 60 | m4_ifval([$2], [$2], [:]) 61 | m4_ifvaln([$3], [else 62 | $3])dnl 63 | fi]) 64 | 65 | 66 | # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) 67 | # --------------------------------------------- 68 | m4_define([_PKG_CONFIG], 69 | [if test -n "$PKG_CONFIG"; then 70 | if test -n "$$1"; then 71 | pkg_cv_[]$1="$$1" 72 | else 73 | PKG_CHECK_EXISTS([$3], 74 | [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], 75 | [pkg_failed=yes]) 76 | fi 77 | else 78 | pkg_failed=untried 79 | fi[]dnl 80 | ])# _PKG_CONFIG 81 | 82 | # _PKG_SHORT_ERRORS_SUPPORTED 83 | # ----------------------------- 84 | AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], 85 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 86 | if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then 87 | _pkg_short_errors_supported=yes 88 | else 89 | _pkg_short_errors_supported=no 90 | fi[]dnl 91 | ])# _PKG_SHORT_ERRORS_SUPPORTED 92 | 93 | 94 | # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], 95 | # [ACTION-IF-NOT-FOUND]) 96 | # 97 | # 98 | # Note that if there is a possibility the first call to 99 | # PKG_CHECK_MODULES might not happen, you should be sure to include an 100 | # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac 101 | # 102 | # 103 | # -------------------------------------------------------------- 104 | AC_DEFUN([PKG_CHECK_MODULES], 105 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 106 | AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl 107 | AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl 108 | 109 | pkg_failed=no 110 | AC_MSG_CHECKING([for $1]) 111 | 112 | _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) 113 | _PKG_CONFIG([$1][_LIBS], [libs], [$2]) 114 | 115 | m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS 116 | and $1[]_LIBS to avoid the need to call pkg-config. 117 | See the pkg-config man page for more details.]) 118 | 119 | if test $pkg_failed = yes; then 120 | _PKG_SHORT_ERRORS_SUPPORTED 121 | if test $_pkg_short_errors_supported = yes; then 122 | $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` 123 | else 124 | $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` 125 | fi 126 | # Put the nasty error message in config.log where it belongs 127 | echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD 128 | 129 | ifelse([$4], , [AC_MSG_ERROR(dnl 130 | [Package requirements ($2) were not met: 131 | 132 | $$1_PKG_ERRORS 133 | 134 | Consider adjusting the PKG_CONFIG_PATH environment variable if you 135 | installed software in a non-standard prefix. 136 | 137 | _PKG_TEXT 138 | ])], 139 | [AC_MSG_RESULT([no]) 140 | $4]) 141 | elif test $pkg_failed = untried; then 142 | ifelse([$4], , [AC_MSG_FAILURE(dnl 143 | [The pkg-config script could not be found or is too old. Make sure it 144 | is in your PATH or set the PKG_CONFIG environment variable to the full 145 | path to pkg-config. 146 | 147 | _PKG_TEXT 148 | 149 | To get pkg-config, see .])], 150 | [$4]) 151 | else 152 | $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS 153 | $1[]_LIBS=$pkg_cv_[]$1[]_LIBS 154 | AC_MSG_RESULT([yes]) 155 | ifelse([$3], , :, [$3]) 156 | fi[]dnl 157 | ])# PKG_CHECK_MODULES 158 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/mac/.npmignore: -------------------------------------------------------------------------------- 1 | Debug 2 | Release 3 | *.exp 4 | *.ilk 5 | *.lib 6 | *.suo 7 | *.vcproj.* 8 | *.ncb 9 | *.suo 10 | *.dll 11 | *.pdb 12 | *.o 13 | hidapi-hidtest 14 | .deps 15 | .libs 16 | *.la 17 | *.lo 18 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/mac/Makefile-manual: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Simple Makefile for HIDAPI test program 3 | # 4 | # Alan Ott 5 | # Signal 11 Software 6 | # 2010-07-03 7 | ########################################### 8 | 9 | all: hidtest 10 | 11 | CC=gcc 12 | CXX=g++ 13 | COBJS=hid.o 14 | CPPOBJS=../hidtest/hidtest.o 15 | OBJS=$(COBJS) $(CPPOBJS) 16 | CFLAGS+=-I../hidapi -Wall -g -c 17 | LIBS=-framework IOKit -framework CoreFoundation 18 | 19 | 20 | hidtest: $(OBJS) 21 | g++ -Wall -g $^ $(LIBS) -o hidtest 22 | 23 | $(COBJS): %.o: %.c 24 | $(CC) $(CFLAGS) $< -o $@ 25 | 26 | $(CPPOBJS): %.o: %.cpp 27 | $(CXX) $(CFLAGS) $< -o $@ 28 | 29 | clean: 30 | rm -f *.o hidtest $(CPPOBJS) 31 | 32 | .PHONY: clean 33 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/mac/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libhidapi.la 2 | libhidapi_la_SOURCES = hid.c 3 | libhidapi_la_LDFLAGS = $(LTLDFLAGS) 4 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ 5 | 6 | hdrdir = $(includedir)/hidapi 7 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h 8 | 9 | EXTRA_DIST = Makefile-manual 10 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/pc/.npmignore: -------------------------------------------------------------------------------- 1 | *.pc 2 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/pc/hidapi-hidraw.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: hidapi-hidraw 7 | Description: C Library for USB/Bluetooth HID device access from Linux, Mac OS X, FreeBSD, and Windows. This is the hidraw implementation. 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lhidapi-hidraw 10 | Cflags: -I${includedir}/hidapi 11 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/pc/hidapi-libusb.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: hidapi-libusb 7 | Description: C Library for USB HID device access from Linux, Mac OS X, FreeBSD, and Windows. This is the libusb implementation. 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lhidapi-libusb 10 | Cflags: -I${includedir}/hidapi 11 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/pc/hidapi.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: hidapi 7 | Description: C Library for USB/Bluetooth HID device access from Linux, Mac OS X, FreeBSD, and Windows. 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lhidapi 10 | Cflags: -I${includedir}/hidapi 11 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/.npmignore: -------------------------------------------------------------------------------- 1 | Debug 2 | Release 3 | *.exp 4 | *.ilk 5 | *.lib 6 | *.suo 7 | *.vcproj.* 8 | *.ncb 9 | *.suo 10 | *.dll 11 | *.pdb 12 | *.o 13 | hidapi-testgui 14 | hidapi-hidraw-testgui 15 | hidapi-libusb-testgui 16 | .deps 17 | .libs 18 | *.la 19 | *.lo 20 | TestGUI.app 21 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/Makefile-manual: -------------------------------------------------------------------------------- 1 | 2 | 3 | OS=$(shell uname) 4 | 5 | ifeq ($(OS), Darwin) 6 | FILE=Makefile.mac 7 | endif 8 | 9 | ifneq (,$(findstring MINGW,$(OS))) 10 | FILE=Makefile.mingw 11 | endif 12 | 13 | ifeq ($(OS), Linux) 14 | FILE=Makefile.linux 15 | endif 16 | 17 | ifeq ($(OS), FreeBSD) 18 | FILE=Makefile.freebsd 19 | endif 20 | 21 | ifeq ($(FILE), ) 22 | all: 23 | $(error Your platform ${OS} is not supported at this time.) 24 | endif 25 | 26 | include $(FILE) 27 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ $(CFLAGS_TESTGUI) 3 | 4 | if OS_LINUX 5 | ## Linux 6 | bin_PROGRAMS = hidapi-hidraw-testgui hidapi-libusb-testgui 7 | 8 | hidapi_hidraw_testgui_SOURCES = test.cpp 9 | hidapi_hidraw_testgui_LDADD = $(top_builddir)/linux/libhidapi-hidraw.la $(LIBS_TESTGUI) 10 | 11 | hidapi_libusb_testgui_SOURCES = test.cpp 12 | hidapi_libusb_testgui_LDADD = $(top_builddir)/libusb/libhidapi-libusb.la $(LIBS_TESTGUI) 13 | else 14 | ## Other OS's 15 | bin_PROGRAMS = hidapi-testgui 16 | 17 | hidapi_testgui_SOURCES = test.cpp 18 | hidapi_testgui_LDADD = $(top_builddir)/$(backend)/libhidapi.la $(LIBS_TESTGUI) 19 | endif 20 | 21 | if OS_DARWIN 22 | hidapi_testgui_SOURCES = test.cpp mac_support_cocoa.m mac_support.h 23 | # Rules for copying the binary and its dependencies into the app bundle. 24 | TestGUI.app/Contents/MacOS/hidapi-testgui$(EXEEXT): hidapi-testgui$(EXEEXT) 25 | $(srcdir)/copy_to_bundle.sh 26 | 27 | all: all-am TestGUI.app/Contents/MacOS/hidapi-testgui$(EXEEXT) 28 | 29 | endif 30 | 31 | EXTRA_DIST = \ 32 | copy_to_bundle.sh \ 33 | Makefile-manual \ 34 | Makefile.freebsd \ 35 | Makefile.linux \ 36 | Makefile.mac \ 37 | Makefile.mingw \ 38 | TestGUI.app.in \ 39 | testgui.sln \ 40 | testgui.vcproj 41 | 42 | distclean-local: 43 | rm -rf TestGUI.app 44 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/Makefile.freebsd: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Simple Makefile for HIDAPI test program 3 | # 4 | # Alan Ott 5 | # Signal 11 Software 6 | # 2010-06-01 7 | ########################################### 8 | 9 | all: testgui 10 | 11 | CC=cc 12 | CXX=c++ 13 | COBJS=../libusb/hid.o 14 | CPPOBJS=test.o 15 | OBJS=$(COBJS) $(CPPOBJS) 16 | CFLAGS=-I../hidapi -I/usr/local/include `fox-config --cflags` -Wall -g -c 17 | LDFLAGS= -L/usr/local/lib 18 | LIBS= -lusb -liconv `fox-config --libs` -pthread 19 | 20 | 21 | testgui: $(OBJS) 22 | $(CXX) -Wall -g $^ $(LDFLAGS) -o $@ $(LIBS) 23 | 24 | $(COBJS): %.o: %.c 25 | $(CC) $(CFLAGS) $< -o $@ 26 | 27 | $(CPPOBJS): %.o: %.cpp 28 | $(CXX) $(CFLAGS) $< -o $@ 29 | 30 | clean: 31 | rm *.o testgui 32 | 33 | .PHONY: clean 34 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/Makefile.linux: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Simple Makefile for HIDAPI test program 3 | # 4 | # Alan Ott 5 | # Signal 11 Software 6 | # 2010-06-01 7 | ########################################### 8 | 9 | all: testgui 10 | 11 | CC=gcc 12 | CXX=g++ 13 | COBJS=../libusb/hid.o 14 | CPPOBJS=test.o 15 | OBJS=$(COBJS) $(CPPOBJS) 16 | CFLAGS=-I../hidapi -Wall -g -c `fox-config --cflags` `pkg-config libusb-1.0 --cflags` 17 | LIBS=-ludev -lrt -lpthread `fox-config --libs` `pkg-config libusb-1.0 --libs` 18 | 19 | 20 | testgui: $(OBJS) 21 | g++ -Wall -g $^ $(LIBS) -o testgui 22 | 23 | $(COBJS): %.o: %.c 24 | $(CC) $(CFLAGS) $< -o $@ 25 | 26 | $(CPPOBJS): %.o: %.cpp 27 | $(CXX) $(CFLAGS) $< -o $@ 28 | 29 | clean: 30 | rm *.o testgui 31 | 32 | .PHONY: clean 33 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/Makefile.mac: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Simple Makefile for HIDAPI test program 3 | # 4 | # Alan Ott 5 | # Signal 11 Software 6 | # 2010-07-03 7 | ########################################### 8 | 9 | all: hidapi-testgui 10 | 11 | CC=gcc 12 | CXX=g++ 13 | COBJS=../mac/hid.o 14 | CPPOBJS=test.o 15 | OBJCOBJS=mac_support_cocoa.o 16 | OBJS=$(COBJS) $(CPPOBJS) $(OBJCOBJS) 17 | CFLAGS=-I../hidapi -Wall -g -c `fox-config --cflags` 18 | LDFLAGS=-L/usr/X11R6/lib 19 | LIBS=`fox-config --libs` -framework IOKit -framework CoreFoundation -framework Cocoa 20 | 21 | 22 | hidapi-testgui: $(OBJS) TestGUI.app 23 | g++ -Wall -g $(OBJS) $(LIBS) $(LDFLAGS) -o hidapi-testgui 24 | ./copy_to_bundle.sh 25 | #cp TestGUI.app/Contents/MacOS/hidapi-testgui TestGUI.app/Contents/MacOS/tg 26 | #cp start.sh TestGUI.app/Contents/MacOS/hidapi-testgui 27 | 28 | $(COBJS): %.o: %.c 29 | $(CC) $(CFLAGS) $< -o $@ 30 | 31 | $(CPPOBJS): %.o: %.cpp 32 | $(CXX) $(CFLAGS) $< -o $@ 33 | 34 | $(OBJCOBJS): %.o: %.m 35 | $(CXX) $(CFLAGS) -x objective-c++ $< -o $@ 36 | 37 | TestGUI.app: TestGUI.app.in 38 | rm -Rf TestGUI.app 39 | mkdir -p TestGUI.app 40 | cp -R TestGUI.app.in/ TestGUI.app 41 | 42 | clean: 43 | rm -f $(OBJS) hidapi-testgui 44 | rm -Rf TestGUI.app 45 | 46 | .PHONY: clean 47 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/Makefile.mingw: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Simple Makefile for HIDAPI test program 3 | # 4 | # Alan Ott 5 | # Signal 11 Software 6 | # 2010-06-01 7 | ########################################### 8 | 9 | all: hidapi-testgui 10 | 11 | CC=gcc 12 | CXX=g++ 13 | COBJS=../windows/hid.o 14 | CPPOBJS=test.o 15 | OBJS=$(COBJS) $(CPPOBJS) 16 | CFLAGS=-I../hidapi -I../../hidapi-externals/fox/include -g -c 17 | LIBS= -mwindows -lsetupapi -L../../hidapi-externals/fox/lib -Wl,-Bstatic -lFOX-1.6 -Wl,-Bdynamic -lgdi32 -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32 18 | 19 | 20 | hidapi-testgui: $(OBJS) 21 | g++ -g $^ $(LIBS) -o hidapi-testgui 22 | 23 | $(COBJS): %.o: %.c 24 | $(CC) $(CFLAGS) $< -o $@ 25 | 26 | $(CPPOBJS): %.o: %.cpp 27 | $(CXX) $(CFLAGS) $< -o $@ 28 | 29 | clean: 30 | rm -f *.o hidapi-testgui.exe 31 | 32 | .PHONY: clean 33 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/TestGUI.app.in/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | 9 | CFBundleExecutable 10 | hidapi-testgui 11 | CFBundleIconFile 12 | Signal11.icns 13 | CFBundleIdentifier 14 | us.signal11.hidtestgui 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | testgui 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | CSResourcesFileMapped 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/TestGUI.app.in/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPL???? -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/TestGUI.app.in/Contents/Resources/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsconfcn/nodebots-session/60e2806507d95a9679fd1df9de4d29719164da94/drivers/node-hid/hidapi/testgui/TestGUI.app.in/Contents/Resources/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/TestGUI.app.in/Contents/Resources/Signal11.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsconfcn/nodebots-session/60e2806507d95a9679fd1df9de4d29719164da94/drivers/node-hid/hidapi/testgui/TestGUI.app.in/Contents/Resources/Signal11.icns -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/copy_to_bundle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #### Configuration: 4 | # The name of the executable. It is assumed 5 | # that it is in the current working directory. 6 | EXE_NAME=hidapi-testgui 7 | # Path to the executable directory inside the bundle. 8 | # This must be an absolute path, so use $PWD. 9 | EXEPATH=$PWD/TestGUI.app/Contents/MacOS 10 | # Libraries to explicitly bundle, even though they 11 | # may not be in /opt/local. One per line. These 12 | # are used with grep, so only a portion of the name 13 | # is required. eg: libFOX, libz, etc. 14 | LIBS_TO_BUNDLE=libFOX 15 | 16 | 17 | function copydeps { 18 | local file=$1 19 | # echo "Copying deps for $file...." 20 | local BASE_OF_EXE=`basename $file` 21 | 22 | # A will contain the dependencies of this library 23 | local A=`otool -LX $file |cut -f 1 -d " "` 24 | local i 25 | for i in $A; do 26 | local BASE=`basename $i` 27 | 28 | # See if it's a lib we specifically want to bundle 29 | local bundle_this_lib=0 30 | local j 31 | for j in $LIBS_TO_BUNDLE; do 32 | echo $i |grep -q $j 33 | if [ $? -eq 0 ]; then 34 | bundle_this_lib=1 35 | echo "bundling $i because it's in the list." 36 | break; 37 | fi 38 | done 39 | 40 | # See if it's in /opt/local. Bundle all in /opt/local 41 | local isOptLocal=0 42 | echo $i |grep -q /opt/local 43 | if [ $? -eq 0 ]; then 44 | isOptLocal=1 45 | echo "bundling $i because it's in /opt/local." 46 | fi 47 | 48 | # Bundle the library 49 | if [ $isOptLocal -ne 0 ] || [ $bundle_this_lib -ne 0 ]; then 50 | 51 | # Copy the file into the bundle if it exists. 52 | if [ -f $EXEPATH/$BASE ]; then 53 | z=0 54 | else 55 | cp $i $EXEPATH 56 | chmod 755 $EXEPATH/$BASE 57 | fi 58 | 59 | 60 | # echo "$BASE_OF_EXE depends on $BASE" 61 | 62 | # Fix the paths using install_name_tool and then 63 | # call this function recursively for each dependency 64 | # of this library. 65 | if [ $BASE_OF_EXE != $BASE ]; then 66 | 67 | # Fix the paths 68 | install_name_tool -id @executable_path/$BASE $EXEPATH/$BASE 69 | install_name_tool -change $i @executable_path/$BASE $EXEPATH/$BASE_OF_EXE 70 | 71 | # Call this function (recursive) on 72 | # on each dependency of this library. 73 | copydeps $EXEPATH/$BASE 74 | fi 75 | fi 76 | done 77 | } 78 | 79 | rm -f $EXEPATH/* 80 | 81 | # Copy the binary into the bundle. Use ../libtool to do this if it's 82 | # available beacuse if $EXE_NAME was built with autotools, it will be 83 | # necessary. If ../libtool not available, just use cp to do the copy, but 84 | # only if $EXE_NAME is a binary. 85 | if [ -x ../libtool ]; then 86 | ../libtool --mode=install cp $EXE_NAME $EXEPATH 87 | else 88 | file -bI $EXE_NAME |grep binary 89 | if [ $? -ne 0 ]; then 90 | echo "There is no ../libtool and $EXE_NAME is not a binary." 91 | echo "I'm not sure what to do." 92 | exit 1 93 | else 94 | cp $EXE_NAME $EXEPATH 95 | fi 96 | fi 97 | copydeps $EXEPATH/$EXE_NAME 98 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/mac_support.cpp: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Mac support for HID Test GUI 3 | 4 | Alan Ott 5 | Signal 11 Software 6 | 7 | Some of this code is from Apple Documentation, most notably 8 | http://developer.apple.com/legacy/mac/library/documentation/AppleScript/Conceptual/AppleEvents/AppleEvents.pdf 9 | *******************************/ 10 | 11 | #include 12 | #include 13 | 14 | 15 | extern FXMainWindow *g_main_window; 16 | 17 | static pascal OSErr HandleQuitMessage(const AppleEvent *theAppleEvent, AppleEvent 18 | *reply, long handlerRefcon) 19 | { 20 | puts("Quitting\n"); 21 | FXApp::instance()->exit(); 22 | return 0; 23 | } 24 | 25 | static pascal OSErr HandleReopenMessage(const AppleEvent *theAppleEvent, AppleEvent 26 | *reply, long handlerRefcon) 27 | { 28 | puts("Showing"); 29 | g_main_window->show(); 30 | return 0; 31 | } 32 | 33 | static pascal OSErr HandleWildCardMessage(const AppleEvent *theAppleEvent, AppleEvent 34 | *reply, long handlerRefcon) 35 | { 36 | puts("WildCard\n"); 37 | return 0; 38 | } 39 | 40 | OSStatus AEHandler(EventHandlerCallRef inCaller, EventRef inEvent, void* inRefcon) 41 | { 42 | Boolean release = false; 43 | EventRecord eventRecord; 44 | OSErr ignoreErrForThisSample; 45 | 46 | // Events of type kEventAppleEvent must be removed from the queue 47 | // before being passed to AEProcessAppleEvent. 48 | if (IsEventInQueue(GetMainEventQueue(), inEvent)) 49 | { 50 | // RemoveEventFromQueue will release the event, which will 51 | // destroy it if we don't retain it first. 52 | RetainEvent(inEvent); 53 | release = true; 54 | RemoveEventFromQueue(GetMainEventQueue(), inEvent); 55 | } 56 | // Convert the event ref to the type AEProcessAppleEvent expects. 57 | ConvertEventRefToEventRecord(inEvent, &eventRecord); 58 | ignoreErrForThisSample = AEProcessAppleEvent(&eventRecord); 59 | if (release) 60 | ReleaseEvent(inEvent); 61 | // This Carbon event has been handled, even if no AppleEvent handlers 62 | // were installed for the Apple event. 63 | return noErr; 64 | } 65 | 66 | static void HandleEvent(EventRecord *event) 67 | { 68 | //printf("What: %d message %x\n", event->what, event->message); 69 | if (event->what == osEvt) { 70 | if (((event->message >> 24) & 0xff) == suspendResumeMessage) { 71 | if (event->message & resumeFlag) { 72 | g_main_window->show(); 73 | } 74 | } 75 | } 76 | 77 | #if 0 78 | switch (event->what) 79 | { 80 | case mouseDown: 81 | //HandleMouseDown(event); 82 | break; 83 | case keyDown: 84 | case autoKey: 85 | //HandleKeyPress(event); 86 | break; 87 | case kHighLevelEvent: 88 | puts("Calling ProcessAppleEvent\n"); 89 | AEProcessAppleEvent(event); 90 | break; 91 | } 92 | #endif 93 | } 94 | 95 | void 96 | init_apple_message_system() 97 | { 98 | OSErr err; 99 | static const EventTypeSpec appleEvents[] = 100 | { 101 | { kEventClassAppleEvent, kEventAppleEvent } 102 | }; 103 | 104 | /* Install the handler for Apple Events */ 105 | InstallApplicationEventHandler(NewEventHandlerUPP(AEHandler), 106 | GetEventTypeCount(appleEvents), appleEvents, 0, NULL); 107 | 108 | /* Install handlers for the individual Apple Events that come 109 | from the Dock icon: the Reopen (click), and the Quit messages. */ 110 | err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, 111 | NewAEEventHandlerUPP(HandleQuitMessage), 0, false); 112 | err = AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, 113 | NewAEEventHandlerUPP(HandleReopenMessage), 0, false); 114 | #if 0 115 | // Left as an example of a wild card match. 116 | err = AEInstallEventHandler(kCoreEventClass, typeWildCard, 117 | NewAEEventHandlerUPP(HandleWildMessage), 0, false); 118 | #endif 119 | } 120 | 121 | void 122 | check_apple_events() 123 | { 124 | RgnHandle cursorRgn = NULL; 125 | Boolean gotEvent=TRUE; 126 | EventRecord event; 127 | 128 | while (gotEvent) { 129 | gotEvent = WaitNextEvent(everyEvent, &event, 0L/*timeout*/, cursorRgn); 130 | if (gotEvent) { 131 | HandleEvent(&event); 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/mac_support.h: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Mac support for HID Test GUI 3 | 4 | Alan Ott 5 | Signal 11 Software 6 | 7 | *******************************/ 8 | 9 | #ifndef MAC_SUPPORT_H__ 10 | #define MAC_SUPPORT_H__ 11 | 12 | extern "C" { 13 | void init_apple_message_system(); 14 | void check_apple_events(); 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/mac_support_cocoa.m: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Mac support for HID Test GUI 3 | 4 | Alan Ott 5 | Signal 11 Software 6 | *******************************/ 7 | 8 | #include 9 | #import 10 | 11 | extern FXMainWindow *g_main_window; 12 | 13 | 14 | @interface MyAppDelegate : NSObject 15 | { 16 | } 17 | @end 18 | 19 | @implementation MyAppDelegate 20 | - (void) applicationWillBecomeActive:(NSNotification*)notif 21 | { 22 | printf("WillBecomeActive\n"); 23 | g_main_window->show(); 24 | 25 | } 26 | 27 | - (void) applicationWillTerminate:(NSNotification*)notif 28 | { 29 | /* Doesn't get called. Not sure why */ 30 | printf("WillTerminate\n"); 31 | FXApp::instance()->exit(); 32 | } 33 | 34 | - (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication*)sender 35 | { 36 | /* Doesn't get called. Not sure why */ 37 | printf("ShouldTerminate\n"); 38 | return YES; 39 | } 40 | 41 | - (void) applicationWillHide:(NSNotification*)notif 42 | { 43 | printf("WillHide\n"); 44 | g_main_window->hide(); 45 | } 46 | 47 | - (void) handleQuitEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent 48 | { 49 | printf("QuitEvent\n"); 50 | FXApp::instance()->exit(); 51 | } 52 | 53 | @end 54 | 55 | extern "C" { 56 | 57 | void 58 | init_apple_message_system() 59 | { 60 | static MyAppDelegate *d = [MyAppDelegate new]; 61 | 62 | [[NSApplication sharedApplication] setDelegate:d]; 63 | 64 | /* Register for Apple Events. */ 65 | /* This is from 66 | http://stackoverflow.com/questions/1768497/application-exit-event */ 67 | NSAppleEventManager *aem = [NSAppleEventManager sharedAppleEventManager]; 68 | [aem setEventHandler:d 69 | andSelector:@selector(handleQuitEvent:withReplyEvent:) 70 | forEventClass:kCoreEventClass andEventID:kAEQuitApplication]; 71 | } 72 | 73 | void 74 | check_apple_events() 75 | { 76 | NSApplication *app = [NSApplication sharedApplication]; 77 | 78 | NSAutoreleasePool *pool = [NSAutoreleasePool new]; 79 | while (1) { 80 | NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask 81 | untilDate:nil 82 | inMode:NSDefaultRunLoopMode 83 | dequeue:YES]; 84 | if (event == NULL) 85 | break; 86 | else { 87 | //printf("Event happened: Type: %d\n", event->_type); 88 | [app sendEvent: event]; 89 | } 90 | } 91 | [pool release]; 92 | } 93 | 94 | } /* extern "C" */ 95 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | xterm -e /Users/alan/work/hidapi/testgui/TestGUI.app/Contents/MacOS/tg 3 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/testgui.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual C++ Express 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgui", "testgui.vcproj", "{08769AC3-785A-4DDC-BFC7-1775414B7AB7}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {08769AC3-785A-4DDC-BFC7-1775414B7AB7}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {08769AC3-785A-4DDC-BFC7-1775414B7AB7}.Debug|Win32.Build.0 = Debug|Win32 14 | {08769AC3-785A-4DDC-BFC7-1775414B7AB7}.Release|Win32.ActiveCfg = Release|Win32 15 | {08769AC3-785A-4DDC-BFC7-1775414B7AB7}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/testgui/testgui.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 26 | 29 | 32 | 35 | 38 | 41 | 53 | 56 | 59 | 62 | 73 | 76 | 79 | 82 | 85 | 88 | 91 | 95 | 96 | 104 | 107 | 110 | 113 | 116 | 119 | 131 | 134 | 137 | 140 | 153 | 156 | 159 | 162 | 165 | 168 | 171 | 175 | 176 | 177 | 178 | 179 | 180 | 185 | 188 | 189 | 192 | 193 | 194 | 199 | 202 | 203 | 204 | 209 | 210 | 213 | 214 | 215 | 216 | 217 | 218 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/udev/99-hid.rules: -------------------------------------------------------------------------------- 1 | # This is a sample udev file for HIDAPI devices which changes the permissions 2 | # to 0666 (world readable/writable) for a specified device on Linux systems. 3 | 4 | 5 | # If you are using the libusb implementation of hidapi (hid-libusb.c), then 6 | # use something like the following line, substituting the VID and PID with 7 | # those of your device. Note that for kernels before 2.6.24, you will need 8 | # to substitute "usb" with "usb_device". It shouldn't hurt to use two lines 9 | # (one each way) for compatibility with older systems. 10 | 11 | # HIDAPI/libusb 12 | SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="003f", MODE="0666" 13 | 14 | 15 | # If you are using the hidraw implementation, then do something like the 16 | # following, substituting the VID and PID with your device. Busnum 1 is USB. 17 | 18 | # HIDAPI/hidraw 19 | KERNEL=="hidraw*", ATTRS{busnum}=="1", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="003f", MODE="0666" 20 | 21 | # Once done, optionally rename this file for your device, and drop it into 22 | # /etc/udev/rules.d and unplug and re-plug your device. This is all that is 23 | # necessary to see the new permissions. Udev does not have to be restarted. 24 | 25 | # Note that the hexadecimal values for VID and PID are case sensitive and 26 | # must be lower case. 27 | 28 | # If you think permissions of 0666 are too loose, then see: 29 | # http://reactivated.net/writing_udev_rules.html for more information on finer 30 | # grained permission setting. For example, it might be sufficient to just 31 | # set the group or user owner for specific devices (for example the plugdev 32 | # group on some systems). 33 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/.npmignore: -------------------------------------------------------------------------------- 1 | Debug 2 | Release 3 | *.exp 4 | *.ilk 5 | *.lib 6 | *.suo 7 | *.vcproj.* 8 | *.ncb 9 | *.suo 10 | *.dll 11 | *.pdb 12 | .deps 13 | .libs 14 | *.lo 15 | *.la 16 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/Makefile-manual: -------------------------------------------------------------------------------- 1 | 2 | 3 | OS=$(shell uname) 4 | 5 | ifneq (,$(findstring MINGW,$(OS))) 6 | FILE=Makefile.mingw 7 | endif 8 | 9 | ifeq ($(FILE), ) 10 | all: 11 | $(error Your platform ${OS} is not supported at this time.) 12 | endif 13 | 14 | include $(FILE) 15 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libhidapi.la 2 | libhidapi_la_SOURCES = hid.c 3 | libhidapi_la_LDFLAGS = $(LTLDFLAGS) 4 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ 5 | libhidapi_la_LIBADD = $(LIBS) 6 | 7 | hdrdir = $(includedir)/hidapi 8 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h 9 | 10 | EXTRA_DIST = \ 11 | ddk_build \ 12 | hidapi.vcproj \ 13 | hidtest.vcproj \ 14 | Makefile-manual \ 15 | Makefile.mingw \ 16 | hidapi.sln 17 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/Makefile.mingw: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Simple Makefile for HIDAPI test program 3 | # 4 | # Alan Ott 5 | # Signal 11 Software 6 | # 2010-06-01 7 | ########################################### 8 | 9 | all: hidtest libhidapi.dll 10 | 11 | CC=gcc 12 | CXX=g++ 13 | COBJS=hid.o 14 | CPPOBJS=../hidtest/hidtest.o 15 | OBJS=$(COBJS) $(CPPOBJS) 16 | CFLAGS=-I../hidapi -g -c 17 | LIBS= -lsetupapi 18 | DLL_LDFLAGS = -mwindows -lsetupapi 19 | 20 | hidtest: $(OBJS) 21 | g++ -g $^ $(LIBS) -o hidtest 22 | 23 | libhidapi.dll: $(OBJS) 24 | $(CC) -g $^ $(DLL_LDFLAGS) -o libhidapi.dll 25 | 26 | $(COBJS): %.o: %.c 27 | $(CC) $(CFLAGS) $< -o $@ 28 | 29 | $(CPPOBJS): %.o: %.cpp 30 | $(CXX) $(CFLAGS) $< -o $@ 31 | 32 | clean: 33 | rm *.o ../hidtest/*.o hidtest.exe 34 | 35 | .PHONY: clean 36 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/ddk_build/.npmignore: -------------------------------------------------------------------------------- 1 | *.log 2 | obj*_*_* -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/ddk_build/hidapi.def: -------------------------------------------------------------------------------- 1 | LIBRARY hidapi 2 | EXPORTS 3 | hid_open @1 4 | hid_write @2 5 | hid_read @3 6 | hid_close @4 7 | hid_get_product_string @5 8 | hid_get_manufacturer_string @6 9 | hid_get_serial_number_string @7 10 | hid_get_indexed_string @8 11 | hid_error @9 12 | hid_set_nonblocking @10 13 | hid_enumerate @11 14 | hid_open_path @12 15 | hid_send_feature_report @13 16 | hid_get_feature_report @14 17 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/ddk_build/makefile: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Copyright (C) Microsoft Corporation 1995, 1996 4 | # All Rights Reserved. 5 | # 6 | # MAKEFILE for HID directory 7 | # 8 | ############################################################################# 9 | 10 | !IFDEF WIN95_BUILD 11 | 12 | ROOT=..\..\..\.. 13 | 14 | VERSIONLIST = debug retail 15 | IS_32 = TRUE 16 | IS_SDK = TRUE 17 | IS_PRIVATE = TRUE 18 | IS_SDK = TRUE 19 | IS_DDK = TRUE 20 | WIN32 = TRUE 21 | COMMONMKFILE = hidapi.mk 22 | 23 | !include $(ROOT)\dev\master.mk 24 | 25 | 26 | !ELSE 27 | 28 | # 29 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 30 | # file to this component. This file merely indirects to the real make file 31 | # that is shared by all the driver components of the Windows NT DDK 32 | # 33 | 34 | !IF DEFINED(_NT_TARGET_VERSION) 35 | ! IF $(_NT_TARGET_VERSION)>=0x501 36 | ! INCLUDE $(NTMAKEENV)\makefile.def 37 | ! ELSE 38 | # Only warn once per directory 39 | ! INCLUDE $(NTMAKEENV)\makefile.plt 40 | ! IF "$(BUILD_PASS)"=="PASS1" 41 | ! message BUILDMSG: Warning : The sample "$(MAKEDIR)" is not valid for the current OS target. 42 | ! ENDIF 43 | ! ENDIF 44 | !ELSE 45 | ! INCLUDE $(NTMAKEENV)\makefile.def 46 | !ENDIF 47 | 48 | !ENDIF 49 | 50 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/ddk_build/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=hidapi 2 | TARGETTYPE=DYNLINK 3 | UMTYPE=console 4 | UMENTRY=main 5 | 6 | MSC_WARNING_LEVEL=/W3 /WX 7 | 8 | TARGETLIBS=$(SDK_LIB_PATH)\hid.lib \ 9 | $(SDK_LIB_PATH)\setupapi.lib \ 10 | $(SDK_LIB_PATH)\kernel32.lib \ 11 | $(SDK_LIB_PATH)\comdlg32.lib 12 | 13 | USE_MSVCRT=1 14 | 15 | INCLUDES= ..\..\hidapi 16 | SOURCES= ..\hid.c \ 17 | 18 | 19 | TARGET_DESTINATION=retail 20 | 21 | MUI=0 22 | MUI_COMMENT="HID Interface DLL" 23 | 24 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/hidapi.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual C++ Express 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hidapi", "hidapi.vcproj", "{A107C21C-418A-4697-BB10-20C3AA60E2E4}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hidtest", "hidtest.vcproj", "{23E9FF6A-49D1-4993-B2B5-BBB992C6C712}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {A107C21C-418A-4697-BB10-20C3AA60E2E4} = {A107C21C-418A-4697-BB10-20C3AA60E2E4} 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | Release|Win32 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {A107C21C-418A-4697-BB10-20C3AA60E2E4}.Debug|Win32.ActiveCfg = Debug|Win32 18 | {A107C21C-418A-4697-BB10-20C3AA60E2E4}.Debug|Win32.Build.0 = Debug|Win32 19 | {A107C21C-418A-4697-BB10-20C3AA60E2E4}.Release|Win32.ActiveCfg = Release|Win32 20 | {A107C21C-418A-4697-BB10-20C3AA60E2E4}.Release|Win32.Build.0 = Release|Win32 21 | {23E9FF6A-49D1-4993-B2B5-BBB992C6C712}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {23E9FF6A-49D1-4993-B2B5-BBB992C6C712}.Debug|Win32.Build.0 = Debug|Win32 23 | {23E9FF6A-49D1-4993-B2B5-BBB992C6C712}.Release|Win32.ActiveCfg = Release|Win32 24 | {23E9FF6A-49D1-4993-B2B5-BBB992C6C712}.Release|Win32.Build.0 = Release|Win32 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/hidapi.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 26 | 29 | 32 | 35 | 38 | 41 | 53 | 56 | 59 | 62 | 70 | 73 | 76 | 79 | 82 | 85 | 88 | 91 | 92 | 100 | 103 | 106 | 109 | 112 | 115 | 127 | 130 | 133 | 136 | 146 | 149 | 152 | 155 | 158 | 161 | 164 | 167 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 181 | 182 | 187 | 190 | 191 | 192 | 197 | 198 | 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /drivers/node-hid/hidapi/windows/hidtest.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 50 | 53 | 56 | 59 | 67 | 70 | 73 | 76 | 79 | 82 | 85 | 90 | 91 | 99 | 102 | 105 | 108 | 111 | 114 | 124 | 127 | 130 | 133 | 143 | 146 | 149 | 152 | 155 | 158 | 161 | 166 | 167 | 168 | 169 | 170 | 171 | 176 | 179 | 180 | 181 | 186 | 187 | 192 | 193 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /drivers/node-hid/index.js: -------------------------------------------------------------------------------- 1 | var EventEmitter = require("events").EventEmitter, 2 | util = require("util"); 3 | 4 | //Load C++ binding 5 | var binding = require("./build/Release/HID.node"); 6 | 7 | //This class is a wrapper for `binding.HID` class 8 | function HID() { 9 | //Inherit from EventEmitter 10 | EventEmitter.call(this); 11 | 12 | /* We also want to inherit from `binding.HID`, but unfortunately, 13 | it's not so easy for native Objects. For example, the 14 | following won't work since `new` keyword isn't used: 15 | 16 | `binding.HID.apply(this, arguments);` 17 | 18 | So... we do this craziness instead... 19 | */ 20 | var thisPlusArgs = new Array(arguments.length + 1); 21 | thisPlusArgs[0] = null; 22 | for(var i = 0; i < arguments.length; i++) 23 | thisPlusArgs[i + 1] = arguments[i]; 24 | this._raw = new (Function.prototype.bind.apply(binding.HID, 25 | thisPlusArgs) )(); 26 | 27 | /* Now we have `this._raw` Object from which we need to 28 | inherit. So, one solution is to simply copy all 29 | prototype methods over to `this` and binding them to 30 | `this._raw` 31 | */ 32 | for(var i in binding.HID.prototype) 33 | if(i != "close") 34 | this[i] = binding.HID.prototype[i].bind(this._raw); 35 | 36 | /* We are now done inheriting from `binding.HID` and EventEmitter. 37 | 38 | Now upon adding a new listener for "data" events, we start 39 | polling the HID device using `read(...)` 40 | See `resume()` for more details. */ 41 | this._paused = true; 42 | var self = this; 43 | self.on("newListener", function(eventName, listener) { 44 | if(eventName == "data") 45 | process.nextTick(self.resume.bind(self) ); 46 | }); 47 | } 48 | //Inherit prototype methods 49 | util.inherits(HID, EventEmitter); 50 | //Don't inherit from `binding.HID`; that's done above already! 51 | 52 | HID.prototype.close = function close() { 53 | this._closing = true; 54 | this._raw.close(); 55 | }; 56 | //Pauses the reader, which stops "data" events from being emitted 57 | HID.prototype.pause = function pause() { 58 | this._paused = true; 59 | }; 60 | HID.prototype.resume = function pause() { 61 | var self = this; 62 | if(self._paused && self.listeners("data").length > 0) 63 | { 64 | //Start polling & reading loop 65 | self._paused = false; 66 | self.read(function readFunc(err, data) { 67 | if(err) 68 | { 69 | //Emit error and pause reading 70 | self._paused = true; 71 | if(!self._closing) 72 | self.emit("error", err); 73 | //else ignore any errors if I'm closing the device 74 | } 75 | else 76 | { 77 | //If there are no "data" listeners, we pause 78 | if(self.listeners("data").length <= 0) 79 | self._paused = true; 80 | //Keep reading if we aren't paused 81 | if(!self._paused) 82 | self.read(readFunc); 83 | //Now emit the event 84 | self.emit("data", data); 85 | } 86 | }); 87 | } 88 | }; 89 | 90 | //Expose API 91 | exports.HID = HID; 92 | exports.devices = binding.devices; 93 | -------------------------------------------------------------------------------- /drivers/node-hid/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | nodewebkit_version() { 6 | grep -o '"nodewebkit":.*"\(.*\)"' package.json |\ 7 | sed 's/.*webkit":.*"\(.*\)".*/\1/' 8 | } 9 | 10 | nw_gyp() { 11 | dir=$1 12 | version=$(echo $2 | sed 's/[^0-9rcRC.\-]//g') 13 | 14 | cd $dir 15 | echo "Configuring nw-gyp for target=$version" 16 | nw-gyp configure --target=$version 17 | nw-gyp build 18 | } 19 | 20 | [ -d build ] && node-gyp clean 21 | if which nw-gyp >/dev/null 22 | then 23 | # we've got nw-gyp... check if we're in a node-webkit project 24 | myDir=$PWD 25 | cd .. 26 | 27 | parentDir=${PWD##*/} 28 | while [ $parentDir == 'node_modules' ] 29 | do 30 | cd .. 31 | currentProject=${PWD##*/} 32 | version=$(nodewebkit_version) 33 | if [ a$version != a ] 34 | then 35 | nw_gyp $myDir $version 36 | exit 37 | fi 38 | 39 | cd .. 40 | parentDir=${PWD##*/} 41 | done 42 | 43 | # go back home 44 | cd $myDir 45 | fi 46 | 47 | # no? just do boring node-gyp 48 | node-gyp configure build install 49 | -------------------------------------------------------------------------------- /drivers/node-hid/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-hid", 3 | "description": "USB HID device access library", 4 | "version": "0.4.0", 5 | "author": { 6 | "name": "Hans Hübner", 7 | "email": "hans.huebner@gmail.com", 8 | "url": "https://github.com/hanshuebner" 9 | }, 10 | "contributors": [ 11 | { 12 | "name": "Blake Miner", 13 | "email": "miner.blake@gmail.com" 14 | } 15 | ], 16 | "repository": { 17 | "type": "git", 18 | "url": "git://github.com/hanshuebner/node-hid.git" 19 | }, 20 | "scripts": { 21 | "prepublish": "git submodule update --init", 22 | "install": "node-gyp rebuild" 23 | }, 24 | "main": "./index.js", 25 | "engines": { 26 | "node": ">=0.8.0" 27 | }, 28 | "license": "MIT/X11", 29 | "dependencies": { 30 | "nan": "^1.2.0" 31 | }, 32 | "devDependencies": {}, 33 | "gypfile": true, 34 | "gitHead": "c56c8aa5d113c6f2574d1f7e64d41745702965bb", 35 | "bugs": { 36 | "url": "https://github.com/hanshuebner/node-hid/issues" 37 | }, 38 | "homepage": "https://github.com/hanshuebner/node-hid", 39 | "_id": "node-hid@0.4.0", 40 | "_shasum": "92034c13f847e80ef5e2abeb3a8a3b43b80639e8", 41 | "_from": "node-hid@*", 42 | "_npmVersion": "2.7.5", 43 | "_nodeVersion": "0.12.2", 44 | "_npmUser": { 45 | "name": "natevw", 46 | "email": "natevw@yahoo.com" 47 | }, 48 | "dist": { 49 | "shasum": "92034c13f847e80ef5e2abeb3a8a3b43b80639e8", 50 | "tarball": "http://registry.npmjs.org/node-hid/-/node-hid-0.4.0.tgz" 51 | }, 52 | "maintainers": [ 53 | { 54 | "name": "gorillatron", 55 | "email": "jornandretangen@gmail.com" 56 | }, 57 | { 58 | "name": "hans", 59 | "email": "hans.huebner@gmail.com" 60 | }, 61 | { 62 | "name": "bminer", 63 | "email": "miner.blake@gmail.com" 64 | }, 65 | { 66 | "name": "natevw", 67 | "email": "natevw@yahoo.com" 68 | } 69 | ], 70 | "directories": {}, 71 | "_resolved": "https://registry.npmjs.org/node-hid/-/node-hid-0.4.0.tgz" 72 | } 73 | -------------------------------------------------------------------------------- /drivers/node-hid/src/.npmignore: -------------------------------------------------------------------------------- 1 | *~ 2 | build 3 | .lock-wscript 4 | -------------------------------------------------------------------------------- /drivers/node-hid/src/buzzers.js: -------------------------------------------------------------------------------- 1 | // Simple interface to Sony Buzz! wireless buzzers 2 | 3 | var util = require('util'); 4 | var events = require('events'); 5 | var HID = require('../'); 6 | 7 | // buzzer protocol info: http://www.developerfusion.com/article/84338/making-usb-c-friendly/ 8 | 9 | function BuzzerController(index) 10 | { 11 | if (!arguments.length) { 12 | index = 0; 13 | } 14 | 15 | var controllers = HID.devices(0x54c, 0x1000); 16 | 17 | if (!controllers.length) { 18 | throw new Error("No Buzzer controllers could be found"); 19 | } 20 | 21 | if (index > controllers.length || index < 0) { 22 | throw new Error("Index " + index + " out of range, only " + controllers.length + " Buzzer controllers found"); 23 | } 24 | 25 | events.EventEmitter.call(this); 26 | 27 | this.hid = new HID.HID(controllers[index].path); 28 | this.oldBits = 0; 29 | this.leds = [0, 0, 0, 0, 0, 0]; 30 | 31 | // Initialize buzzers 32 | this.hid.write([0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); 33 | this.hid.read(this.buzzerData.bind(this)); 34 | } 35 | 36 | util.inherits(BuzzerController, events.EventEmitter); 37 | 38 | BuzzerController.prototype.handleBuzzer = function (buzzerNumber, bits) 39 | { 40 | var mask = 1 << (buzzerNumber * 5); 41 | for (var buttonNumber = 0; buttonNumber < 5; buttonNumber++) { 42 | var now = bits & mask; 43 | var old = this.oldBits & mask; 44 | if (old ^ now) { 45 | this.emit('button', buzzerNumber, buttonNumber, now ? true : false); 46 | } 47 | mask <<= 1; 48 | } 49 | } 50 | 51 | BuzzerController.prototype.buzzerData = function (error, data) { 52 | console.log('error', error, 'data', data); 53 | var bits = (data[4] << 16) | (data[3] << 8) | data[2]; 54 | for (var i = 0; i < 4; i++) { 55 | this.handleBuzzer(i, bits); 56 | } 57 | this.oldBits = bits; 58 | this.hid.read(this.buzzerData.bind(this)); 59 | } 60 | 61 | BuzzerController.prototype.led = function(buzzer, state) { 62 | this.leds[buzzer + 2] = state ? 0xff : 0x00; 63 | this.hid.write(this.leds); 64 | } 65 | 66 | exports.BuzzerController = BuzzerController; 67 | -------------------------------------------------------------------------------- /drivers/node-hid/src/powermate.js: -------------------------------------------------------------------------------- 1 | // Interface to Griffin PowerMate 2 | 3 | // Received data from the PowerMate contains the state of the button 4 | // in the first byte and the turning direction, if any, in the second 5 | // byte. The second byte is encoded as a signed integer. Data sent 6 | // to the PowerMate contains zero in the first byte and the brightness 7 | // of the LED in the second byte. 8 | 9 | var HID = require('../'); 10 | var util = require('util'); 11 | var events = require('events'); 12 | 13 | var allDevices; 14 | function getAllDevices() 15 | { 16 | if (!allDevices) { 17 | allDevices = HID.devices(1917, 1040); 18 | } 19 | return allDevices; 20 | } 21 | 22 | function PowerMate(index) 23 | { 24 | if (!arguments.length) { 25 | index = 0; 26 | } 27 | 28 | var powerMates = getAllDevices(); 29 | if (!powerMates.length) { 30 | throw new Error("No PowerMates could be found"); 31 | } 32 | if (index > powerMates.length || index < 0) { 33 | throw new Error("Index " + index + " out of range, only " + powerMates.length + " PowerMates found"); 34 | } 35 | this.hid = new HID.HID(powerMates[index].path); 36 | this.position = 0; 37 | this.button = 0; 38 | this.hid.read(this.interpretData.bind(this)); 39 | } 40 | 41 | util.inherits(PowerMate, events.EventEmitter); 42 | 43 | PowerMate.prototype.setLed = function(brightness) { 44 | this.hid.write([0, brightness]); 45 | } 46 | 47 | PowerMate.prototype.interpretData = function(error, data) { 48 | var button = data[0]; 49 | if (button ^ this.button) { 50 | this.emit(button ? 'buttonDown' : 'buttonUp'); 51 | this.button = button; 52 | } 53 | var delta = data[1]; 54 | if (delta) { 55 | if (delta & 0x80) { 56 | delta = -256 + delta; 57 | } 58 | this.position += delta; 59 | this.emit('turn', delta, this.position); 60 | } 61 | this.hid.read(this.interpretData.bind(this)); 62 | } 63 | 64 | exports.PowerMate = PowerMate; 65 | exports.deviceCount = function () { return getAllDevices().length; } 66 | -------------------------------------------------------------------------------- /drivers/node-hid/src/show-devices.js: -------------------------------------------------------------------------------- 1 | var HID = require('../'); 2 | 3 | console.log('devices:', HID.devices()); 4 | -------------------------------------------------------------------------------- /drivers/node-hid/src/test-buzzers.js: -------------------------------------------------------------------------------- 1 | 2 | var buzzers = require('./buzzers'); 3 | 4 | var buzzerController = new buzzers.BuzzerController(); 5 | 6 | function blinkLed(buzzerNumber) 7 | { 8 | buzzerController.led(buzzerNumber, true); 9 | setTimeout(function () { 10 | buzzerController.led(buzzerNumber, false); 11 | }, 500); 12 | } 13 | 14 | buzzerController.on('button', function (buzzer, button, state) { 15 | console.log('buzzer', buzzer, 'button', button, 'state', state); 16 | if (state) { 17 | blinkLed(buzzer); 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /drivers/node-hid/src/test-powermate.js: -------------------------------------------------------------------------------- 1 | 2 | var PowerMate = require('./powermate'); 3 | 4 | var powerMate; 5 | for (var i = 0; i < PowerMate.deviceCount(); i++) { 6 | 7 | console.log('opening powermate', i); 8 | 9 | powerMate = new PowerMate.PowerMate(i); 10 | 11 | powerMate.on('buttonDown', function () { 12 | console.log('button down'); 13 | this.position = 0; 14 | }); 15 | 16 | powerMate.on('buttonUp', function () { 17 | console.log('button up'); 18 | }); 19 | 20 | powerMate.on('turn', function (delta, position) { 21 | console.log('delta', delta, 'position', position); 22 | this.setLed(position % 256); 23 | }); 24 | } -------------------------------------------------------------------------------- /drivers/node-hid/src/test-ps3.js: -------------------------------------------------------------------------------- 1 | var HID = require('../'); 2 | var REPL = require('repl'); 3 | 4 | var repl = REPL.start('node-hid> '); 5 | var hid = new HID.HID(1356, 616); 6 | 7 | console.log('features', hid.getFeatureReport(0xf2, 17)); 8 | 9 | hid.gotData = function (err, data) { 10 | console.log('got ps3 data', data); 11 | this.read(this.gotData.bind(this)); 12 | } 13 | 14 | hid.read(hid.gotData.bind(hid)); 15 | 16 | repl.context.hid = hid; 17 | -------------------------------------------------------------------------------- /drivers/node-hid/src/wscript: -------------------------------------------------------------------------------- 1 | # -*- Python -*- 2 | 3 | import sys; 4 | import os; 5 | 6 | hidapi_home='../hidapi' 7 | 8 | cflags=["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall", "-fPIC" ] 9 | includes=[ hidapi_home + "/hidapi" ] 10 | 11 | def set_options(opt): 12 | opt.tool_options("compiler_cxx") 13 | opt.tool_options("compiler_cc") 14 | 15 | def configure(conf): 16 | conf.check_tool("compiler_cxx") 17 | conf.check_tool("node_addon") 18 | conf.check_tool("compiler_cc") 19 | if sys.platform == 'darwin': 20 | conf.env.append_value('LINKFLAGS', ['Release/libhidapi.a', '-framework', 'IOKit', '-framework', 'CoreFoundation']) 21 | else: 22 | conf.env.append_value('LINKFLAGS', ['Release/libhidapi.a', '-ludev' ]) 23 | 24 | def build(bld): 25 | bld.add_group("hidapi") 26 | hidapi = bld.new_task_gen("cc", "staticlib") 27 | hidapi.includes = includes 28 | hidapi.cflags = cflags 29 | if sys.platform == 'darwin': 30 | hidapi.source = "../hidapi/mac/hid.c" 31 | else: 32 | hidapi.source = "../hidapi/linux/hid.c" 33 | hidapi.target = "hidapi" 34 | 35 | bld.add_group("adapter") 36 | adapter = bld.new_task_gen("cxx", "shlib", "node_addon", use = ['hidapi']) 37 | adapter.includes = includes 38 | adapter.cxxflags = cflags 39 | adapter.target = "HID" 40 | adapter.source = "HID.cc" 41 | -------------------------------------------------------------------------------- /examples/button.js: -------------------------------------------------------------------------------- 1 | // Adapted from Johnny Five Example for JS Conf CN nodebots session. 2 | // Button class doesn't appear to work so this will do it for what you need 3 | // Potentially just emit an event if you need it. 4 | 5 | var five = require("johnny-five"); 6 | 7 | var board = new five.Board(); 8 | 9 | board.on("ready", function() { 10 | 11 | // Create a new `button` hardware instance. 12 | // This example allows the button module to 13 | // create a completely default instance 14 | console.log("Board ready"); 15 | 16 | var button = new five.Sensor({ 17 | pin: 21, 18 | }); 19 | 20 | button.on("change", function() { 21 | console.log(this.value); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/leds.js: -------------------------------------------------------------------------------- 1 | // This is an example to show how to use the LEDs on the mbot. 2 | // mbot maps WS2812 pixels in a 2 pixel strip attached to pin 13. 3 | 4 | var five = require("johnny-five"); 5 | var pixel = require("node-pixel"); 6 | 7 | var opts = {}; 8 | opts.port = process.argv[2] || ""; 9 | 10 | var board = new five.Board(opts); 11 | var strip = null; 12 | 13 | var fps = 3; // how many frames per second do you want to try? 14 | 15 | board.on("ready", function() { 16 | 17 | console.log("Board ready, lets add light"); 18 | 19 | strip = new pixel.Strip({ 20 | data: 13, 21 | length: 2, 22 | board: this, 23 | controller: "FIRMATA", 24 | }); 25 | 26 | strip.on("ready", function() { 27 | 28 | console.log("Strip ready, let's go"); 29 | 30 | var colors = ["#440000", "#000044"]; 31 | var current_colors = [0,1]; 32 | var current_pos = [0,1]; 33 | var blinker = setInterval(function() { 34 | 35 | strip.color("#000"); // blanks it out 36 | for (var i=0; i< current_pos.length; i++) { 37 | if (++current_pos[i] >= strip.stripLength()) { 38 | current_pos[i] = 0; 39 | if (++current_colors[i] >= colors.length) current_colors[i] = 0; 40 | } 41 | strip.pixel(current_pos[i]).color(colors[current_colors[i]]); 42 | } 43 | strip.show(); 44 | }, 1000/fps); 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /examples/light.js: -------------------------------------------------------------------------------- 1 | // Light sensor example for mBot. Uses the light sensor at the front 2 | // of the board which is on Analog pin 6 A6. 3 | // The data event provides a value output for the analog value of the the 4 | // light sensor in the range 0 (total darkness) to 1023 (full bright light). 5 | 6 | var five = require("johnny-five"); 7 | var board = new five.Board(); 8 | 9 | board.on("ready", function() { 10 | 11 | var sensor = new five.Sensor({ 12 | pin: "A6", 13 | freq: 500 // change this to speed you want data reported at. Slower is better 14 | }); 15 | 16 | sensor.on("data", function() { 17 | console.log(this.value); 18 | }); 19 | }); 20 | 21 | -------------------------------------------------------------------------------- /examples/motors.js: -------------------------------------------------------------------------------- 1 | var five = require("johnny-five"); 2 | 3 | var max_speed_l = 150; 4 | var max_speed_r = 140; 5 | 6 | // set up the input 7 | var stdin = process.openStdin(); 8 | require('tty').setRawMode(true); 9 | 10 | var board = new five.Board({port: process.argv[2]}); 11 | 12 | var l_motor = r_motor = null; 13 | 14 | board.on("ready", function(err) { 15 | 16 | if (err){ 17 | console.log(err); 18 | return; 19 | } 20 | l_motor = new five.Motor({pins: {pwm: 6, dir: 7}}); 21 | r_motor = new five.Motor({pins: {pwm: 5, dir: 4}}); 22 | 23 | console.info("Board connected. Robot set up. LRUD to control"); 24 | 25 | }); 26 | 27 | stdin.on('keypress', function(chunk, key) { 28 | // process the keypresses 29 | 30 | if (key) { 31 | switch (key.name) { 32 | case "up": 33 | l_motor.reverse(max_speed_l); 34 | r_motor.forward(max_speed_r); 35 | break; 36 | case "down": 37 | r_motor.reverse(max_speed_r); 38 | l_motor.forward(max_speed_l); 39 | break; 40 | case "left": 41 | l_motor.forward(max_speed_l); 42 | r_motor.forward(max_speed_r); 43 | break; 44 | case "right": 45 | r_motor.reverse(max_speed_r); 46 | l_motor.reverse(max_speed_l); 47 | break; 48 | case "space": 49 | l_motor.stop(); 50 | r_motor.stop(); 51 | break; 52 | } 53 | } 54 | }); 55 | 56 | -------------------------------------------------------------------------------- /examples/piezo.js: -------------------------------------------------------------------------------- 1 | // Adapted from Johnny-Five Piezo example for NodeBots session at JSConf CN 2 | 3 | var five = require("johnny-five"), 4 | board = new five.Board(); 5 | 6 | board.on("ready", function() { 7 | // Creates a piezo object and defines the pin to be used for the signal 8 | var piezo = new five.Piezo(8); 9 | 10 | // Plays a song 11 | piezo.play({ 12 | // song is composed by an array of pairs of notes and beats 13 | // The first argument is the note (null means "no note") 14 | // The second argument is the length of time (beat) of the note (or non-note) 15 | song: [ 16 | ["C4", 1 / 4], 17 | ["D4", 1 / 4], 18 | ["F4", 1 / 4], 19 | ["D4", 1 / 4], 20 | ["A4", 1 / 4], 21 | [null, 1 / 4], 22 | ["A4", 1], 23 | ["G4", 1], 24 | [null, 1 / 2], 25 | ["C4", 1 / 4], 26 | ["D4", 1 / 4], 27 | ["F4", 1 / 4], 28 | ["D4", 1 / 4], 29 | ["G4", 1 / 4], 30 | [null, 1 / 4], 31 | ["G4", 1], 32 | ["F4", 1], 33 | [null, 1 / 2] 34 | ], 35 | tempo: 100 36 | }); 37 | 38 | // Plays the same song with a string representation 39 | piezo.play({ 40 | // song is composed by a string of notes 41 | // a default beat is set, and the default octave is used 42 | // any invalid note is read as "no note" 43 | song: "C D F D A - A A A A G G G G - - C D F D G - G G G G F F F F - -", 44 | beats: 1 / 4, 45 | tempo: 100 46 | }); 47 | }); 48 | -------------------------------------------------------------------------------- /examples/reflectance.js: -------------------------------------------------------------------------------- 1 | // Assumes the reflectance sensor is put into PORT 3 2 | 3 | // Gives you values of the reflectance sensor. 4 | var five = require("johnny-five"), 5 | board = new five.Board(); 6 | 7 | board.on("ready", function() { 8 | 9 | // Create a new `reflectance` hardware instance. 10 | var eyes = new five.IR.Reflect.Array({ 11 | emitter: 13, 12 | pins: ["A1", "A2"], // any number of pins 13 | freq: 25 14 | }); 15 | 16 | eyes.on('data', function() { 17 | console.log( "Raw Values: ", this.raw ); 18 | }); 19 | 20 | eyes.on('line', function() { 21 | console.log( "Line Position: ", this.line); 22 | }); 23 | 24 | eyes.enable(); 25 | }); 26 | -------------------------------------------------------------------------------- /examples/sonar.js: -------------------------------------------------------------------------------- 1 | // Uses proximity sensor on the front to tell the distance from the object 2 | // Assumes prox sensor is plugged into port 2 - if not change the pin to use 3 | // the pin for appropriate port and the second pin within it. 4 | 5 | var five = require("johnny-five"); 6 | var board = new five.Board(); 7 | 8 | board.on("ready", function() { 9 | var proximity = new five.Proximity({ 10 | controller: "HCSR04", 11 | pin: 10 12 | }); 13 | 14 | proximity.on("data", function() { 15 | console.log("inches: ", this.inches); 16 | console.log("cm: ", this.cm); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/wifi_motors.js: -------------------------------------------------------------------------------- 1 | // This is an example to show how to use the LEDs on the mbot. 2 | // mbot maps WS2812 pixels in a 2 pixel strip attached to pin 13. 3 | 4 | var five = require("johnny-five"); 5 | var firmata = require("firmata"); 6 | var pixel = require("node-pixel"); 7 | var HID = require("node-hid"); 8 | 9 | // set up the input 10 | var stdin = process.openStdin(); 11 | require('tty').setRawMode(true); 12 | 13 | var allDevices = HID.devices(0x416,0xffff); 14 | console.log(allDevices); 15 | var hiddev = new HID.HID(allDevices[0].path) 16 | 17 | var io = new firmata.Board(hiddev); 18 | 19 | var max_speed_l = 150; 20 | var max_speed_r = 140; 21 | 22 | var l_motor = r_motor = null; 23 | 24 | var opts = {}; 25 | opts.io = io; 26 | io.once('ready', function(){ 27 | 28 | console.log('io ready'); 29 | io.isReady = true; 30 | 31 | var board = new five.Board({io: io}); 32 | var strip = null; 33 | 34 | var fps = 3; // how many frames per second do you want to try? 35 | 36 | board.on("ready", function() { 37 | 38 | l_motor = new five.Motor({pins: {pwm: 6, dir: 7}}); 39 | r_motor = new five.Motor({pins: {pwm: 5, dir: 4}}); 40 | 41 | console.info("Board connected. Robot set up. LRUD to control"); 42 | 43 | }); 44 | }); 45 | 46 | stdin.on('keypress', function(chunk, key) { 47 | // process the keypresses 48 | 49 | if (key) { 50 | switch (key.name) { 51 | case "up": 52 | l_motor.reverse(max_speed_l); 53 | r_motor.forward(max_speed_r); 54 | break; 55 | case "down": 56 | r_motor.reverse(max_speed_r); 57 | l_motor.forward(max_speed_l); 58 | break; 59 | case "left": 60 | l_motor.forward(max_speed_l); 61 | r_motor.forward(max_speed_r); 62 | break; 63 | case "right": 64 | r_motor.reverse(max_speed_r); 65 | l_motor.reverse(max_speed_l); 66 | break; 67 | case "space": 68 | l_motor.stop(); 69 | r_motor.stop(); 70 | break; 71 | } 72 | } 73 | }); 74 | 75 | -------------------------------------------------------------------------------- /firmware/mbotFirmata/Adafruit_NeoPixel.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------- 2 | This file is part of the Adafruit NeoPixel library. 3 | 4 | NeoPixel is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as 6 | published by the Free Software Foundation, either version 3 of 7 | the License, or (at your option) any later version. 8 | 9 | NeoPixel is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with NeoPixel. If not, see 16 | . 17 | --------------------------------------------------------------------*/ 18 | 19 | #ifndef ADAFRUIT_NEOPIXEL_H 20 | #define ADAFRUIT_NEOPIXEL_H 21 | 22 | #if (ARDUINO >= 100) 23 | #include 24 | #else 25 | #include 26 | #include 27 | #endif 28 | 29 | // 'type' flags for LED pixels (third parameter to constructor): 30 | #define NEO_RGB 0x00 // Wired for RGB data order 31 | #define NEO_GRB 0x01 // Wired for GRB data order 32 | #define NEO_BRG 0x04 33 | 34 | #define NEO_COLMASK 0x01 35 | #define NEO_KHZ800 0x02 // 800 KHz datastream 36 | #define NEO_SPDMASK 0x02 37 | // Trinket flash space is tight, v1 NeoPixels aren't handled by default. 38 | // Remove the ifndef/endif to add support -- but code will be bigger. 39 | // Conversely, can comment out the #defines to save space on other MCUs. 40 | #ifndef __AVR_ATtiny85__ 41 | #define NEO_KHZ400 0x00 // 400 KHz datastream 42 | #endif 43 | 44 | class Adafruit_NeoPixel { 45 | 46 | public: 47 | 48 | // Constructor: number of LEDs, pin number, LED type 49 | Adafruit_NeoPixel(uint16_t n, uint8_t p=6, uint8_t t=NEO_GRB + NEO_KHZ800); 50 | ~Adafruit_NeoPixel(); 51 | 52 | void 53 | begin(void), 54 | show(void), 55 | setPin(uint8_t p), 56 | setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b), 57 | setPixelColor(uint16_t n, uint32_t c), 58 | setBrightness(uint8_t), 59 | clear(); 60 | uint8_t 61 | *getPixels(void) const, 62 | getBrightness(void) const; 63 | uint16_t 64 | numPixels(void) const; 65 | static uint32_t 66 | Color(uint8_t r, uint8_t g, uint8_t b); 67 | uint32_t 68 | getPixelColor(uint16_t n) const; 69 | inline bool 70 | canShow(void) { return (micros() - endTime) >= 50L; } 71 | 72 | private: 73 | 74 | const uint16_t 75 | numLEDs, // Number of RGB LEDs in strip 76 | numBytes; // Size of 'pixels' buffer below 77 | uint8_t 78 | pin, // Output pin number 79 | brightness, 80 | *pixels, // Holds LED color values (3 bytes each) 81 | rOffset, // Index of red byte within each 3-byte pixel 82 | gOffset, // Index of green byte 83 | bOffset; // Index of blue byte 84 | const uint8_t 85 | type; // Pixel flags (400 vs 800 KHz, RGB vs GRB color) 86 | uint32_t 87 | endTime; // Latch timing reference 88 | #ifdef __AVR__ 89 | const volatile uint8_t 90 | *port; // Output PORT register 91 | uint8_t 92 | pinMask; // Output PORT bitmask 93 | #endif 94 | 95 | }; 96 | 97 | #endif // ADAFRUIT_NEOPIXEL_H 98 | -------------------------------------------------------------------------------- /firmware/mbotFirmata/Firmata.h: -------------------------------------------------------------------------------- 1 | /* 2 | Firmata.h - Firmata library v2.4.0 - 2014-12-21 3 | Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | See file LICENSE.txt for further informations on licensing terms. 11 | */ 12 | 13 | #ifndef Firmata_h 14 | #define Firmata_h 15 | 16 | #include "./Boards.h" /* Hardware Abstraction Layer + Wiring/Arduino */ 17 | 18 | /* Version numbers for the protocol. The protocol is still changing, so these 19 | * version numbers are important. This number can be queried so that host 20 | * software can test whether it will be compatible with the currently 21 | * installed firmware. */ 22 | #define FIRMATA_MAJOR_VERSION 2 // for non-compatible changes 23 | #define FIRMATA_MINOR_VERSION 4 // for backwards compatible changes 24 | #define FIRMATA_BUGFIX_VERSION 0 // for bugfix releases 25 | 26 | #define MAX_DATA_BYTES 64 // max number of data bytes in incoming messages 27 | 28 | // message command bytes (128-255/0x80-0xFF) 29 | #define DIGITAL_MESSAGE 0x90 // send data for a digital pin 30 | #define ANALOG_MESSAGE 0xE0 // send data for an analog pin (or PWM) 31 | #define REPORT_ANALOG 0xC0 // enable analog input by pin # 32 | #define REPORT_DIGITAL 0xD0 // enable digital input by port pair 33 | // 34 | #define SET_PIN_MODE 0xF4 // set a pin to INPUT/OUTPUT/PWM/etc 35 | // 36 | #define REPORT_VERSION 0xF9 // report protocol version 37 | #define SYSTEM_RESET 0xFF // reset from MIDI 38 | // 39 | #define START_SYSEX 0xF0 // start a MIDI Sysex message 40 | #define END_SYSEX 0xF7 // end a MIDI Sysex message 41 | 42 | // extended command set using sysex (0-127/0x00-0x7F) 43 | /* 0x00-0x0F reserved for user-defined commands */ 44 | #define ENCODER_DATA 0x61 // reply with encoders current positions 45 | #define SERVO_CONFIG 0x70 // set max angle, minPulse, maxPulse, freq 46 | #define STRING_DATA 0x71 // a string message with 14-bits per char 47 | #define STEPPER_DATA 0x72 // control a stepper motor 48 | #define ONEWIRE_DATA 0x73 // send an OneWire read/write/reset/select/skip/search request 49 | #define SHIFT_DATA 0x75 // a bitstream to/from a shift register 50 | #define I2C_REQUEST 0x76 // send an I2C read/write request 51 | #define I2C_REPLY 0x77 // a reply to an I2C read request 52 | #define I2C_CONFIG 0x78 // config I2C settings such as delay times and power pins 53 | #define EXTENDED_ANALOG 0x6F // analog write (PWM, Servo, etc) to any pin 54 | #define PIN_STATE_QUERY 0x6D // ask for a pin's current mode and value 55 | #define PIN_STATE_RESPONSE 0x6E // reply with pin's current mode and value 56 | #define CAPABILITY_QUERY 0x6B // ask for supported modes and resolution of all pins 57 | #define CAPABILITY_RESPONSE 0x6C // reply with supported modes and resolution 58 | #define ANALOG_MAPPING_QUERY 0x69 // ask for mapping of analog to pin numbers 59 | #define ANALOG_MAPPING_RESPONSE 0x6A // reply with mapping info 60 | #define REPORT_FIRMWARE 0x79 // report name and version of the firmware 61 | #define SAMPLING_INTERVAL 0x7A // set the poll rate of the main loop 62 | #define SCHEDULER_DATA 0x7B // send a createtask/deletetask/addtotask/schedule/querytasks/querytask request to the scheduler 63 | #define SYSEX_NON_REALTIME 0x7E // MIDI Reserved for non-realtime messages 64 | #define SYSEX_REALTIME 0x7F // MIDI Reserved for realtime messages 65 | // these are DEPRECATED to make the naming more consistent 66 | #define FIRMATA_STRING 0x71 // same as STRING_DATA 67 | #define SYSEX_I2C_REQUEST 0x76 // same as I2C_REQUEST 68 | #define SYSEX_I2C_REPLY 0x77 // same as I2C_REPLY 69 | #define SYSEX_SAMPLING_INTERVAL 0x7A // same as SAMPLING_INTERVAL 70 | 71 | // pin modes 72 | //#define INPUT 0x00 // defined in wiring.h 73 | //#define OUTPUT 0x01 // defined in wiring.h 74 | #define ANALOG 0x02 // analog pin in analogInput mode 75 | #define PWM 0x03 // digital pin in PWM output mode 76 | #define SERVO 0x04 // digital pin in Servo output mode 77 | #define SHIFT 0x05 // shiftIn/shiftOut mode 78 | #define I2C 0x06 // pin included in I2C setup 79 | #define ONEWIRE 0x07 // pin configured for 1-wire 80 | #define STEPPER 0x08 // pin configured for stepper motor 81 | #define ENCODER 0x09 // pin configured for rotary encoders 82 | #define IGNORE 0x7F // pin configured to be ignored by digitalWrite and capabilityResponse 83 | #define TOTAL_PIN_MODES 11 84 | 85 | extern "C" { 86 | // callback function types 87 | typedef void (*callbackFunction)(byte, int); 88 | typedef void (*systemResetCallbackFunction)(void); 89 | typedef void (*stringCallbackFunction)(char *); 90 | typedef void (*sysexCallbackFunction)(byte command, byte argc, byte *argv); 91 | } 92 | 93 | 94 | // TODO make it a subclass of a generic Serial/Stream base class 95 | class FirmataClass 96 | { 97 | public: 98 | FirmataClass(); 99 | /* Arduino constructors */ 100 | void begin(); 101 | void begin(long); 102 | void begin(Stream &s); 103 | /* querying functions */ 104 | void printVersion(void); 105 | void blinkVersion(void); 106 | void printFirmwareVersion(void); 107 | //void setFirmwareVersion(byte major, byte minor); // see macro below 108 | void setFirmwareNameAndVersion(const char *name, byte major, byte minor); 109 | /* serial receive handling */ 110 | int available(void); 111 | void processInput(void); 112 | /* serial send handling */ 113 | void sendAnalog(byte pin, int value); 114 | void sendDigital(byte pin, int value); // TODO implement this 115 | void sendDigitalPort(byte portNumber, int portData); 116 | void sendString(const char *string); 117 | void sendString(byte command, const char *string); 118 | void sendSysex(byte command, byte bytec, byte *bytev); 119 | void write(byte c); 120 | /* attach & detach callback functions to messages */ 121 | void attach(byte command, callbackFunction newFunction); 122 | void attach(byte command, systemResetCallbackFunction newFunction); 123 | void attach(byte command, stringCallbackFunction newFunction); 124 | void attach(byte command, sysexCallbackFunction newFunction); 125 | void detach(byte command); 126 | 127 | /* utility methods */ 128 | void sendValueAsTwo7bitBytes(int value); 129 | void startSysex(void); 130 | void endSysex(void); 131 | 132 | private: 133 | Stream *FirmataStream; 134 | /* firmware name and version */ 135 | byte firmwareVersionCount; 136 | byte *firmwareVersionVector; 137 | /* input message handling */ 138 | byte waitForData; // this flag says the next serial input will be data 139 | byte executeMultiByteCommand; // execute this after getting multi-byte data 140 | byte multiByteChannel; // channel data for multiByteCommands 141 | byte storedInputData[MAX_DATA_BYTES]; // multi-byte data 142 | /* sysex */ 143 | boolean parsingSysex; 144 | int sysexBytesRead; 145 | /* callback functions */ 146 | callbackFunction currentAnalogCallback; 147 | callbackFunction currentDigitalCallback; 148 | callbackFunction currentReportAnalogCallback; 149 | callbackFunction currentReportDigitalCallback; 150 | callbackFunction currentPinModeCallback; 151 | systemResetCallbackFunction currentSystemResetCallback; 152 | stringCallbackFunction currentStringCallback; 153 | sysexCallbackFunction currentSysexCallback; 154 | 155 | /* private methods ------------------------------ */ 156 | void processSysexMessage(void); 157 | void systemReset(void); 158 | void strobeBlinkPin(int count, int onInterval, int offInterval); 159 | }; 160 | 161 | extern FirmataClass Firmata; 162 | 163 | /*============================================================================== 164 | * MACROS 165 | *============================================================================*/ 166 | 167 | /* shortcut for setFirmwareNameAndVersion() that uses __FILE__ to set the 168 | * firmware name. It needs to be a macro so that __FILE__ is included in the 169 | * firmware source file rather than the library source file. 170 | */ 171 | #define setFirmwareVersion(x, y) setFirmwareNameAndVersion(__FILE__, x, y) 172 | 173 | #endif /* Firmata_h */ 174 | -------------------------------------------------------------------------------- /firmware/mbotFirmata/ws2812.cpp: -------------------------------------------------------------------------------- 1 | #include "ws2812.h" 2 | #include "Arduino.h" 3 | 4 | Adafruit_NeoPixel strip = Adafruit_NeoPixel(STRIP_LENGTH, LED_PIN, NEO_GRB + NEO_KHZ800); 5 | 6 | char buf[BUFLENGTH]; // character buffer for json message processing 7 | 8 | void ws2812_initialise() { 9 | // initialises the strip 10 | strip.begin(); 11 | strip.show(); 12 | } 13 | 14 | void process_command(byte argc, byte *argv){ 15 | // this takes a pixel command that has been determined and then 16 | // processes it appropriately. 17 | 18 | switch (argv[0]) { 19 | case PIXEL_SHOW: { 20 | show(); 21 | break; 22 | } 23 | case PIXEL_SET_STRIP: { 24 | // sets the entirety of the strip to one colour 25 | uint32_t strip_colour = (uint32_t)argv[1] + ((uint32_t)argv[2]<<7) + ((uint32_t)argv[3]<<14) + ((uint32_t)argv[4] << 21); 26 | for (uint16_t i = 0; i