2021-11-18 19:07:47 +00:00
|
|
|
#include <Joystick.h>
|
2021-11-18 20:48:29 +00:00
|
|
|
#include <Mux.h>
|
2021-11-18 19:07:47 +00:00
|
|
|
|
|
|
|
Joystick joystick(false);
|
|
|
|
|
2021-11-18 20:48:29 +00:00
|
|
|
// These defines match the board schematic
|
|
|
|
#define ENC1 2, 3
|
|
|
|
#define ENC2 4, 5
|
|
|
|
#define BTN1 6
|
|
|
|
#define BTN2 7
|
|
|
|
#define BTN3 8
|
|
|
|
#define BTN4 9
|
|
|
|
#define BTN5 10
|
|
|
|
#define BTN6 11
|
|
|
|
#define BTN7 12
|
|
|
|
#define BTN8 13
|
|
|
|
#define BTN9 A0
|
|
|
|
|
|
|
|
// Buttons 10 and higher are all on A1 (the MUX signal pin), these are multiplexer channel IDs
|
|
|
|
#define BTN10 0
|
|
|
|
#define BTN11 1
|
|
|
|
#define BTN12 2
|
|
|
|
#define BTN13 3
|
|
|
|
#define BTN14 4
|
|
|
|
#define BTN15 5
|
|
|
|
#define BTN16 6
|
|
|
|
#define BTN17 7
|
|
|
|
#define BTN18 8
|
|
|
|
#define BTN19 9
|
|
|
|
#define BTN20 10
|
|
|
|
#define BTN21 11
|
|
|
|
#define BTN22 12
|
|
|
|
#define KBTN1 13
|
|
|
|
#define KBTN2 14
|
|
|
|
#define KBTN3 15
|
|
|
|
|
2021-11-18 19:07:47 +00:00
|
|
|
void setup() {
|
2021-11-18 20:48:29 +00:00
|
|
|
// Encoders
|
|
|
|
joystick.AddEncoder(ENC1, ENCODER_PULSED_SPLIT);
|
|
|
|
joystick.AddEncoder(ENC2, ENCODER_PULSED_SPLIT);
|
2021-11-18 19:07:47 +00:00
|
|
|
|
|
|
|
// // Power switches
|
2021-11-18 20:48:29 +00:00
|
|
|
joystick.AddButton(BTN1, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
|
|
|
joystick.AddButton(BTN2, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
|
|
|
joystick.AddButton(BTN3, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
|
|
|
joystick.AddButton(BTN4, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
|
2021-11-18 19:07:47 +00:00
|
|
|
|
|
|
|
// // HUD modes
|
2021-11-18 20:48:29 +00:00
|
|
|
joystick.AddButton(BTN5, BUTTON_PASSTHRU);
|
|
|
|
joystick.AddButton(BTN6, BUTTON_PASSTHRU);
|
|
|
|
joystick.AddButton(BTN7, BUTTON_PASSTHRU);
|
2021-11-18 19:07:47 +00:00
|
|
|
|
|
|
|
// // Mining Modules
|
2021-11-18 20:48:29 +00:00
|
|
|
joystick.AddButton(BTN8, BUTTON_PASSTHRU);
|
|
|
|
joystick.AddButton(BTN9, BUTTON_PASSTHRU);
|
|
|
|
joystick.AddButton(BTN10, BUTTON_PASSTHRU, true, mux);
|
2021-11-18 19:07:47 +00:00
|
|
|
|
|
|
|
// // Flight Modes
|
2021-11-18 20:48:29 +00:00
|
|
|
joystick.AddButton(BTN11, BUTTON_PASSTHRU, true, mux);
|
|
|
|
joystick.AddButton(BTN12, BUTTON_PASSTHRU, true, mux);
|
|
|
|
joystick.AddButton(BTN13, BUTTON_PASSTHRU, true, mux);
|
|
|
|
joystick.AddButton(BTN14, BUTTON_PASSTHRU, true, mux);
|
2021-11-18 19:07:47 +00:00
|
|
|
|
|
|
|
// // Doors & Lights
|
2021-11-18 20:48:29 +00:00
|
|
|
joystick.AddButton(BTN15, BUTTON_PULSED_DOUBLE_ACTION, true, mux);
|
|
|
|
joystick.AddButton(BTN16, BUTTON_PULSED_DOUBLE_ACTION_SPLIT, true, mux);
|
|
|
|
joystick.AddButton(BTN17, BUTTON_PULSED_DOUBLE_ACTION_SPLIT, true, mux);
|
2021-11-18 19:07:47 +00:00
|
|
|
|
|
|
|
// // Emergency Panel
|
2021-11-18 20:48:29 +00:00
|
|
|
joystick.AddButton(KBTN1, BUTTON_PASSTHRU);
|
|
|
|
joystick.AddButton(KBTN2, BUTTON_PASSTHRU);
|
|
|
|
joystick.AddButton(KBTN3, BUTTON_PASSTHRU);
|
2021-11-18 19:07:47 +00:00
|
|
|
|
|
|
|
joystick.Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
joystick.Update();
|
|
|
|
}
|