blob: dcb70b69402d8a23d584cf138f844e6234b43166 (
plain)
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
|
/*
* gamepad.c: A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id$
*/
#ifndef GAMEPAD_HANDLER_H
#define GAMEPAD_HANDLER_H
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <inttypes.h>
class cGamepadHandler
{
public:
typedef enum
{
PRESS,
RELEASE,
REPEAT,
} event_type;
typedef struct
{
int key;
event_type type;
} generic_event;
cGamepadHandler();
virtual ~cGamepadHandler();
bool connect(const char* dev);
void disconnect();
bool ready();
int buttons();
int axes();
char* name();
generic_event* event(void);
static const int MAX_NUM_BUTTONS = 16;
static const int MAX_NUM_AXIS = 8;
static const int AXIS_DEAD_ZONE = 15000;
static const int MAX_KEYS = MAX_NUM_BUTTONS + 2*MAX_NUM_AXIS;
private:
int m_fd;
generic_event m_event;
int m_axis_state[MAX_NUM_AXIS];
};
#endif
|