Reassigned buttons to match konami sdvx, removed startup delay, removed z axis

This commit is contained in:
Nicholas G
2020-09-30 13:03:05 -04:00
parent 92f93876f3
commit ce76dbcdc5
4 changed files with 28 additions and 29 deletions
+2 -3
View File
@@ -140,9 +140,8 @@ bool HID_::setup(USBSetup& setup)
if(setup.wLength == 3){
uint8_t data[3];
if (3 == USB_RecvControl(data, 3)){
iivx_led = (uint16_t) (data[2] << 8) + data[1];
//iivx_led = data[1];
reactiveTimeoutCount = 0;
iivx_led = (uint16_t) (data[2] << 8) + data[1];
reactiveTimeoutCount = 0;
}
return true;
}
+21 -12
View File
@@ -16,39 +16,39 @@ int currMode = EEPROM.read(0);
#define MOUSE_MULT 3
// Button Keybinds
#define BIND_ST KEY_RETURN
#define BIND_A 'a'
#define BIND_B 's'
#define BIND_C 'd'
#define BIND_D 'f'
#define BIND_FX_L 'z'
#define BIND_FX_R 'x'
#define BIND_ST KEY_RETURN
// Button Pinout
#define BT_ST 4
#define BT_A 5
#define BT_B 6
#define BT_C 7
#define BT_D 8
#define FX_L 9
#define FX_R 10
uint8_t buttonCount = 7;
#define BT_ST 4
// LED Pinout
#define BT_ST_LED 16
#define BT_A_LED 14
#define BT_B_LED 15
#define BT_C_LED 18
#define BT_D_LED 19
#define FX_L_LED 20
#define FX_R_LED 21
#define BT_ST_LED 16
// Number of cycles before HID falls back to reactive
unsigned long reactiveTimeoutMax = 1000;
unsigned long reactiveTimeoutCount = reactiveTimeoutMax;
uint8_t buttonPins[] = { BT_ST, BT_A, BT_B, BT_C, BT_D, FX_L, FX_R };
uint8_t ledPins[] = { BT_ST_LED, BT_A_LED, BT_B_LED, BT_C_LED, BT_D_LED, FX_L_LED, FX_R_LED };
uint8_t buttonPins[] = { BT_A, BT_B, BT_C, BT_D, FX_L, FX_R, BT_ST };
uint8_t ledPins[] = { BT_A_LED, BT_B_LED, BT_C_LED, BT_D_LED, FX_L_LED, FX_R_LED, BT_ST_LED };
uint8_t buttonCount = sizeof(buttonPins) / sizeof(buttonPins[0]);
// Encoder sensitivity = number of positions per rotation times 4 (24*4) / number of positions for HID report (256)
#define ENCODER_SENSITIVITY (double) 0.375
@@ -58,19 +58,22 @@ float knob2 = 0;
float old_knob1 = 0;
float old_knob2 = 0;
void lights(uint8_t lightDesc) {
for (int i = 0; i < buttonCount; i++) {
void lights(uint16_t lightDesc) {
for (int i = 0; i < buttonCount - 1; i++) {
if ((lightDesc >> i) & 1) {
digitalWrite(ledPins[i], HIGH);
} else {
digitalWrite(ledPins[i], LOW);
}
}
if ((lightDesc >> 8) & 1) {
digitalWrite(BT_ST_LED, HIGH);
} else {
digitalWrite(BT_ST_LED, LOW);
}
}
void setup() {
delay(500);
// Setup I/O for pins
for (int i = 0; i < buttonCount; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
@@ -190,14 +193,20 @@ void keyboard_mode() {
}
void joy_mode() {
// Read buttons
for (int i = 0; i < buttonCount; i++) {
// Read buttons except BT_ST
for (int i = 0; i < buttonCount - 1; i++) {
if (digitalRead(buttonPins[i]) != HIGH) {
report.buttons |= (uint16_t)1 << i;
} else {
report.buttons &= ~((uint16_t)1 << i);
}
}
// Read BT_ST
if (digitalRead(BT_ST) != HIGH) {
report.buttons |= (uint16_t)1 << 8;
} else {
report.buttons &= ~((uint16_t)1 << 8);
}
// Read Encoders
report.xAxis = (uint8_t)((int32_t)(encL.read() / ENCODER_SENSITIVITY) % 256);
+5 -7
View File
@@ -32,14 +32,14 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
0x09, 0x05, /* USAGE (Game Pad) */
0xa1, 0x01, /* COLLECTION (Application) */
0x85, 0x04, /* REPORT_ID */ //REPORT 4
0x85, 0x04, /* REPORT_ID set to 4 */
/*Buttons */
0x05, 0x09, /* USAGE_PAGE (Button) */
0x19, 0x01, /* USAGE_MINIMUM (Button 1) */
0x29, 0x0f, /* USAGE_MAXIMUM (Button 16) changed to 15*/
0x29, 0x0f, /* USAGE_MAXIMUM (Button 16) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x95, 0x0f, /* REPORT_COUNT (16) changed to 15*/
0x95, 0x0f, /* REPORT_COUNT (16) */
0x75, 0x01, /* REPORT_SIZE (1) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
/* Reserved byte */
@@ -50,17 +50,16 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
0x09, 0x30, /* USAGE (X) */
0x09, 0x31, /* USAGE (Y) */
0x09, 0x32, /* USAGE (Z) */
0x15, 0x81, /* LOGICAL_MINIMUM (0) */
0x25, 0x7f, /* LOGICAL_MAXIMUM (255) */
0x95, 0x03, /* REPORT_COUNT (3) */
0x95, 0x02, /* REPORT_COUNT (3) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
//iivx led
/*Lights config*/
0x85, 0x05, /* REPORT_ID set to 5*/
0x85, 0x05, /* REPORT_ID set to 5 */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
/*Led 1 */
@@ -201,7 +200,6 @@ void iivx_::setState(iivxReport_t *report)
data[2] = report->xAxis; // X axis
data[3] = report->yAxis; // Y axis
data[4] = report->zAxis; // Z axis
//HID_SendReport(Report number, array of values in same order as HID descriptor, length)
HID().SendReport(4, data, iivxByte);
-7
View File
@@ -24,12 +24,6 @@
#include "HID.h"
#if !defined(_USING_HID)
#warning "USING OLD HID CORE, UPGRADE TO ARDUINO 1.6.8"
#else
// Low level key report: up to 6 keys and shift, ctrl etc at once
extern volatile uint16_t iivx_led;
@@ -52,4 +46,3 @@ public:
extern iivx_ iivx;
#endif
#endif