Compare commits
No commits in common. "c7807b0c26c8a0a5fe81ad06a7d7045304c14a79" and "edaf38c598e268c23df3204dc3ae155f4158e4f8" have entirely different histories.
c7807b0c26
...
edaf38c598
10
Makefile
10
Makefile
|
@ -15,11 +15,13 @@ firmwares: MockBand.drums.hex
|
||||||
MockBand.drums.hex: VID=0x1bad
|
MockBand.drums.hex: VID=0x1bad
|
||||||
MockBand.drums.hex: PID=0x3110
|
MockBand.drums.hex: PID=0x3110
|
||||||
|
|
||||||
MockBand.drums-xbox.hex: VID=0x1bad
|
firmwares: MockBand.drumsx.hex
|
||||||
MockBand.drums-xbox.hex: PID=0x0003
|
MockBand.drumsx.hex: VID=0x1bad
|
||||||
|
MockBand.drumsx.hex: PID=0x0003
|
||||||
|
|
||||||
MockBand.drums-rb1.hex: VID=0x1bad
|
firmwares: MockBand.drums1.hex
|
||||||
MockBand.drums-rb1.hex: PID=00005
|
MockBand.drums1.hex: VID=0x1bad
|
||||||
|
MockBand.drums1.hex: PID=00005
|
||||||
|
|
||||||
|
|
||||||
MockBand.%.hex: MockBand.ino
|
MockBand.%.hex: MockBand.ino
|
||||||
|
|
52
MockBand.ino
52
MockBand.ino
|
@ -2,6 +2,8 @@
|
||||||
#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
|
||||||
|
@ -26,9 +28,7 @@
|
||||||
#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 == 0x0003
|
#if USB_PID == 0x0004
|
||||||
#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,57 +127,43 @@ 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 = (vbuttons & 0b1100111111); // +-..!OYRGB
|
buttonState.buttons = (buttons & 0b1100111111); // +-..!OYRGB
|
||||||
#ifdef GUITAR
|
#ifdef GUITAR
|
||||||
buttonState.buttons |= (vbuttons >> 10) & 0b11111; // Solo keys
|
buttonState.buttons |= (buttons >> 10) & 0b11111; // Solo keys
|
||||||
bitWrite(buttonState.buttons, 6, vbuttons & (0b11111 << 10)); // Solo modifier
|
bitWrite(buttonState.buttons, 6, buttons & (0b11111 << 10)); // Solo modifier
|
||||||
|
|
||||||
if (bitRead(vbuttons, 6)) {
|
if (bitRead(buttons, 6)) {
|
||||||
buttonState.hatAndConstant = 0; // up
|
buttonState.hatAndConstant = 0; // up
|
||||||
} else if bitRead(vbuttons, 7) {
|
} else if bitRead(buttons, 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
|
||||||
|
|
||||||
// Hi hat pedal (SOLO_RED) makes yellow cymbal strike a blue cymbal strike
|
// rbdrum2midi wants these set
|
||||||
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
|
||||||
|
|
||||||
// Clone Hero 1.0.0.4080-final needs blue and yellow cymbals to send up and down on d-pad.
|
// Say the D-pad is centered
|
||||||
// This is what the mysterous CymExt1 and CymExt2 mappings mean.
|
buttonState.hatAndConstant = 8;
|
||||||
// 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
|
||||||
|
|
||||||
// Log sample rate to the second Y axis
|
#ifdef DEBUG
|
||||||
buttonState.axis[3] = samples & 0xff;
|
// Log sample rate to the first X axis
|
||||||
|
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);
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
# 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,11 +11,12 @@ 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.
|
||||||
which doesn't appear to be used by anything else.
|
If you `#define DEBUG`,
|
||||||
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.
|
||||||
|
@ -23,11 +24,6 @@ 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
|
||||||
----------
|
----------
|
||||||
|
@ -136,31 +132,8 @@ 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