Compare commits

...

3 Commits

Author SHA1 Message Date
Neale Pickett c7807b0c26 Cleanup
Mockband / build (push) Failing after 20s Details
2024-01-07 15:55:26 -07:00
Neale Pickett cd62fa7eba Hi hat now makes yellow cymbal = blue cymbal 2024-01-07 15:29:50 -07:00
Neale Pickett f35e123474 Send CH-friendly dpad on cymbals; +XBox drum PID 2024-01-07 14:54:34 -07:00
4 changed files with 97 additions and 31 deletions

View File

@ -15,13 +15,11 @@ firmwares: MockBand.drums.hex
MockBand.drums.hex: VID=0x1bad
MockBand.drums.hex: PID=0x3110
firmwares: MockBand.drumsx.hex
MockBand.drumsx.hex: VID=0x1bad
MockBand.drumsx.hex: PID=0x0003
MockBand.drums-xbox.hex: VID=0x1bad
MockBand.drums-xbox.hex: PID=0x0003
firmwares: MockBand.drums1.hex
MockBand.drums1.hex: VID=0x1bad
MockBand.drums1.hex: PID=00005
MockBand.drums-rb1.hex: VID=0x1bad
MockBand.drums-rb1.hex: PID=00005
MockBand.%.hex: MockBand.ino

View File

@ -2,8 +2,6 @@
#include <Arduino.h>
#include <PluggableUSB.h>
//#define DEBUG
#include "hid.hh" // Modified HID library: doesn't prefix each packet with ID
#include "instrument.hh"
#include "standard.hh" // Standard pins
@ -28,7 +26,9 @@
#error USB_VID must be set to 0x1bad: see INSTALL.md
#endif
#if USB_PID == 0x0004
#if USB_PID == 0x0003
#define DRUM // XBox
#elif USB_PID == 0x0004
#define GUITAR
#elif USB_PID == 0x0005
#define DRUM // Wii RB1
@ -127,43 +127,57 @@ void loop() {
//
// Calculate and send an HID update
//
uint16_t vbuttons = buttons; // We're going to mess with the button state
buttonState.buttons = (buttons & 0b1100111111); // +-..!OYRGB
buttonState.buttons = (vbuttons & 0b1100111111); // +-..!OYRGB
#ifdef GUITAR
buttonState.buttons |= (buttons >> 10) & 0b11111; // Solo keys
bitWrite(buttonState.buttons, 6, buttons & (0b11111 << 10)); // Solo modifier
buttonState.buttons |= (vbuttons >> 10) & 0b11111; // Solo keys
bitWrite(buttonState.buttons, 6, vbuttons & (0b11111 << 10)); // Solo modifier
if (bitRead(buttons, 6)) {
if (bitRead(vbuttons, 6)) {
buttonState.hatAndConstant = 0; // up
} else if bitRead(buttons, 7) { //
} else if bitRead(vbuttons, 7) {
buttonState.hatAndConstant = 4; // down
} else {
buttonState.hatAndConstant = 8; // nothing
}
#else // DRUMS
buttonState.buttons |= (buttons >> 10) & 0b01011; // Cymbals
bitWrite(buttonState.buttons, 10, (buttons >> 0) & 0b01111); // Drum pad modifier
bitWrite(buttonState.buttons, 11, (buttons >> 10) & 0b01011); // Cymbals modifier
buttonState.axis[3] = bitRead(buttons, 12)?255:0; // High hat
// rbdrum2midi wants these set
// Hi hat pedal (SOLO_RED) makes yellow cymbal strike a blue cymbal strike
if (bitRead(vbuttons, 12) && bitRead(vbuttons, 13)) {
bitClear(vbuttons, 13);
bitSet(vbuttons, 10);
}
buttonState.buttons |= (vbuttons >> 10) & 0b01011; // Cymbals
bitWrite(buttonState.buttons, 10, (vbuttons >> 0) & 0b01111); // Drum pad modifier
bitWrite(buttonState.buttons, 11, (vbuttons >> 10) & 0b01011); // Cymbals modifier
// rbdrum2midi wants these set: it ignores the button states.
buttonState.velocity[0] = bitRead(buttonState.buttons, 3)?127:0; // Y
buttonState.velocity[1] = bitRead(buttonState.buttons, 2)?127:0; // R
buttonState.velocity[2] = bitRead(buttonState.buttons, 1)?127:0; // G
buttonState.velocity[3] = bitRead(buttonState.buttons, 0)?127:0; // B
// Say the D-pad is centered
buttonState.hatAndConstant = 8;
// Clone Hero 1.0.0.4080-final needs blue and yellow cymbals to send up and down on d-pad.
// This is what the mysterous CymExt1 and CymExt2 mappings mean.
// If these aren't set, all pads (except red) register as simultaneous drum and cymbal hits.
if (bitRead(vbuttons, 13)) {
buttonState.hatAndConstant = 0; // up
} else if (bitRead(vbuttons, 10)) {
buttonState.hatAndConstant = 4; // down
} else {
buttonState.hatAndConstant = 8; // nothing
}
#endif
#ifdef DPAD
#error DPAD isn't implemented yet
#endif
#ifdef DEBUG
// Log sample rate to the first X axis
buttonState.axis[0] = samples & 0xff;
#endif
// Log sample rate to the second Y axis
buttonState.axis[3] = samples & 0xff;
// Send an update
HID().SendReport(0, (uint8_t *)&buttonState, 27);

27
docs/CHANGELOG.md Normal file
View File

@ -0,0 +1,27 @@
# Changelog
## [1.0-beta2] - 2024-01-07
### Added
- CI/CD build
- Make-based build, but it still works with the Arduino IDE!
- XBox controller
### Fixed
- Blue and Yellow cymbal strikes send up and down on the D-pad.
- This fixes a bug with Clone Hero where Blue, Yellow, and Green pads,
both cymbal and drum pads,
triggered a drum and cymbal hit at the same time.
- Clone Hero's mysterious CymExt1 and CymExt2 are read on Yellow and Blue
cymbal hits, and must map to dpad up and down. In Windows this might be called "POV Hat";
in Linux it's called "Hat 0"
### Changed
- The "high hat" pin now causes the yellow cymbal to send a blue cymbal hit,
similar to devices sold in the past for this express purpose.
Previously it changed a hat axis,
because I thought "hat" meant "high hat". Heh.
### Removed
- No more DEBUG option
## [1.0-beta1] - 2024-01-04

View File

@ -11,12 +11,11 @@ Sample Rate
-----------
The number of samples taken since the last HID report
is sent as the second Y axis.
If you `#define DEBUG`,
you can use the
is sent as the second Y axis,
which doesn't appear to be used by anything else.
You can use the
[included gamepad tester](gamepad.html),
to see the approximate number of samples as an integer,
on the first X axis.
to see the approximate number of samples as an integer.
This is approximate,
because the browser encodes the value as a real number between -1 and 1.
@ -24,6 +23,11 @@ We convert it back, but may lose a little precision.
It's close enough for me,
hopefully it's close enough for you.
This number will not be very useful
unless you are polling the wammy bar,
since without that input,
updates are only sent when a button state changes.
Debouncing
----------
@ -132,8 +136,31 @@ None of the Wii games I have
seem to care what these values are set to.
Clone Hero
==========
This controller doesn't have a dpad (currently),
so we're using 12 buttons to represent the state of 9 inputs.
Sometimes software is just weird!
Clone Hero has two undocumented CymExt1 and CymExt2 mappings.
It talks about what they should be set to (on Windows) in the wiki,
but doesn't explain what they're used for.
It seems that Clone Hero expects the Yellow and Blue cymbals
to send dpad inputs, in addition to the pad color and cymbal modifier.
If the controller doesn't send these,
then every drum pad hit plays that color's drum and cymbal at the same time,
and every cymbal pad hit does the same thing.
I'm not exactly sure why Clone Hero does this,
but in any case,
Mockband sends the right things now,
so the drum controller should work correctly after you map everything.
References
=========
==========
The most valuable sources of information I found were: