mockband/docs/NOTES.md

79 lines
1.7 KiB
Markdown
Raw Normal View History

2024-01-01 12:19:50 -07:00
Sample Rate
-----------
The number of samples taken since the last HID report
is sent as the second Y axis.
If you use the
[included gamepad tester](gamepad.html),
it will show the approximate number of samples as an integer,
for Y axis 2.
This is approximate,
because the browser encodes the value as a real number between -1 and 1.
We convert it back, but may lose a little precision.
It's close enough for me,
hopefully it's close enough for you.
Debouncing
----------
Using `millis()` time to debounce the switch
roughly halved my sample frequency.
So instead, I do some preprocessor arithmetic
to calculate how many samples to take after an edge,
in order to debounce switches.
The drum controller was a partcular pain:
in addition to the switch bouncing,
the stick was bouncing on the rubber pad.
I settled on a 40ms silence window as feeling pretty good.
You can adjust this if you want to.
2024-01-04 13:10:56 -07:00
USB Junk
========
Gamepad Buttons
---------------
The `buttons` struct member is a bitmap,
each bit mapping to one of the 12 buttons reported through HID.
Here's what each bit means:
2024-01-04 13:10:56 -07:00
* 0o00: Blue
* 0o01: Green
* 0o02: Red
* 0o03: Yellow
* 0o04: Orange
* 0o05: Tilt Switch / 2x kick
* 0o06: Solo modifier (second row of buttons on guitar)
* 0o07: ???
* 0o10: Minus
* 0o11: Plus
* 0o12: Drum pad modifier
* 0o13: Cymbal modifier
* 0o14: Select
hatAndConstant
--------------
2024-01-04 13:10:56 -07:00
Here's what the values mean:
* 2: right
* 6: left
* 0: up
* 4: down
* 8: nothing
2024-01-04 13:10:56 -07:00
velocity
--------
I don't know how I can verify that I'm setting this right,
but the `rbdrum2midi` program looks at these bytes to detect hits.
I set them to 127 when a hit is detected on the digital pin.
Sending these values does not seem to cause problems with my Wii games.