blob: 718b4dca5278ff36d10cf098f21ff941dc8e5b0d (
plain) (
blame)
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
66
67
68
69
70
71
72
73
74
|
/*
* jsi (Joystick interface) c libray
*/
#ifdef _WIN32
#include <Windows.h>
#else
// Linux header.
#include <linux/types.h>
#include <linux/input.h>
#include <linux/joystick.h>
// Unix headers.
#include <fcntl.h>
#include <unistd.h>
#endif
// OS headers.
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
// C.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
#ifndef JSI_H
#define JSI_H
#define JSI_VERSION "Still in making"
#define JSI_TRUE 1
#define JSI_FALSE 0
#define JSI_NAME_MAX 128
#define JSI_UP 0x0
#define JSI_DOWN 0x1
#define JSI_TYPE_BUTTON 0x1
#define JSI_TYPE_AXIS 0x2
#define JSI_TYPE_INIT 0x80
struct jsi_joy_layout {
int axes;
int buttons;
char name[JSI_NAME_MAX];
};
typedef struct {
int fd;
int num;
int joystick_count_init;
struct jsi_joy_layout layout;
} jsi_joystick;
struct jsi_event {
int value;
int type;
int num;
};
int jsi_get_joystick(int joy_num, jsi_joystick * joystick_data);
void jsi_close_joystick(jsi_joystick joystick_data);
int jsi_joy_count();
int jsi_get_event(jsi_joystick joystick_data, struct jsi_event * event_data);
#endif // JSI_H
|