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 1
1
module . 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');
5
5
var os = require ( 'os' )
6
6
// list of supported devices
7
7
var boards = require ( './boards.js' )
8
-
9
- var isWin = ( os . platform ( ) === 'win32' ) ;
10
8
var devices = HID . devices ( ) ;
11
9
12
10
// this will choose any device found in the boards.js file
@@ -19,10 +17,8 @@ var message = "Hello World!"
19
17
// 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
20
18
var messageBuffer = Array . from ( message , function ( c ) { return c . charCodeAt ( 0 ) } ) ;
21
19
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 )
26
22
27
23
// Some OSes expect that you always send a buffer that equals your report length
28
24
// So lets fill up the rest of the buffer with zeros
@@ -66,6 +62,7 @@ function anySupportedBoard(d) {
66
62
67
63
68
64
function 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 ) ;
70
67
}
71
68
You can’t perform that action at this time.
0 commit comments