57 lines
1016 B
C
57 lines
1016 B
C
/*
|
|
* Released into the public domain
|
|
* by Aki Goto <tyatsumi@gmail.com>
|
|
*/
|
|
|
|
#ifndef GAMEPAD_H
|
|
#define GAMEPAD_H
|
|
|
|
#include <linux/joystick.h>
|
|
|
|
enum {
|
|
ButtonId_UP,
|
|
ButtonId_DOWN,
|
|
ButtonId_LEFT,
|
|
ButtonId_RIGHT,
|
|
ButtonId_A,
|
|
ButtonId_B,
|
|
ButtonId_X,
|
|
ButtonId_Y,
|
|
ButtonId_L1,
|
|
ButtonId_R1,
|
|
ButtonId_L2,
|
|
ButtonId_R2,
|
|
};
|
|
|
|
enum {
|
|
ButtonType_BUTTON,
|
|
ButtonType_POSITIVE_AXIS,
|
|
ButtonType_NEGATIVE_AXIS,
|
|
};
|
|
|
|
struct Button {
|
|
int id;
|
|
int type;
|
|
int number;
|
|
struct Button *shift;
|
|
struct Button *control;
|
|
struct Button *alt;
|
|
int prev;
|
|
int current;
|
|
};
|
|
|
|
extern void Button_initialize(struct Button *this, int id);
|
|
extern void Button_setDevice(struct Button *this, int type, int number);
|
|
extern int Button_update(struct Button *this, struct js_event *event);
|
|
extern int Button_isDown(struct Button *this);
|
|
extern int Button_isUp(struct Button *this);
|
|
extern int Button_isHolded(struct Button *this);
|
|
|
|
struct Gamepad {
|
|
struct Button buttons[12];
|
|
};
|
|
|
|
extern void Gamepad_initialize(struct Gamepad *this);
|
|
|
|
#endif
|