/
controls.h
65 lines (50 loc) · 1.37 KB
/
controls.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include <Arduino.h>
#include "weirdmath.h"
#define BUTTON_CLOCK 48
#define BUTTON_DATA 49
#define BUTTON_LATCH 50
#define BUTTON_SHIFTMASK_B 0x80
#define BUTTON_SHIFTMASK_A 0x40
#define BUTTON_SHIFTMASK_START 0x20
#define BUTTON_SHIFTMASK_SELECT 0x10
#define JOYSTICK_X A11
#define JOYSTICK_Y A10
#define JOYSTICK_X_CENTER 512
#define JOYSTICK_Y_CENTER 512
#define PAD_A 0x01
#define PAD_B 0x02
#define PAD_SELECT 0x04
#define PAD_START 0x08
#define PAD_UP 0x10
#define PAD_DOWN 0x20
#define PAD_LEFT 0x40
#define PAD_RIGHT 0x80
#define KEYLAYER_0 0
#define KEYLAYER_1 1
#define KEYLAYER_2 2
#define KEYLAYER_3 3
#define KEYLAYER_4 4
#define KEYLAYER_5 5
enum class Keymod { a, b, ab, select, start, none };
class Controls {
public:
void begin();
int16_t readJoystickX(uint8_t sampling = 3);
int16_t readJoystickY(uint8_t sampling = 3);
uint32_t readButtons();
uint32_t justPressed();
uint32_t justReleased();
private:
uint32_t last_buttons;
uint32_t curr_buttons;
uint32_t justpressed_buttons;
uint32_t justreleased_buttons;
};
enum class MenuMode { live, menu1, menu2 };
enum class Menu1Control { env, mod, filter, delay };
enum class Menu2Control { bpm, chain, wave, file };
Menu1Control &operator++(Menu1Control &s);
Menu1Control &operator--(Menu1Control &s);
Menu2Control &operator++(Menu2Control &s);
Menu2Control &operator--(Menu2Control &s);