mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
(drivers_joypad) Cleanups
This commit is contained in:
parent
4205b3e8f3
commit
494a190c5b
@ -25,7 +25,7 @@ static const char *android_joypad_name(unsigned pad)
|
|||||||
static bool android_joypad_init(void)
|
static bool android_joypad_init(void)
|
||||||
{
|
{
|
||||||
unsigned autoconf_pad;
|
unsigned autoconf_pad;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
autoconfig_params_t params = {{0}};
|
autoconfig_params_t params = {{0}};
|
||||||
|
|
||||||
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
||||||
|
@ -15,9 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../input_autodetect.h"
|
#include "../input_autodetect.h"
|
||||||
#include "../input_common.h"
|
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include "../../runloop.h"
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -46,7 +44,7 @@ static int g_notify;
|
|||||||
static int g_epoll;
|
static int g_epoll;
|
||||||
static bool g_hotplug;
|
static bool g_hotplug;
|
||||||
|
|
||||||
static void poll_pad(struct linuxraw_joypad *pad)
|
static void linuxraw_poll_pad(struct linuxraw_joypad *pad)
|
||||||
{
|
{
|
||||||
struct js_event event;
|
struct js_event event;
|
||||||
|
|
||||||
@ -122,7 +120,7 @@ static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p
|
|||||||
static void handle_plugged_pad(void)
|
static void handle_plugged_pad(void)
|
||||||
{
|
{
|
||||||
int i, rc;
|
int i, rc;
|
||||||
size_t event_size = sizeof(struct inotify_event) + NAME_MAX + 1;
|
size_t event_size = sizeof(struct inotify_event) + NAME_MAX + 1;
|
||||||
uint8_t *event_buf = (uint8_t*)calloc(1, event_size);
|
uint8_t *event_buf = (uint8_t*)calloc(1, event_size);
|
||||||
|
|
||||||
if (!event_buf)
|
if (!event_buf)
|
||||||
@ -211,7 +209,7 @@ retry:
|
|||||||
for (i = 0; i < ret; i++)
|
for (i = 0; i < ret; i++)
|
||||||
{
|
{
|
||||||
if (events[i].data.ptr)
|
if (events[i].data.ptr)
|
||||||
poll_pad((struct linuxraw_joypad*)events[i].data.ptr);
|
linuxraw_poll_pad((struct linuxraw_joypad*)events[i].data.ptr);
|
||||||
else
|
else
|
||||||
handle_plugged_pad();
|
handle_plugged_pad();
|
||||||
}
|
}
|
||||||
@ -228,7 +226,7 @@ static bool linuxraw_joypad_init(void)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
g_epoll = epoll_create(MAX_USERS + 1);
|
g_epoll = epoll_create(MAX_USERS + 1);
|
||||||
if (g_epoll < 0)
|
if (g_epoll < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -255,7 +253,7 @@ static bool linuxraw_joypad_init(void)
|
|||||||
|
|
||||||
/* TODO - implement VID/PID? */
|
/* TODO - implement VID/PID? */
|
||||||
input_config_autoconfigure_joypad(¶ms);
|
input_config_autoconfigure_joypad(¶ms);
|
||||||
poll_pad(pad);
|
linuxraw_poll_pad(pad);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
input_config_autoconfigure_joypad(¶ms);
|
input_config_autoconfigure_joypad(¶ms);
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../input_autodetect.h"
|
#include "../input_autodetect.h"
|
||||||
#include "../input_common.h"
|
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -109,11 +108,11 @@ static void parport_poll_pad(struct parport_joypad *pad)
|
|||||||
static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad)
|
static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int datadir = 1; /* read */
|
|
||||||
char data;
|
char data;
|
||||||
struct ppdev_frob_struct frob;
|
struct ppdev_frob_struct frob;
|
||||||
bool set_control = false;
|
int datadir = 1; /* read */
|
||||||
int mode = IEEE1284_MODE_BYTE;
|
bool set_control = false;
|
||||||
|
int mode = IEEE1284_MODE_BYTE;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
if (pad->fd >= 0)
|
if (pad->fd >= 0)
|
||||||
@ -122,9 +121,9 @@ static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad
|
|||||||
if (access(path, R_OK | W_OK) < 0)
|
if (access(path, R_OK | W_OK) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pad->fd = open(path, O_RDWR | O_NONBLOCK);
|
pad->fd = open(path, O_RDWR | O_NONBLOCK);
|
||||||
|
|
||||||
*pad->ident = '\0';
|
*pad->ident = '\0';
|
||||||
|
|
||||||
if (pad->fd >= 0)
|
if (pad->fd >= 0)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[Joypad]: Found parallel port: %s\n", path);
|
RARCH_LOG("[Joypad]: Found parallel port: %s\n", path);
|
||||||
@ -208,8 +207,8 @@ static void parport_joypad_poll(void)
|
|||||||
|
|
||||||
static void destroy_pad(struct parport_joypad *pad)
|
static void destroy_pad(struct parport_joypad *pad)
|
||||||
{
|
{
|
||||||
char data;
|
char data = pad->saved_data;
|
||||||
data = pad->saved_data;
|
|
||||||
if (ioctl(pad->fd, PPWDATA, &data) < 0)
|
if (ioctl(pad->fd, PPWDATA, &data) < 0)
|
||||||
RARCH_ERR("[Joypad]: Failed to restore original data register on %s\n", pad->ident);
|
RARCH_ERR("[Joypad]: Failed to restore original data register on %s\n", pad->ident);
|
||||||
|
|
||||||
@ -231,7 +230,7 @@ static bool parport_joypad_init(void)
|
|||||||
bool found_disabled_button;
|
bool found_disabled_button;
|
||||||
char buf[PARPORT_NUM_BUTTONS * 3 + 1];
|
char buf[PARPORT_NUM_BUTTONS * 3 + 1];
|
||||||
char pin[3 + 1];
|
char pin[3 + 1];
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
autoconfig_params_t params = {{0}};
|
autoconfig_params_t params = {{0}};
|
||||||
|
|
||||||
memset(buf, 0, PARPORT_NUM_BUTTONS * 3 + 1);
|
memset(buf, 0, PARPORT_NUM_BUTTONS * 3 + 1);
|
||||||
|
@ -35,7 +35,7 @@ static INLINE int16_t convert_u8_to_s16(uint8_t val)
|
|||||||
static const char *ps3_joypad_name(unsigned pad)
|
static const char *ps3_joypad_name(unsigned pad)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
return settings->input.device_names[pad];
|
return settings ? settings->input.device_names[pad] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ps3_joypad_init(void)
|
static bool ps3_joypad_init(void)
|
||||||
@ -77,8 +77,10 @@ static uint64_t ps3_joypad_get_buttons(unsigned port_num)
|
|||||||
|
|
||||||
static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||||
{
|
{
|
||||||
int val = 0, axis = -1;
|
int val = 0;
|
||||||
bool is_neg = false, is_pos = false;
|
int axis = -1;
|
||||||
|
bool is_neg = false;
|
||||||
|
bool is_pos = false;
|
||||||
|
|
||||||
if (joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
if (joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../input_autodetect.h"
|
#include "../input_autodetect.h"
|
||||||
#include "../input_common.h"
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ typedef struct _sdl_joypad
|
|||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
SDL_GameController *controller;
|
SDL_GameController *controller;
|
||||||
SDL_Haptic *haptic;
|
SDL_Haptic *haptic;
|
||||||
int rumble_effect; // -1 = not initialized, -2 = error/unsupported
|
int rumble_effect; /* -1 = not initialized, -2 = error/unsupported */
|
||||||
#endif
|
#endif
|
||||||
unsigned num_axes;
|
unsigned num_axes;
|
||||||
unsigned num_buttons;
|
unsigned num_buttons;
|
||||||
@ -46,7 +45,7 @@ static sdl_joypad_t sdl_pads[MAX_USERS];
|
|||||||
static bool g_has_haptic;
|
static bool g_has_haptic;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char* pad_name(unsigned id)
|
static const char* sdl_pad_name(unsigned id)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
if (sdl_pads[id].controller)
|
if (sdl_pads[id].controller)
|
||||||
@ -57,7 +56,7 @@ static const char* pad_name(unsigned id)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t pad_get_button(sdl_joypad_t *pad, unsigned button)
|
static uint8_t sdl_pad_get_button(sdl_joypad_t *pad, unsigned button)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
/* TODO: see if a LUT like winxinput_joypad.c's button_index_to_bitmap_code is needed. */
|
/* TODO: see if a LUT like winxinput_joypad.c's button_index_to_bitmap_code is needed. */
|
||||||
@ -67,16 +66,16 @@ static uint8_t pad_get_button(sdl_joypad_t *pad, unsigned button)
|
|||||||
return SDL_JoystickGetButton(pad->joypad, button);
|
return SDL_JoystickGetButton(pad->joypad, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t pad_get_hat(sdl_joypad_t *pad, unsigned hat)
|
static uint8_t sdl_pad_get_hat(sdl_joypad_t *pad, unsigned hat)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
if (pad->controller)
|
if (pad->controller)
|
||||||
return pad_get_button(pad, hat);
|
return sdl_pad_get_button(pad, hat);
|
||||||
#endif
|
#endif
|
||||||
return SDL_JoystickGetHat(pad->joypad, hat);
|
return SDL_JoystickGetHat(pad->joypad, hat);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t pad_get_axis(sdl_joypad_t *pad, unsigned axis)
|
static int16_t sdl_pad_get_axis(sdl_joypad_t *pad, unsigned axis)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
/* TODO: see if a rarch <-> sdl translation is needed. */
|
/* TODO: see if a rarch <-> sdl translation is needed. */
|
||||||
@ -86,13 +85,13 @@ static int16_t pad_get_axis(sdl_joypad_t *pad, unsigned axis)
|
|||||||
return SDL_JoystickGetAxis(pad->joypad, axis);
|
return SDL_JoystickGetAxis(pad->joypad, axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pad_connect(unsigned id)
|
static void sdl_pad_connect(unsigned id)
|
||||||
{
|
{
|
||||||
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[id];
|
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[id];
|
||||||
bool success = false;
|
bool success = false;
|
||||||
int32_t product = 0;
|
int32_t product = 0;
|
||||||
int32_t vendor = 0;
|
int32_t vendor = 0;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
autoconfig_params_t params = {{0}};
|
autoconfig_params_t params = {{0}};
|
||||||
|
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
@ -125,21 +124,21 @@ static void pad_connect(unsigned id)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strlcpy(settings->input.device_names[id], pad_name(id), sizeof(settings->input.device_names[id]));
|
strlcpy(settings->input.device_names[id], sdl_pad_name(id), sizeof(settings->input.device_names[id]));
|
||||||
|
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
guid = SDL_JoystickGetGUID(pad->joypad);
|
guid = SDL_JoystickGetGUID(pad->joypad);
|
||||||
guid_ptr = (uint16_t*)guid.data;
|
guid_ptr = (uint16_t*)guid.data;
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
vendor = guid_ptr[2];
|
vendor = guid_ptr[2];
|
||||||
product = guid_ptr[4];
|
product = guid_ptr[4];
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
vendor = guid_ptr[0];
|
vendor = guid_ptr[0];
|
||||||
product = guid_ptr[1];
|
product = guid_ptr[1];
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
params.idx = id;
|
params.idx = id;
|
||||||
strlcpy(params.name, pad_name(id), sizeof(params.name));
|
strlcpy(params.name, sdl_pad_name(id), sizeof(params.name));
|
||||||
params.vid = vendor;
|
params.vid = vendor;
|
||||||
params.pid = product;
|
params.pid = product;
|
||||||
strlcpy(params.driver, sdl_joypad.ident, sizeof(params.driver));
|
strlcpy(params.driver, sdl_joypad.ident, sizeof(params.driver));
|
||||||
@ -147,7 +146,7 @@ static void pad_connect(unsigned id)
|
|||||||
input_config_autoconfigure_joypad(¶ms);
|
input_config_autoconfigure_joypad(¶ms);
|
||||||
|
|
||||||
RARCH_LOG("[SDL]: Joypad #%u (%04x:%04x) connected: %s.\n", id, vendor,
|
RARCH_LOG("[SDL]: Joypad #%u (%04x:%04x) connected: %s.\n", id, vendor,
|
||||||
product, pad_name(id));
|
product, sdl_pad_name(id));
|
||||||
|
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
|
|
||||||
@ -193,7 +192,7 @@ static void pad_connect(unsigned id)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pad_disconnect(unsigned id)
|
static void sdl_pad_disconnect(unsigned id)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
@ -222,7 +221,7 @@ static void sdl_joypad_destroy(void)
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < MAX_USERS; i++)
|
for (i = 0; i < MAX_USERS; i++)
|
||||||
pad_disconnect(i);
|
sdl_pad_disconnect(i);
|
||||||
|
|
||||||
SDL_QuitSubSystem(g_subsystem);
|
SDL_QuitSubSystem(g_subsystem);
|
||||||
memset(sdl_pads, 0, sizeof(sdl_pads));
|
memset(sdl_pads, 0, sizeof(sdl_pads));
|
||||||
@ -230,7 +229,7 @@ static void sdl_joypad_destroy(void)
|
|||||||
|
|
||||||
static bool sdl_joypad_init(void)
|
static bool sdl_joypad_init(void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i, num_sticks;
|
||||||
|
|
||||||
if (SDL_WasInit(0) == 0)
|
if (SDL_WasInit(0) == 0)
|
||||||
{
|
{
|
||||||
@ -251,12 +250,12 @@ static bool sdl_joypad_init(void)
|
|||||||
|
|
||||||
memset(sdl_pads, 0, sizeof(sdl_pads));
|
memset(sdl_pads, 0, sizeof(sdl_pads));
|
||||||
|
|
||||||
unsigned num_sticks = SDL_NumJoysticks();
|
num_sticks = SDL_NumJoysticks();
|
||||||
if (num_sticks > MAX_USERS)
|
if (num_sticks > MAX_USERS)
|
||||||
num_sticks = MAX_USERS;
|
num_sticks = MAX_USERS;
|
||||||
|
|
||||||
for (i = 0; i < num_sticks; i++)
|
for (i = 0; i < num_sticks; i++)
|
||||||
pad_connect(i);
|
sdl_pad_connect(i);
|
||||||
|
|
||||||
#ifndef HAVE_SDL2
|
#ifndef HAVE_SDL2
|
||||||
/* quit if no joypad is detected. */
|
/* quit if no joypad is detected. */
|
||||||
@ -280,21 +279,24 @@ error:
|
|||||||
|
|
||||||
static bool sdl_joypad_button(unsigned port, uint16_t joykey)
|
static bool sdl_joypad_button(unsigned port, uint16_t joykey)
|
||||||
{
|
{
|
||||||
|
sdl_joypad_t *pad = NULL;
|
||||||
if (joykey == NO_BTN)
|
if (joykey == NO_BTN)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[port];
|
pad = (sdl_joypad_t*)&sdl_pads[port];
|
||||||
if (!pad->joypad)
|
if (!pad->joypad)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check hat.
|
/* Check hat. */
|
||||||
if (GET_HAT_DIR(joykey))
|
if (GET_HAT_DIR(joykey))
|
||||||
{
|
{
|
||||||
|
uint8_t dir;
|
||||||
uint16_t hat = GET_HAT(joykey);
|
uint16_t hat = GET_HAT(joykey);
|
||||||
if (hat >= pad->num_hats)
|
if (hat >= pad->num_hats)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Uint8 dir = pad_get_hat(pad, hat);
|
dir = sdl_pad_get_hat(pad, hat);
|
||||||
|
|
||||||
switch (GET_HAT_DIR(joykey))
|
switch (GET_HAT_DIR(joykey))
|
||||||
{
|
{
|
||||||
case HAT_UP_MASK:
|
case HAT_UP_MASK:
|
||||||
@ -311,8 +313,8 @@ static bool sdl_joypad_button(unsigned port, uint16_t joykey)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the button
|
/* Check the button */
|
||||||
if (joykey < pad->num_buttons && pad_get_button(pad, joykey))
|
if (joykey < pad->num_buttons && sdl_pad_get_button(pad, joykey))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -330,16 +332,16 @@ static int16_t sdl_joypad_axis(unsigned port, uint32_t joyaxis)
|
|||||||
int16_t val = 0;
|
int16_t val = 0;
|
||||||
if (AXIS_NEG_GET(joyaxis) < pad->num_axes)
|
if (AXIS_NEG_GET(joyaxis) < pad->num_axes)
|
||||||
{
|
{
|
||||||
val = pad_get_axis(pad, AXIS_NEG_GET(joyaxis));
|
val = sdl_pad_get_axis(pad, AXIS_NEG_GET(joyaxis));
|
||||||
|
|
||||||
if (val > 0)
|
if (val > 0)
|
||||||
val = 0;
|
val = 0;
|
||||||
else if (val < -0x7fff) // -0x8000 can cause trouble if we later abs() it.
|
else if (val < -0x7fff) /* -0x8000 can cause trouble if we later abs() it. */
|
||||||
val = -0x7fff;
|
val = -0x7fff;
|
||||||
}
|
}
|
||||||
else if (AXIS_POS_GET(joyaxis) < pad->num_axes)
|
else if (AXIS_POS_GET(joyaxis) < pad->num_axes)
|
||||||
{
|
{
|
||||||
val = pad_get_axis(pad, AXIS_POS_GET(joyaxis));
|
val = sdl_pad_get_axis(pad, AXIS_POS_GET(joyaxis));
|
||||||
|
|
||||||
if (val < 0)
|
if (val < 0)
|
||||||
val = 0;
|
val = 0;
|
||||||
@ -354,15 +356,18 @@ static void sdl_joypad_poll(void)
|
|||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED) > 0)
|
|
||||||
|
while (SDL_PeepEvents(&event, 1,
|
||||||
|
SDL_GETEVENT, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED) > 0)
|
||||||
{
|
{
|
||||||
if (event.type == SDL_JOYDEVICEADDED)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
pad_connect(event.jdevice.which);
|
case SDL_JOYDEVICEADDED:
|
||||||
}
|
sdl_pad_connect(event.jdevice.which);
|
||||||
else if (event.type == SDL_JOYDEVICEREMOVED)
|
break;
|
||||||
{
|
case SDL_JOYDEVICEREMOVED:
|
||||||
pad_disconnect(event.jdevice.which);
|
sdl_pad_disconnect(event.jdevice.which);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -381,15 +386,20 @@ static bool sdl_joypad_set_rumble(unsigned pad, enum retro_rumble_effect effect,
|
|||||||
if (!joypad->joypad || !joypad->haptic)
|
if (!joypad->joypad || !joypad->haptic)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
efx.type = SDL_HAPTIC_LEFTRIGHT;
|
efx.type = SDL_HAPTIC_LEFTRIGHT;
|
||||||
efx.leftright.type = SDL_HAPTIC_LEFTRIGHT;
|
efx.leftright.type = SDL_HAPTIC_LEFTRIGHT;
|
||||||
efx.leftright.length = 5000;
|
efx.leftright.length = 5000;
|
||||||
|
|
||||||
switch (effect)
|
switch (effect)
|
||||||
{
|
{
|
||||||
case RETRO_RUMBLE_STRONG: efx.leftright.large_magnitude = strength; break;
|
case RETRO_RUMBLE_STRONG:
|
||||||
case RETRO_RUMBLE_WEAK: efx.leftright.small_magnitude = strength; break;
|
efx.leftright.large_magnitude = strength;
|
||||||
default: return false;
|
break;
|
||||||
|
case RETRO_RUMBLE_WEAK:
|
||||||
|
efx.leftright.small_magnitude = strength;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (joypad->rumble_effect == -1)
|
if (joypad->rumble_effect == -1)
|
||||||
@ -430,7 +440,7 @@ static const char *sdl_joypad_name(unsigned pad)
|
|||||||
if (pad >= MAX_USERS)
|
if (pad >= MAX_USERS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return pad_name(pad);
|
return sdl_pad_name(pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
rarch_joypad_driver_t sdl_joypad = {
|
rarch_joypad_driver_t sdl_joypad = {
|
||||||
|
@ -14,9 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../input_autodetect.h"
|
#include "../input_autodetect.h"
|
||||||
#include "../input_common.h"
|
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include "../../runloop.h"
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -36,7 +36,7 @@ static const char* const XBOX_CONTROLLER_NAMES[4] =
|
|||||||
static const char *xdk_joypad_name(unsigned pad)
|
static const char *xdk_joypad_name(unsigned pad)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
return settings->input.device_names[pad];
|
return settings ? settings->input.device_names[pad] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool xdk_joypad_init(void)
|
static bool xdk_joypad_init(void)
|
||||||
@ -95,8 +95,11 @@ static uint64_t xdk_joypad_get_buttons(unsigned port_num)
|
|||||||
|
|
||||||
static int16_t xdk_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
static int16_t xdk_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||||
{
|
{
|
||||||
int val = 0, axis = -1;
|
int val = 0;
|
||||||
bool is_neg = false, is_pos = false;
|
int axis = -1;
|
||||||
|
bool is_neg = false;
|
||||||
|
bool is_pos = false;
|
||||||
|
|
||||||
if (joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
if (joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -139,12 +142,14 @@ static int16_t xdk_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
|||||||
static void xdk_joypad_poll(void)
|
static void xdk_joypad_poll(void)
|
||||||
{
|
{
|
||||||
unsigned port;
|
unsigned port;
|
||||||
uint64_t *state_p1 = NULL;
|
#ifdef _XBOX1
|
||||||
uint64_t *lifecycle_state = NULL;
|
|
||||||
global_t *global = global_get_ptr();
|
|
||||||
#if defined(_XBOX1)
|
|
||||||
unsigned int dwInsertions, dwRemovals;
|
unsigned int dwInsertions, dwRemovals;
|
||||||
|
#endif
|
||||||
|
uint64_t *state_p1 = NULL;
|
||||||
|
uint64_t *lifecycle_state = NULL;
|
||||||
|
global_t *global = global_get_ptr();
|
||||||
|
|
||||||
|
#if defined(_XBOX1)
|
||||||
XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD,
|
XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD,
|
||||||
reinterpret_cast<PDWORD>(&dwInsertions),
|
reinterpret_cast<PDWORD>(&dwInsertions),
|
||||||
reinterpret_cast<PDWORD>(&dwRemovals));
|
reinterpret_cast<PDWORD>(&dwRemovals));
|
||||||
|
@ -13,13 +13,14 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Support 360 controllers on Windows.
|
/* Support 360 controllers on Windows.
|
||||||
// Said controllers do show under DInput but they have limitations in this mode;
|
* Said controllers do show under DInput but they have limitations in this mode;
|
||||||
// The triggers are combined rather than seperate and it is not possible to use
|
* The triggers are combined rather than seperate and it is not possible to use
|
||||||
// the guide button.
|
* the guide button.
|
||||||
|
*
|
||||||
// Some wrappers for other controllers also simulate xinput (as it is easier to implement)
|
* Some wrappers for other controllers also simulate xinput (as it is easier to implement)
|
||||||
// so this may be useful for those also.
|
* so this may be useful for those also.
|
||||||
|
**/
|
||||||
#include "../input_autodetect.h"
|
#include "../input_autodetect.h"
|
||||||
#include "../input_common.h"
|
#include "../input_common.h"
|
||||||
|
|
||||||
@ -274,6 +275,7 @@ static bool winxinput_joypad_query_pad(unsigned pad)
|
|||||||
static void winxinput_joypad_destroy(void)
|
static void winxinput_joypad_destroy(void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
memset(&g_winxinput_states[i], 0, sizeof(winxinput_joypad_state));
|
memset(&g_winxinput_states[i], 0, sizeof(winxinput_joypad_state));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user