File tree Expand file tree Collapse file tree 2 files changed +7
-11
lines changed
examples/HID/hid_generic_inout Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change 11module . exports = {
2- "Feather_nRF52840" :[ 0X239A , 0X8029 ] ,
3- "Metro_nRF52840" :[ 0X239A , 0X803F ] ,
4- "Circuit_Playground_Express" :[ 0X239A , 0X8018 ] ,
5- }
2+ "Adafruit Boards" :[ 0x239A , 0xFFFF ] ,
3+ "TinyUSB example" :[ 0xCAFE , 0xFFFF ]
4+ }
Original file line number Diff line number Diff line change @@ -5,8 +5,6 @@ var HID = require('node-hid');
55var os = require ( 'os' )
66// list of supported devices
77var boards = require ( './boards.js' )
8-
9- var isWin = ( os . platform ( ) === 'win32' ) ;
108var devices = HID . devices ( ) ;
119
1210// this will choose any device found in the boards.js file
@@ -19,10 +17,8 @@ var message = "Hello World!"
1917// This means if you have characters in your string that are not Latin-1 you will have to add additional logic for character codes above 255
2018var messageBuffer = Array . from ( message , function ( c ) { return c . charCodeAt ( 0 ) } ) ;
2119
22- // Windows wants you to prepend a 0 to whatever you send
23- if ( isWin ) {
24- messageBuffer . unshift ( 0 )
25- }
20+ // HIDAPI requires us to prepend a 0 for single hid report as dummy reportID
21+ messageBuffer . unshift ( 0 )
2622
2723// Some OSes expect that you always send a buffer that equals your report length
2824// So lets fill up the rest of the buffer with zeros
@@ -66,6 +62,7 @@ function anySupportedBoard(d) {
6662
6763
6864function isDevice ( board , d ) {
69- return d . vendorId == board [ 0 ] && d . productId == board [ 1 ] ;
65+ // product id 0xff is matches all
66+ return d . vendorId == board [ 0 ] && ( d . productId == board [ 1 ] || board [ 1 ] == 0xFFFF ) ;
7067}
7168
You can’t perform that action at this time.
0 commit comments