-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.hpp
32 lines (27 loc) · 1.02 KB
/
input.hpp
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
// Abstraction layer for input device (e.g. joystick, keyboard)
// Handle initialisation of input device with constructor / destructor
// Deliver 8 bit unsigned integer value with detected input (2^0 -> left, 2^1 -> right, 2^2 -> up, 2^3 -> down, 2^4 -> fire)
//
// Variant for RaspberryPi SenseHat joystick
//
// Written by Stefan Abendroth <sab@ab-solut.com>
// Last updated: 2022-02-09
#ifndef _INPUT_
#define _INPUT_
#include <cstdint> // uint8_t
#include "libs/joystick.h" // Raspberry Pi SenseHat joystick
#define INPUT_LEFT 1 // 2^0 -> left
#define INPUT_RIGHT 2 // 2^1 -> right
#define INPUT_UP 4 // 2^2 -> up
#define INPUT_DOWN 8 // 2^3 -> down
#define INPUT_FIRE 16 // 2^4 -> fire
class Input
{
public:
Input(); // Initialisation of input device
~Input(); // Close input device
uint8_t read(); // Deliver 8 bit unsigned integer value with detected input
private:
js_event ev; // SenseHat joystick event
};
#endif