GTK+: Clean up control stuff a bit.

This commit is contained in:
Brandon Wright 2018-11-02 15:27:12 -05:00
parent 7700efe1fc
commit 61d691a523
3 changed files with 31 additions and 77 deletions

View File

@ -20,11 +20,8 @@ Binding::Binding (void)
Binding::Binding (GdkEventKey *event) Binding::Binding (GdkEventKey *event)
{ {
/* Make keypress lower-case */ event->keyval = gdk_keyval_to_lower (event->keyval);
if (event->keyval >= GDK_A && event->keyval <= GDK_Z) value = BINDING_KEY | (event->keyval & BINDING_KEY_MASK);
value = BINDING_KEY | ((event->keyval - GDK_A + GDK_a) & BINDING_KEY_MASK);
else
value = BINDING_KEY | (event->keyval & BINDING_KEY_MASK);
/* Strip modifiers from modifiers */ /* Strip modifiers from modifiers */
if (event->keyval == GDK_Control_L || if (event->keyval == GDK_Control_L ||

View File

@ -112,20 +112,17 @@ const int b_breaks[] =
static int joystick_lock = 0; static int joystick_lock = 0;
bool bool S9xPollButton (uint32 id, bool *pressed)
S9xPollButton (uint32 id, bool *pressed)
{ {
return true; return true;
} }
bool bool S9xPollAxis (uint32 id, int16 *value)
S9xPollAxis (uint32 id, int16 *value)
{ {
return true; return true;
} }
bool bool S9xPollPointer (uint32 id, int16 *x, int16 *y)
S9xPollPointer (uint32 id, int16 *x, int16 *y)
{ {
*x = top_level->mouse_loc_x; *x = top_level->mouse_loc_x;
*y = top_level->mouse_loc_y; *y = top_level->mouse_loc_y;
@ -133,8 +130,7 @@ S9xPollPointer (uint32 id, int16 *x, int16 *y)
return true; return true;
} }
bool bool S9xIsMousePluggedIn ()
S9xIsMousePluggedIn (void)
{ {
enum controllers ctl; enum controllers ctl;
int8 id1, id2, id3, id4; int8 id1, id2, id3, id4;
@ -149,8 +145,7 @@ S9xIsMousePluggedIn (void)
return false; return false;
} }
bool bool S9xGrabJoysticks ()
S9xGrabJoysticks (void)
{ {
if (joystick_lock) if (joystick_lock)
return FALSE; return FALSE;
@ -160,16 +155,12 @@ S9xGrabJoysticks (void)
return TRUE; return TRUE;
} }
void void S9xReleaseJoysticks ()
S9xReleaseJoysticks (void)
{ {
joystick_lock--; joystick_lock--;
return;
} }
static void static void swap_controllers_1_2 ()
swap_controllers_1_2 (void)
{ {
JoypadBinding interrim; JoypadBinding interrim;
@ -178,12 +169,9 @@ swap_controllers_1_2 (void)
gui_config->pad[1] = interrim; gui_config->pad[1] = interrim;
gui_config->rebind_keys (); gui_config->rebind_keys ();
return;
} }
void void S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2)
S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2)
{ {
static bool quit_binding_down = FALSE; static bool quit_binding_down = FALSE;
@ -251,12 +239,9 @@ S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2)
S9xQuickLoadSlot (cmd.port[0] - PORT_QUICKLOAD0); S9xQuickLoadSlot (cmd.port[0] - PORT_QUICKLOAD0);
} }
} }
return;
} }
Binding Binding S9xGetBindingByName (const char *name)
S9xGetBindingByName (const char *name)
{ {
for (int i = 0; i < NUM_EMU_LINKS; i++) for (int i = 0; i < NUM_EMU_LINKS; i++)
{ {
@ -269,8 +254,7 @@ S9xGetBindingByName (const char *name)
return Binding (); return Binding ();
} }
s9xcommand_t s9xcommand_t S9xGetPortCommandT (const char *name)
S9xGetPortCommandT (const char *name)
{ {
s9xcommand_t cmd; s9xcommand_t cmd;
@ -380,8 +364,7 @@ S9xGetPortCommandT (const char *name)
return cmd; return cmd;
} }
void void S9xProcessEvents (bool8 block)
S9xProcessEvents (bool8 block)
{ {
#ifdef USE_JOYSTICK #ifdef USE_JOYSTICK
JoyEvent event; JoyEvent event;
@ -407,8 +390,7 @@ S9xProcessEvents (bool8 block)
} }
#ifdef USE_JOYSTICK #ifdef USE_JOYSTICK
static void static void poll_joystick_events ()
poll_joystick_events (void)
{ {
SDL_Event event; SDL_Event event;
@ -430,13 +412,10 @@ poll_joystick_events (void)
gui_config->joystick[event.jbutton.which]->handle_event (&event); gui_config->joystick[event.jbutton.which]->handle_event (&event);
} }
} }
return;
} }
#endif #endif
void void S9xInitInputDevices ()
S9xInitInputDevices (void)
{ {
#ifdef USE_JOYSTICK #ifdef USE_JOYSTICK
SDL_Init (SDL_INIT_JOYSTICK); SDL_Init (SDL_INIT_JOYSTICK);
@ -465,12 +444,9 @@ S9xInitInputDevices (void)
//First plug in both, they'll change later as needed //First plug in both, they'll change later as needed
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0); S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0); S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
return;
} }
void void S9xDeinitInputDevices ()
S9xDeinitInputDevices (void)
{ {
#ifdef USE_JOYSTICK #ifdef USE_JOYSTICK
for (int i = 0; gui_config->joystick[i] != NULL; i++) for (int i = 0; gui_config->joystick[i] != NULL; i++)
@ -482,11 +458,10 @@ S9xDeinitInputDevices (void)
SDL_Quit (); SDL_Quit ();
#endif #endif
return;
} }
#ifdef USE_JOYSTICK #ifdef USE_JOYSTICK
JoyDevice::JoyDevice (unsigned int device_num) JoyDevice::JoyDevice (unsigned int device_num)
{ {
enabled = false; enabled = false;
@ -529,7 +504,7 @@ JoyDevice::JoyDevice (unsigned int device_num)
return; return;
} }
JoyDevice::~JoyDevice (void) JoyDevice::~JoyDevice ()
{ {
if (enabled) if (enabled)
{ {
@ -540,22 +515,16 @@ JoyDevice::~JoyDevice (void)
} }
enabled = false; enabled = false;
return;
} }
void void JoyDevice::add_event (unsigned int parameter, unsigned int state)
JoyDevice::add_event (unsigned int parameter, unsigned int state)
{ {
JoyEvent event = { parameter, state }; JoyEvent event = { parameter, state };
queue.push (event); queue.push (event);
return;
} }
void void JoyDevice::register_centers ()
JoyDevice::register_centers (void)
{ {
for (int i = 0; i < num_axes; i++) for (int i = 0; i < num_axes; i++)
{ {
@ -573,12 +542,9 @@ JoyDevice::register_centers (void)
else else
calibration[i].center = 32767; calibration[i].center = 32767;
} }
return;
} }
void void JoyDevice::handle_event (SDL_Event *event)
JoyDevice::handle_event (SDL_Event *event)
{ {
if (event->type == SDL_JOYAXISMOTION) if (event->type == SDL_JOYAXISMOTION)
{ {
@ -733,12 +699,9 @@ JoyDevice::handle_event (SDL_Event *event)
hat[event->jhat.hat] = event->jhat.value; hat[event->jhat.hat] = event->jhat.value;
} }
return;
} }
int int JoyDevice::get_event (JoyEvent *event)
JoyDevice::get_event (JoyEvent *event)
{ {
poll_events (); poll_events ();
@ -753,16 +716,12 @@ JoyDevice::get_event (JoyEvent *event)
return 1; return 1;
} }
void void JoyDevice::poll_events ()
JoyDevice::poll_events (void)
{ {
poll_joystick_events (); poll_joystick_events ();
return;
} }
void void JoyDevice::flush ()
JoyDevice::flush (void)
{ {
SDL_Event event; SDL_Event event;
@ -772,7 +731,5 @@ JoyDevice::flush (void)
while (!queue.empty ()) while (!queue.empty ())
queue.pop (); queue.pop ();
return;
} }
#endif #endif

View File

@ -57,8 +57,8 @@ typedef struct JoypadBinding
#ifdef USE_JOYSTICK #ifdef USE_JOYSTICK
bool S9xGrabJoysticks (void); bool S9xGrabJoysticks ();
void S9xReleaseJoysticks (void); void S9xReleaseJoysticks ();
typedef struct JoyEvent typedef struct JoyEvent
{ {
@ -78,11 +78,11 @@ class JoyDevice
{ {
public: public:
JoyDevice (unsigned int device_num); JoyDevice (unsigned int device_num);
~JoyDevice (void); ~JoyDevice ();
int get_event (JoyEvent *event); int get_event (JoyEvent *event);
void flush (void); void flush ();
void handle_event (SDL_Event *event); void handle_event (SDL_Event *event);
void register_centers (void); void register_centers ();
SDL_Joystick *filedes; SDL_Joystick *filedes;
Calibration *calibration; Calibration *calibration;
@ -103,8 +103,8 @@ class JoyDevice
}; };
#endif #endif
void S9xDeinitInputDevices (void); void S9xDeinitInputDevices ();
Binding S9xGetBindingByName (const char *name); Binding S9xGetBindingByName (const char *name);
bool S9xIsMousePluggedIn (void); bool S9xIsMousePluggedIn ();
#endif /* __GTK_CONTROL_H*/ #endif /* __GTK_CONTROL_H*/