mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Remove platform-specific MAX_PADS - use global define MAX_PLAYERS
instead and customize it for certain ports
This commit is contained in:
parent
840361b76c
commit
fb1355b975
@ -39,10 +39,10 @@ typedef struct
|
|||||||
#define PRESSED_RIGHT(x, y) ((x >= dzone_max))
|
#define PRESSED_RIGHT(x, y) ((x >= dzone_max))
|
||||||
|
|
||||||
static unsigned pads_connected;
|
static unsigned pads_connected;
|
||||||
static int state_device_ids[MAX_PADS];
|
static int state_device_ids[MAX_PLAYERS];
|
||||||
static uint64_t state[MAX_PADS];
|
static uint64_t state[MAX_PLAYERS];
|
||||||
static uint64_t keycode_lut[LAST_KEYCODE];
|
static uint64_t keycode_lut[LAST_KEYCODE];
|
||||||
dpad_values_t dpad_state[MAX_PADS];
|
dpad_values_t dpad_state[MAX_PLAYERS];
|
||||||
|
|
||||||
|
|
||||||
struct input_pointer
|
struct input_pointer
|
||||||
@ -237,7 +237,7 @@ static void *android_input_init(void)
|
|||||||
|
|
||||||
if (!g_settings.input.autodetect_enable)
|
if (!g_settings.input.autodetect_enable)
|
||||||
{
|
{
|
||||||
for (j = 0; j < MAX_PADS; j++)
|
for (j = 0; j < MAX_PLAYERS; j++)
|
||||||
{
|
{
|
||||||
uint8_t shift = 8 + (j * 8);
|
uint8_t shift = 8 + (j * 8);
|
||||||
for (k = 0; k < RARCH_FIRST_CUSTOM_BIND; k++)
|
for (k = 0; k < RARCH_FIRST_CUSTOM_BIND; k++)
|
||||||
@ -251,7 +251,7 @@ static void *android_input_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < MAX_PADS; i++)
|
for(i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
for(j = 0; j < RARCH_FIRST_META_KEY; j++)
|
for(j = 0; j < RARCH_FIRST_META_KEY; j++)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,7 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned
|
|||||||
char name_buf[256];
|
char name_buf[256];
|
||||||
name_buf[0] = 0;
|
name_buf[0] = 0;
|
||||||
|
|
||||||
if (port > MAX_PADS)
|
if (port > MAX_PLAYERS)
|
||||||
{
|
{
|
||||||
snprintf(msg, sizeof_msg, "Max number of pads reached.\n");
|
snprintf(msg, sizeof_msg, "Max number of pads reached.\n");
|
||||||
return;
|
return;
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
#ifndef _ANDROID_INPUT_AUTODETECT_H
|
#ifndef _ANDROID_INPUT_AUTODETECT_H
|
||||||
#define _ANDROID_INPUT_AUTODETECT_H
|
#define _ANDROID_INPUT_AUTODETECT_H
|
||||||
|
|
||||||
#define MAX_PADS 8
|
|
||||||
|
|
||||||
#define AKEY_EVENT_NO_ACTION 255
|
#define AKEY_EVENT_NO_ACTION 255
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -99,7 +99,13 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_XBOX) || defined(GEKKO)
|
||||||
|
#define MAX_PLAYERS 4
|
||||||
|
#elif defined(PSP)
|
||||||
|
#define MAX_PLAYERS 1
|
||||||
|
#else
|
||||||
#define MAX_PLAYERS 8
|
#define MAX_PLAYERS 8
|
||||||
|
#endif
|
||||||
|
|
||||||
enum menu_enums
|
enum menu_enums
|
||||||
{
|
{
|
||||||
|
@ -36,9 +36,7 @@
|
|||||||
#define GC_JOYSTICK_THRESHOLD 48
|
#define GC_JOYSTICK_THRESHOLD 48
|
||||||
#define WII_JOYSTICK_THRESHOLD 40
|
#define WII_JOYSTICK_THRESHOLD 40
|
||||||
|
|
||||||
#define MAX_PADS 4
|
static uint64_t pad_state[MAX_PLAYERS];
|
||||||
|
|
||||||
static uint64_t pad_state[MAX_PADS];
|
|
||||||
|
|
||||||
const struct platform_bind platform_keys[] = {
|
const struct platform_bind platform_keys[] = {
|
||||||
{ GX_GC_A, "GC A button" },
|
{ GX_GC_A, "GC A button" },
|
||||||
@ -139,7 +137,7 @@ static int16_t gx_input_state(void *data, const struct retro_keybind **binds,
|
|||||||
(void)data;
|
(void)data;
|
||||||
(void)index;
|
(void)index;
|
||||||
|
|
||||||
if (port >= MAX_PADS || device != RETRO_DEVICE_JOYPAD)
|
if (port >= MAX_PLAYERS || device != RETRO_DEVICE_JOYPAD)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (binds[port][id].joykey & pad_state[port]) ? 1 : 0;
|
return (binds[port][id].joykey & pad_state[port]) ? 1 : 0;
|
||||||
@ -453,7 +451,7 @@ static void *gx_input_init(void)
|
|||||||
driver.input->set_keybinds(driver.input_data, 0, i, 0,
|
driver.input->set_keybinds(driver.input_data, 0, i, 0,
|
||||||
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
||||||
|
|
||||||
for(unsigned i = 0; i < MAX_PADS; i++)
|
for(unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
unsigned keybind_action = 0;
|
unsigned keybind_action = 0;
|
||||||
|
|
||||||
@ -497,7 +495,7 @@ static void gx_input_poll(void *data)
|
|||||||
WPAD_ReadPending(WPAD_CHAN_ALL, NULL);
|
WPAD_ReadPending(WPAD_CHAN_ALL, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (unsigned port = 0; port < MAX_PADS; port++)
|
for (unsigned port = 0; port < MAX_PLAYERS; port++)
|
||||||
{
|
{
|
||||||
uint32_t down = 0;
|
uint32_t down = 0;
|
||||||
uint64_t *state_cur = &pad_state[port];
|
uint64_t *state_cur = &pad_state[port];
|
||||||
|
@ -104,7 +104,7 @@ const struct platform_bind platform_keys[] = {
|
|||||||
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) | (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN), "RStick D-Pad Down" },
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) | (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN), "RStick D-Pad Down" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint64_t state[MAX_PADS];
|
static uint64_t state[MAX_PLAYERS];
|
||||||
static unsigned pads_connected;
|
static unsigned pads_connected;
|
||||||
#ifdef HAVE_MOUSE
|
#ifdef HAVE_MOUSE
|
||||||
static unsigned mice_connected;
|
static unsigned mice_connected;
|
||||||
@ -115,7 +115,7 @@ static void ps3_input_poll(void *data)
|
|||||||
CellPadInfo2 pad_info;
|
CellPadInfo2 pad_info;
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
for (unsigned i = 0; i < MAX_PADS; i++)
|
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
static CellPadData state_tmp;
|
static CellPadData state_tmp;
|
||||||
cellPadGetData(i, &state_tmp);
|
cellPadGetData(i, &state_tmp);
|
||||||
@ -508,7 +508,7 @@ static void ps3_input_set_keybinds(void *data, unsigned device,
|
|||||||
|
|
||||||
static void* ps3_input_init(void)
|
static void* ps3_input_init(void)
|
||||||
{
|
{
|
||||||
cellPadInit(MAX_PADS);
|
cellPadInit(MAX_PLAYERS);
|
||||||
#ifdef HAVE_MOUSE
|
#ifdef HAVE_MOUSE
|
||||||
cellMouseInit(MAX_MICE);
|
cellMouseInit(MAX_MICE);
|
||||||
#endif
|
#endif
|
||||||
@ -518,7 +518,7 @@ static void* ps3_input_init(void)
|
|||||||
driver.input->set_keybinds(driver.input_data, 0, i, 0,
|
driver.input->set_keybinds(driver.input_data, 0, i, 0,
|
||||||
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
||||||
|
|
||||||
for(unsigned i = 0; i < MAX_PADS; i++)
|
for(unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
unsigned keybind_action = 0;
|
unsigned keybind_action = 0;
|
||||||
|
|
||||||
|
@ -22,10 +22,6 @@
|
|||||||
|
|
||||||
#include "sdk_defines.h"
|
#include "sdk_defines.h"
|
||||||
|
|
||||||
#ifndef __PSL1GHT__
|
|
||||||
#define MAX_PADS 7
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEADZONE_LOW 55
|
#define DEADZONE_LOW 55
|
||||||
#define DEADZONE_HIGH 210
|
#define DEADZONE_HIGH 210
|
||||||
|
|
||||||
|
@ -35,8 +35,6 @@
|
|||||||
#define ANALOGSTICK_DEADZONE_LOW (0x40)
|
#define ANALOGSTICK_DEADZONE_LOW (0x40)
|
||||||
#define ANALOGSTICK_DEADZONE_HIGH (0xc0)
|
#define ANALOGSTICK_DEADZONE_HIGH (0xc0)
|
||||||
|
|
||||||
#define MAX_PADS 1
|
|
||||||
|
|
||||||
const struct platform_bind platform_keys[] = {
|
const struct platform_bind platform_keys[] = {
|
||||||
{ PSP_GAMEPAD_CIRCLE, "Circle button" },
|
{ PSP_GAMEPAD_CIRCLE, "Circle button" },
|
||||||
{ PSP_GAMEPAD_CROSS, "Cross button" },
|
{ PSP_GAMEPAD_CROSS, "Cross button" },
|
||||||
@ -174,7 +172,7 @@ static void* psp_input_initialize(void)
|
|||||||
driver.input->set_keybinds(driver.input_data, 0, i, 0,
|
driver.input->set_keybinds(driver.input_data, 0, i, 0,
|
||||||
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
||||||
|
|
||||||
for(unsigned i = 0; i < MAX_PADS; i++)
|
for(unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
unsigned keybind_action = 0;
|
unsigned keybind_action = 0;
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include <xtl.h>
|
#include <xtl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_PADS 4
|
|
||||||
#define DEADZONE (16000)
|
#define DEADZONE (16000)
|
||||||
|
|
||||||
#include "../driver.h"
|
#include "../driver.h"
|
||||||
@ -29,14 +28,14 @@
|
|||||||
#include "../libretro.h"
|
#include "../libretro.h"
|
||||||
|
|
||||||
|
|
||||||
static uint64_t state[MAX_PADS];
|
static uint64_t state[MAX_PLAYERS];
|
||||||
unsigned pads_connected;
|
unsigned pads_connected;
|
||||||
|
|
||||||
#ifdef _XBOX1
|
#ifdef _XBOX1
|
||||||
static HANDLE gamepads[MAX_PADS];
|
static HANDLE gamepads[MAX_PLAYERS];
|
||||||
static DWORD dwDeviceMask;
|
static DWORD dwDeviceMask;
|
||||||
static bool bInserted[MAX_PADS];
|
static bool bInserted[MAX_PLAYERS];
|
||||||
static bool bRemoved[MAX_PADS];
|
static bool bRemoved[MAX_PLAYERS];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const struct platform_bind platform_keys[] = {
|
const struct platform_bind platform_keys[] = {
|
||||||
@ -89,9 +88,9 @@ static void xdk_input_poll(void *data)
|
|||||||
|
|
||||||
XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD, reinterpret_cast<PDWORD>(&dwInsertions), reinterpret_cast<PDWORD>(&dwRemovals));
|
XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD, reinterpret_cast<PDWORD>(&dwInsertions), reinterpret_cast<PDWORD>(&dwRemovals));
|
||||||
|
|
||||||
for (unsigned i = 0; i < MAX_PADS; i++)
|
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
XINPUT_CAPABILITIES caps[MAX_PADS];
|
XINPUT_CAPABILITIES caps[MAX_PLAYERS];
|
||||||
(void)caps;
|
(void)caps;
|
||||||
// handle removed devices
|
// handle removed devices
|
||||||
bRemoved[i] = (dwRemovals & (1<<i)) ? true : false;
|
bRemoved[i] = (dwRemovals & (1<<i)) ? true : false;
|
||||||
@ -168,7 +167,7 @@ static void xdk_input_poll(void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(_XBOX360)
|
#elif defined(_XBOX360)
|
||||||
for (unsigned i = 0; i < MAX_PADS; i++)
|
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
XINPUT_STATE state_tmp;
|
XINPUT_STATE state_tmp;
|
||||||
pads_connected += (XInputGetState(i, &state_tmp) == ERROR_DEVICE_NOT_CONNECTED) ? 0 : 1;
|
pads_connected += (XInputGetState(i, &state_tmp) == ERROR_DEVICE_NOT_CONNECTED) ? 0 : 1;
|
||||||
@ -405,7 +404,7 @@ static void *xdk_input_init(void)
|
|||||||
driver.input->set_keybinds(driver.input_data, 0, i, 0,
|
driver.input->set_keybinds(driver.input_data, 0, i, 0,
|
||||||
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
||||||
|
|
||||||
for(unsigned i = 0; i < MAX_PADS; i++)
|
for(unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
unsigned keybind_action = 0;
|
unsigned keybind_action = 0;
|
||||||
|
|
||||||
|
@ -24,14 +24,12 @@
|
|||||||
#include <input/input.h>
|
#include <input/input.h>
|
||||||
#include <usb/usbmain.h>
|
#include <usb/usbmain.h>
|
||||||
|
|
||||||
#define MAX_PADS 4
|
static uint64_t state[MAX_PLAYERS];
|
||||||
|
|
||||||
static uint64_t state[MAX_PADS];
|
|
||||||
|
|
||||||
static void xenon360_input_poll(void *data)
|
static void xenon360_input_poll(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
for (unsigned i = 0; i < MAX_PADS; i++)
|
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
struct controller_data_s pad;
|
struct controller_data_s pad;
|
||||||
usb_do_poll();
|
usb_do_poll();
|
||||||
@ -64,7 +62,7 @@ static int16_t xenon360_input_state(void *data, const struct retro_keybind **bin
|
|||||||
uint64_t button = binds[player][id].joykey;
|
uint64_t button = binds[player][id].joykey;
|
||||||
int16_t retval = 0;
|
int16_t retval = 0;
|
||||||
|
|
||||||
if(player < MAX_PADS)
|
if(player < MAX_PLAYERS)
|
||||||
{
|
{
|
||||||
switch (device)
|
switch (device)
|
||||||
{
|
{
|
||||||
@ -106,7 +104,7 @@ static void* xenon360_input_init(void)
|
|||||||
xenon360_input_set_keybinds(driver.input_data, 0, i,
|
xenon360_input_set_keybinds(driver.input_data, 0, i,
|
||||||
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
||||||
|
|
||||||
for(unsigned i = 0; i < MAX_PADS; i++)
|
for(unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
unsigned keybind_action = 0;
|
unsigned keybind_action = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user