Skip to content

Instantly share code, notes, and snippets.

@danjenkins
Created June 5, 2014 20:47
Show Gist options
  • Save danjenkins/d92ee69b5b1b7e88e7d4 to your computer and use it in GitHub Desktop.
Save danjenkins/d92ee69b5b1b7e88e7d4 to your computer and use it in GitHub Desktop.
no pressing of any buttons, fills in by itself
hid-mapper --vendor 1356 --product 1476 --buttons l3,r3
Calibrating device...
Prompting for
buttons: l3, r3
joysticks:
Press the l3 button:
Added {"pin":2,"value":124,"name":"l3"}
Press the r3 button:
Added {"pin":2,"value":124,"name":"r3"}
[?] Enter a filename to save this file (blank to skip):
^C21:45:47 ✘ dan:(master *)~/git/hid-mapper$ hid-mapper --vendor 1356 --product 1476 --buttons l3,r3
Calibrating device...
Prompting for
buttons: l3, r3
joysticks:
Press the l3 button:
Added {"pin":2,"value":125,"name":"l3"}
Press the r3 button:
Added {"pin":2,"value":126,"name":"r3"}
[?] Enter a filename to save this file (blank to skip):
^C21:46:18 ✘ dan:(master *)~/git/hid-mapper$ hid-mapper --vendor 1356 --product 1476 --buttons l3,r3
Calibrating device...
Prompting for
buttons: l3, r3
joysticks:
Press the l3 button:
Added {"pin":1,"value":125,"name":"l3"}
Press the r3 button:
Added {"pin":1,"value":125,"name":"r3"}
[?] Enter a filename to save this file (blank to skip):
^C21:46:42 ✘ dan:(master *)~/git/hid-mapper$ hid-mapper --vendor 1356 --product 1476 --buttons l3,r3
Calibrating device...
Prompting for
buttons: l3, r3
joysticks:
Press the l3 button:
Added {"pin":2,"value":121,"name":"l3"}
Press the r3 button:
Added {"pin":2,"value":123,"name":"r3"}
[?] Enter a filename to save this file (blank to skip):
@lukekarrys
Copy link

It tries to first fill in 50 frames of data from the controller here during calibration https://github.com/lukekarrys/hid-mapper/blob/master/lib/processData.js#L29-L32

Then it checks all those frames to see if the controller is toggling any pins by itself https://github.com/lukekarrys/hid-mapper/blob/master/lib/processData.js#L80

If that's the case, then it will ignore any changes on that pin https://github.com/lukekarrys/hid-mapper/blob/master/lib/processData.js#L122-L124

Also, before it will emit any change events, it checks to make sure that the current frame isn't any of the first 50 frames it filled up while calibrating https://github.com/lukekarrys/hid-mapper/blob/master/lib/processData.js#L57-L66

My code only accounts for one pin toggling though so that might be an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment