Skip to content

Commit f5f2751

Browse files
authored
Merge pull request #121 from adafruit/more-hid-inout
More hid inout
2 parents 906530a + cab3c41 commit f5f2751

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
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+
}

examples/HID/hid_generic_inout/hid_test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ var HID = require('node-hid');
55
var os = require('os')
66
// list of supported devices
77
var boards = require('./boards.js')
8-
9-
var isWin = (os.platform() === 'win32');
108
var 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
2018
var 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

6864
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);
7067
}
7168

0 commit comments

Comments
 (0)