2010-09-25 17:46:12 +02:00
|
|
|
#ifndef __GTK_CONTROL_H
|
|
|
|
#define __GTK_CONTROL_H
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
|
|
|
|
#include "gtk_binding.h"
|
|
|
|
#ifdef USE_JOYSTICK
|
|
|
|
#include "SDL.h"
|
|
|
|
#endif
|
|
|
|
|
2018-11-02 21:47:31 +01:00
|
|
|
const int NUM_JOYPADS = 10;
|
2010-09-25 17:46:12 +02:00
|
|
|
|
2018-11-02 21:47:31 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
JOY_MODE_GLOBAL = 0,
|
|
|
|
JOY_MODE_INDIVIDUAL = 1,
|
|
|
|
JOY_MODE_CALIBRATE = 2
|
|
|
|
};
|
2010-09-25 17:46:12 +02:00
|
|
|
|
2018-11-02 21:47:31 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
JOY_RELEASED = 0,
|
|
|
|
JOY_PRESSED = 1
|
|
|
|
};
|
2010-09-25 17:46:12 +02:00
|
|
|
|
2018-11-02 21:47:31 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PORT_COMMAND_FULLSCREEN = 1,
|
|
|
|
PORT_COMMAND_SAVE_SPC = 2,
|
|
|
|
PORT_OPEN_ROM = 3,
|
|
|
|
PORT_PAUSE = 4,
|
|
|
|
PORT_SEEK_TO_FRAME = 5,
|
|
|
|
PORT_QUIT = 6,
|
|
|
|
PORT_SWAP_CONTROLLERS = 7,
|
|
|
|
PORT_REWIND = 8,
|
|
|
|
PORT_QUICKLOAD0 = 9,
|
|
|
|
PORT_QUICKLOAD1 = 10,
|
|
|
|
PORT_QUICKLOAD2 = 11,
|
|
|
|
PORT_QUICKLOAD3 = 12,
|
|
|
|
PORT_QUICKLOAD4 = 13,
|
|
|
|
PORT_QUICKLOAD5 = 14,
|
|
|
|
PORT_QUICKLOAD6 = 15,
|
|
|
|
PORT_QUICKLOAD7 = 16,
|
|
|
|
PORT_QUICKLOAD8 = 17,
|
|
|
|
PORT_QUICKLOAD9 = 18
|
|
|
|
};
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
typedef struct BindingLink
|
|
|
|
{
|
|
|
|
const char *button_name;
|
|
|
|
const char *snes9x_name;
|
|
|
|
|
|
|
|
} BindingLink;
|
|
|
|
|
|
|
|
extern const BindingLink b_links[];
|
|
|
|
extern const int b_breaks[];
|
2018-11-02 21:47:31 +01:00
|
|
|
const int NUM_JOYPAD_LINKS = 24;
|
|
|
|
const int NUM_EMU_LINKS = 55;
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
typedef struct JoypadBinding
|
|
|
|
{
|
|
|
|
Binding data[NUM_JOYPAD_LINKS]; /* Avoid packing issues */
|
|
|
|
} JoypadBinding;
|
|
|
|
|
|
|
|
#ifdef USE_JOYSTICK
|
|
|
|
|
2018-11-02 21:27:12 +01:00
|
|
|
bool S9xGrabJoysticks ();
|
|
|
|
void S9xReleaseJoysticks ();
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
typedef struct JoyEvent
|
|
|
|
{
|
|
|
|
unsigned int parameter;
|
|
|
|
unsigned int state;
|
|
|
|
|
|
|
|
} JoyEvent;
|
|
|
|
|
|
|
|
typedef struct Calibration
|
|
|
|
{
|
|
|
|
int min;
|
|
|
|
int max;
|
|
|
|
int center;
|
|
|
|
} Calibration;
|
|
|
|
|
|
|
|
class JoyDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
JoyDevice (unsigned int device_num);
|
2018-11-02 21:27:12 +01:00
|
|
|
~JoyDevice ();
|
2010-09-25 17:46:12 +02:00
|
|
|
int get_event (JoyEvent *event);
|
2018-11-02 21:27:12 +01:00
|
|
|
void flush ();
|
2010-09-25 17:46:12 +02:00
|
|
|
void handle_event (SDL_Event *event);
|
2018-11-02 21:27:12 +01:00
|
|
|
void register_centers ();
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
SDL_Joystick *filedes;
|
|
|
|
Calibration *calibration;
|
|
|
|
std::queue<JoyEvent> queue;
|
|
|
|
int mode;
|
|
|
|
int joynum;
|
|
|
|
int num_axes;
|
|
|
|
int num_hats;
|
|
|
|
int *axis;
|
|
|
|
int *hat;
|
|
|
|
bool enabled;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2018-11-02 21:52:26 +01:00
|
|
|
void poll_events ();
|
2014-02-05 10:22:07 +01:00
|
|
|
void add_event (unsigned int parameter, unsigned int state);
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-11-02 21:27:12 +01:00
|
|
|
void S9xDeinitInputDevices ();
|
2010-09-25 17:46:12 +02:00
|
|
|
Binding S9xGetBindingByName (const char *name);
|
2018-11-02 21:27:12 +01:00
|
|
|
bool S9xIsMousePluggedIn ();
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
#endif /* __GTK_CONTROL_H*/
|