Compare commits
3 Commits
edaf38c598
...
c7807b0c26
Author | SHA1 | Date |
---|---|---|
Neale Pickett | c7807b0c26 | |
Neale Pickett | cd62fa7eba | |
Neale Pickett | f35e123474 |
10
Makefile
10
Makefile
|
@ -15,13 +15,11 @@ firmwares: MockBand.drums.hex
|
||||||
MockBand.drums.hex: VID=0x1bad
|
MockBand.drums.hex: VID=0x1bad
|
||||||
MockBand.drums.hex: PID=0x3110
|
MockBand.drums.hex: PID=0x3110
|
||||||
|
|
||||||
firmwares: MockBand.drumsx.hex
|
MockBand.drums-xbox.hex: VID=0x1bad
|
||||||
MockBand.drumsx.hex: VID=0x1bad
|
MockBand.drums-xbox.hex: PID=0x0003
|
||||||
MockBand.drumsx.hex: PID=0x0003
|
|
||||||
|
|
||||||
firmwares: MockBand.drums1.hex
|
MockBand.drums-rb1.hex: VID=0x1bad
|
||||||
MockBand.drums1.hex: VID=0x1bad
|
MockBand.drums-rb1.hex: PID=00005
|
||||||
MockBand.drums1.hex: PID=00005
|
|
||||||
|
|
||||||
|
|
||||||
MockBand.%.hex: MockBand.ino
|
MockBand.%.hex: MockBand.ino
|
||||||
|
|
52
MockBand.ino
52
MockBand.ino
|
@ -2,8 +2,6 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <PluggableUSB.h>
|
#include <PluggableUSB.h>
|
||||||
|
|
||||||
//#define DEBUG
|
|
||||||
|
|
||||||
#include "hid.hh" // Modified HID library: doesn't prefix each packet with ID
|
#include "hid.hh" // Modified HID library: doesn't prefix each packet with ID
|
||||||
#include "instrument.hh"
|
#include "instrument.hh"
|
||||||
#include "standard.hh" // Standard pins
|
#include "standard.hh" // Standard pins
|
||||||
|
@ -28,7 +26,9 @@
|
||||||
#error USB_VID must be set to 0x1bad: see INSTALL.md
|
#error USB_VID must be set to 0x1bad: see INSTALL.md
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USB_PID == 0x0004
|
#if USB_PID == 0x0003
|
||||||
|
#define DRUM // XBox
|
||||||
|
#elif USB_PID == 0x0004
|
||||||
#define GUITAR
|
#define GUITAR
|
||||||
#elif USB_PID == 0x0005
|
#elif USB_PID == 0x0005
|
||||||
#define DRUM // Wii RB1
|
#define DRUM // Wii RB1
|
||||||
|
@ -127,43 +127,57 @@ void loop() {
|
||||||
//
|
//
|
||||||
// Calculate and send an HID update
|
// 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
|
#ifdef GUITAR
|
||||||
buttonState.buttons |= (buttons >> 10) & 0b11111; // Solo keys
|
buttonState.buttons |= (vbuttons >> 10) & 0b11111; // Solo keys
|
||||||
bitWrite(buttonState.buttons, 6, buttons & (0b11111 << 10)); // Solo modifier
|
bitWrite(buttonState.buttons, 6, vbuttons & (0b11111 << 10)); // Solo modifier
|
||||||
|
|
||||||
if (bitRead(buttons, 6)) {
|
if (bitRead(vbuttons, 6)) {
|
||||||
buttonState.hatAndConstant = 0; // up
|
buttonState.hatAndConstant = 0; // up
|
||||||
} else if bitRead(buttons, 7) { //
|
} else if bitRead(vbuttons, 7) {
|
||||||
buttonState.hatAndConstant = 4; // down
|
buttonState.hatAndConstant = 4; // down
|
||||||
} else {
|
} else {
|
||||||
buttonState.hatAndConstant = 8; // nothing
|
buttonState.hatAndConstant = 8; // nothing
|
||||||
}
|
}
|
||||||
#else // DRUMS
|
#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[0] = bitRead(buttonState.buttons, 3)?127:0; // Y
|
||||||
buttonState.velocity[1] = bitRead(buttonState.buttons, 2)?127:0; // R
|
buttonState.velocity[1] = bitRead(buttonState.buttons, 2)?127:0; // R
|
||||||
buttonState.velocity[2] = bitRead(buttonState.buttons, 1)?127:0; // G
|
buttonState.velocity[2] = bitRead(buttonState.buttons, 1)?127:0; // G
|
||||||
buttonState.velocity[3] = bitRead(buttonState.buttons, 0)?127:0; // B
|
buttonState.velocity[3] = bitRead(buttonState.buttons, 0)?127:0; // B
|
||||||
|
|
||||||
// Say the D-pad is centered
|
// Clone Hero 1.0.0.4080-final needs blue and yellow cymbals to send up and down on d-pad.
|
||||||
buttonState.hatAndConstant = 8;
|
// 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
|
#endif
|
||||||
|
|
||||||
#ifdef DPAD
|
#ifdef DPAD
|
||||||
#error DPAD isn't implemented yet
|
#error DPAD isn't implemented yet
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
// Log sample rate to the second Y axis
|
||||||
// Log sample rate to the first X axis
|
buttonState.axis[3] = samples & 0xff;
|
||||||
buttonState.axis[0] = samples & 0xff;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Send an update
|
// Send an update
|
||||||
HID().SendReport(0, (uint8_t *)&buttonState, 27);
|
HID().SendReport(0, (uint8_t *)&buttonState, 27);
|
||||||
|
|
|
@ -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
|
|
@ -11,12 +11,11 @@ Sample Rate
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
The number of samples taken since the last HID report
|
The number of samples taken since the last HID report
|
||||||
is sent as the second Y axis.
|
is sent as the second Y axis,
|
||||||
If you `#define DEBUG`,
|
which doesn't appear to be used by anything else.
|
||||||
you can use the
|
You can use the
|
||||||
[included gamepad tester](gamepad.html),
|
[included gamepad tester](gamepad.html),
|
||||||
to see the approximate number of samples as an integer,
|
to see the approximate number of samples as an integer.
|
||||||
on the first X axis.
|
|
||||||
|
|
||||||
This is approximate,
|
This is approximate,
|
||||||
because the browser encodes the value as a real number between -1 and 1.
|
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,
|
It's close enough for me,
|
||||||
hopefully it's close enough for you.
|
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
|
Debouncing
|
||||||
----------
|
----------
|
||||||
|
@ -132,8 +136,31 @@ None of the Wii games I have
|
||||||
seem to care what these values are set to.
|
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
|
References
|
||||||
=========
|
==========
|
||||||
|
|
||||||
The most valuable sources of information I found were:
|
The most valuable sources of information I found were:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue