Inital commit

This commit is contained in:
2023-02-09 11:54:14 +01:00
commit f19b4c485a
3 changed files with 115 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#include <Arduino.h>
#define NUM_KEYS 12
class Gamepad{
public:
enum Button {
B = 0x1,
Y = 0x2,
Select = 0x4,
Start = 0x8,
Up = 0x10,
Down = 0x20,
Left = 0x40,
Right = 0x80,
A = 0x100,
X = 0x200,
LeftShoulder = 0x400,
RightShoulder = 0x800
};
Gamepad(uint8_t latch, uint8_t clock, uint8_t data);
bool isPressed(Button button);
bool isPressedLast(Button button);
uint16_t getState();
uint16_t getLastState();
private:
uint16_t readCon();
uint16_t lastState = 0;
uint8_t latch;
uint8_t clock;
uint8_t data;
};