(Drivers joypad) Cleanups

This commit is contained in:
twinaphex 2019-07-16 14:39:31 +02:00
parent bf80376d27
commit f1ea1f1845
2 changed files with 8 additions and 14 deletions

View File

@ -49,7 +49,7 @@ static EM_BOOL rwebpad_gamepad_cb(int event_type,
if (event_type == EMSCRIPTEN_EVENT_GAMEPADCONNECTED) if (event_type == EMSCRIPTEN_EVENT_GAMEPADCONNECTED)
{ {
if(!input_autoconfigure_connect( if (!input_autoconfigure_connect(
gamepad_event->id, /* name */ gamepad_event->id, /* name */
NULL, /* display name */ NULL, /* display name */
rwebpad_joypad.ident, /* driver */ rwebpad_joypad.ident, /* driver */
@ -105,22 +105,18 @@ static bool rwebpad_joypad_init(void *data)
static const char *rwebpad_joypad_name(unsigned pad) static const char *rwebpad_joypad_name(unsigned pad)
{ {
static EmscriptenGamepadEvent gamepad_state; static EmscriptenGamepadEvent gamepad_state;
EMSCRIPTEN_RESULT r; EMSCRIPTEN_RESULT r = emscripten_get_gamepad_status(pad, &gamepad_state);
r = emscripten_get_gamepad_status(pad, &gamepad_state);
if (r == EMSCRIPTEN_RESULT_SUCCESS) if (r == EMSCRIPTEN_RESULT_SUCCESS)
return gamepad_state.id; return gamepad_state.id;
else return "";
return "";
} }
static bool rwebpad_joypad_button(unsigned port_num, uint16_t joykey) static bool rwebpad_joypad_button(unsigned port_num, uint16_t joykey)
{ {
EmscriptenGamepadEvent gamepad_state; EmscriptenGamepadEvent gamepad_state;
EMSCRIPTEN_RESULT r; EMSCRIPTEN_RESULT r = emscripten_get_gamepad_status(
port_num, &gamepad_state);
r = emscripten_get_gamepad_status(port_num, &gamepad_state);
if (r == EMSCRIPTEN_RESULT_SUCCESS) if (r == EMSCRIPTEN_RESULT_SUCCESS)
if (joykey < gamepad_state.numButtons) if (joykey < gamepad_state.numButtons)
@ -137,7 +133,7 @@ static void rwebpad_joypad_get_buttons(unsigned port_num, input_bits_t *state)
if (r == EMSCRIPTEN_RESULT_SUCCESS) if (r == EMSCRIPTEN_RESULT_SUCCESS)
{ {
int i; unsigned i;
for (i = 0; i < gamepad_state.numButtons; i++) for (i = 0; i < gamepad_state.numButtons; i++)
{ {
@ -188,9 +184,7 @@ static void rwebpad_joypad_poll(void)
static bool rwebpad_joypad_query_pad(unsigned pad) static bool rwebpad_joypad_query_pad(unsigned pad)
{ {
EmscriptenGamepadEvent gamepad_state; EmscriptenGamepadEvent gamepad_state;
EMSCRIPTEN_RESULT r; EMSCRIPTEN_RESULT r = emscripten_get_gamepad_status(pad, &gamepad_state);
r = emscripten_get_gamepad_status(pad, &gamepad_state);
if (r == EMSCRIPTEN_RESULT_SUCCESS) if (r == EMSCRIPTEN_RESULT_SUCCESS)
return gamepad_state.connected == EM_TRUE; return gamepad_state.connected == EM_TRUE;

View File

@ -105,7 +105,7 @@ static void sdl_pad_connect(unsigned id)
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
SDL_JoystickGUID guid; SDL_JoystickGUID guid;
uint16_t *guid_ptr; uint16_t *guid_ptr = NULL;
if (SDL_IsGameController(id)) if (SDL_IsGameController(id))
{ {