Skip to content

Commit

Permalink
Revert "Remove platform-specific MAX_PADS - use global define MAX_PLA…
Browse files Browse the repository at this point in the history
…YERS"

This reverts commit fb1355b.
  • Loading branch information
twinaphex committed Mar 16, 2013
1 parent f028a85 commit ad2cd4e
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 33 deletions.
10 changes: 5 additions & 5 deletions android/native/jni/input_android.c
Expand Up @@ -39,10 +39,10 @@ typedef struct
#define PRESSED_RIGHT(x, y) ((x >= dzone_max))

static unsigned pads_connected;
static int state_device_ids[MAX_PLAYERS];
static uint64_t state[MAX_PLAYERS];
static int state_device_ids[MAX_PADS];
static uint64_t state[MAX_PADS];
static uint64_t keycode_lut[LAST_KEYCODE];
dpad_values_t dpad_state[MAX_PLAYERS];
dpad_values_t dpad_state[MAX_PADS];


struct input_pointer
Expand Down Expand Up @@ -237,7 +237,7 @@ static void *android_input_init(void)

if (!g_settings.input.autodetect_enable)
{
for (j = 0; j < MAX_PLAYERS; j++)
for (j = 0; j < MAX_PADS; j++)
{
uint8_t shift = 8 + (j * 8);
for (k = 0; k < RARCH_FIRST_CUSTOM_BIND; k++)
Expand All @@ -251,7 +251,7 @@ static void *android_input_init(void)
}
}

for(i = 0; i < MAX_PLAYERS; i++)
for(i = 0; i < MAX_PADS; i++)
{
for(j = 0; j < RARCH_FIRST_META_KEY; j++)
{
Expand Down
2 changes: 1 addition & 1 deletion android/native/jni/input_autodetect.c
Expand Up @@ -75,7 +75,7 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned
char name_buf[256];
name_buf[0] = 0;

if (port > MAX_PLAYERS)
if (port > MAX_PADS)
{
snprintf(msg, sizeof_msg, "Max number of pads reached.\n");
return;
Expand Down
2 changes: 2 additions & 0 deletions android/native/jni/input_autodetect.h
Expand Up @@ -17,6 +17,8 @@
#ifndef _ANDROID_INPUT_AUTODETECT_H
#define _ANDROID_INPUT_AUTODETECT_H

#define MAX_PADS 8

#define AKEY_EVENT_NO_ACTION 255

enum {
Expand Down
6 changes: 0 additions & 6 deletions general.h
Expand Up @@ -99,13 +99,7 @@
extern "C" {
#endif

#if defined(_XBOX) || defined(GEKKO)
#define MAX_PLAYERS 4
#elif defined(PSP)
#define MAX_PLAYERS 1
#else
#define MAX_PLAYERS 8
#endif

enum menu_enums
{
Expand Down
10 changes: 6 additions & 4 deletions gx/gx_input.c
Expand Up @@ -36,7 +36,9 @@
#define GC_JOYSTICK_THRESHOLD 48
#define WII_JOYSTICK_THRESHOLD 40

static uint64_t pad_state[MAX_PLAYERS];
#define MAX_PADS 4

static uint64_t pad_state[MAX_PADS];

const struct platform_bind platform_keys[] = {
{ GX_GC_A, "GC A button" },
Expand Down Expand Up @@ -137,7 +139,7 @@ static int16_t gx_input_state(void *data, const struct retro_keybind **binds,
(void)data;
(void)index;

if (port >= MAX_PLAYERS || device != RETRO_DEVICE_JOYPAD)
if (port >= MAX_PADS || device != RETRO_DEVICE_JOYPAD)
return 0;

return (binds[port][id].joykey & pad_state[port]) ? 1 : 0;
Expand Down Expand Up @@ -451,7 +453,7 @@ static void *gx_input_init(void)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));

for(unsigned i = 0; i < MAX_PLAYERS; i++)
for(unsigned i = 0; i < MAX_PADS; i++)
{
unsigned keybind_action = 0;

Expand Down Expand Up @@ -495,7 +497,7 @@ static void gx_input_poll(void *data)
WPAD_ReadPending(WPAD_CHAN_ALL, NULL);
#endif

for (unsigned port = 0; port < MAX_PLAYERS; port++)
for (unsigned port = 0; port < MAX_PADS; port++)
{
uint32_t down = 0;
uint64_t *state_cur = &pad_state[port];
Expand Down
8 changes: 4 additions & 4 deletions ps3/ps3_input.c
Expand Up @@ -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" },
};

static uint64_t state[MAX_PLAYERS];
static uint64_t state[MAX_PADS];
static unsigned pads_connected;
#ifdef HAVE_MOUSE
static unsigned mice_connected;
Expand All @@ -115,7 +115,7 @@ static void ps3_input_poll(void *data)
CellPadInfo2 pad_info;
(void)data;

for (unsigned i = 0; i < MAX_PLAYERS; i++)
for (unsigned i = 0; i < MAX_PADS; i++)
{
static CellPadData state_tmp;
cellPadGetData(i, &state_tmp);
Expand Down Expand Up @@ -508,7 +508,7 @@ static void ps3_input_set_keybinds(void *data, unsigned device,

static void* ps3_input_init(void)
{
cellPadInit(MAX_PLAYERS);
cellPadInit(MAX_PADS);
#ifdef HAVE_MOUSE
cellMouseInit(MAX_MICE);
#endif
Expand All @@ -518,7 +518,7 @@ static void* ps3_input_init(void)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));

for(unsigned i = 0; i < MAX_PLAYERS; i++)
for(unsigned i = 0; i < MAX_PADS; i++)
{
unsigned keybind_action = 0;

Expand Down
4 changes: 4 additions & 0 deletions ps3/ps3_input.h
Expand Up @@ -22,6 +22,10 @@

#include "sdk_defines.h"

#ifndef __PSL1GHT__
#define MAX_PADS 7
#endif

#define DEADZONE_LOW 55
#define DEADZONE_HIGH 210

Expand Down
4 changes: 3 additions & 1 deletion psp/psp_input.c
Expand Up @@ -35,6 +35,8 @@
#define ANALOGSTICK_DEADZONE_LOW (0x40)
#define ANALOGSTICK_DEADZONE_HIGH (0xc0)

#define MAX_PADS 1

const struct platform_bind platform_keys[] = {
{ PSP_GAMEPAD_CIRCLE, "Circle button" },
{ PSP_GAMEPAD_CROSS, "Cross button" },
Expand Down Expand Up @@ -172,7 +174,7 @@ static void* psp_input_initialize(void)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));

for(unsigned i = 0; i < MAX_PLAYERS; i++)
for(unsigned i = 0; i < MAX_PADS; i++)
{
unsigned keybind_action = 0;

Expand Down
17 changes: 9 additions & 8 deletions xdk/xdk_xinput_input.c
Expand Up @@ -21,21 +21,22 @@
#include <xtl.h>
#endif

#define MAX_PADS 4
#define DEADZONE (16000)

#include "../driver.h"
#include "../general.h"
#include "../libretro.h"


static uint64_t state[MAX_PLAYERS];
static uint64_t state[MAX_PADS];
unsigned pads_connected;

#ifdef _XBOX1
static HANDLE gamepads[MAX_PLAYERS];
static HANDLE gamepads[MAX_PADS];
static DWORD dwDeviceMask;
static bool bInserted[MAX_PLAYERS];
static bool bRemoved[MAX_PLAYERS];
static bool bInserted[MAX_PADS];
static bool bRemoved[MAX_PADS];
#endif

const struct platform_bind platform_keys[] = {
Expand Down Expand Up @@ -88,9 +89,9 @@ static void xdk_input_poll(void *data)

XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD, reinterpret_cast<PDWORD>(&dwInsertions), reinterpret_cast<PDWORD>(&dwRemovals));

for (unsigned i = 0; i < MAX_PLAYERS; i++)
for (unsigned i = 0; i < MAX_PADS; i++)
{
XINPUT_CAPABILITIES caps[MAX_PLAYERS];
XINPUT_CAPABILITIES caps[MAX_PADS];
(void)caps;
// handle removed devices
bRemoved[i] = (dwRemovals & (1<<i)) ? true : false;
Expand Down Expand Up @@ -167,7 +168,7 @@ static void xdk_input_poll(void *data)
}
}
#elif defined(_XBOX360)
for (unsigned i = 0; i < MAX_PLAYERS; i++)
for (unsigned i = 0; i < MAX_PADS; i++)
{
XINPUT_STATE state_tmp;
pads_connected += (XInputGetState(i, &state_tmp) == ERROR_DEVICE_NOT_CONNECTED) ? 0 : 1;
Expand Down Expand Up @@ -404,7 +405,7 @@ static void *xdk_input_init(void)
driver.input->set_keybinds(driver.input_data, 0, i, 0,
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));

for(unsigned i = 0; i < MAX_PLAYERS; i++)
for(unsigned i = 0; i < MAX_PADS; i++)
{
unsigned keybind_action = 0;

Expand Down
10 changes: 6 additions & 4 deletions xenon/xenon360_input.c
Expand Up @@ -24,12 +24,14 @@
#include <input/input.h>
#include <usb/usbmain.h>

static uint64_t state[MAX_PLAYERS];
#define MAX_PADS 4

static uint64_t state[MAX_PADS];

static void xenon360_input_poll(void *data)
{
(void)data;
for (unsigned i = 0; i < MAX_PLAYERS; i++)
for (unsigned i = 0; i < MAX_PADS; i++)
{
struct controller_data_s pad;
usb_do_poll();
Expand Down Expand Up @@ -62,7 +64,7 @@ static int16_t xenon360_input_state(void *data, const struct retro_keybind **bin
uint64_t button = binds[player][id].joykey;
int16_t retval = 0;

if(player < MAX_PLAYERS)
if(player < MAX_PADS)
{
switch (device)
{
Expand Down Expand Up @@ -104,7 +106,7 @@ static void* xenon360_input_init(void)
xenon360_input_set_keybinds(driver.input_data, 0, i,
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));

for(unsigned i = 0; i < MAX_PLAYERS; i++)
for(unsigned i = 0; i < MAX_PADS; i++)
{
unsigned keybind_action = 0;

Expand Down

0 comments on commit ad2cd4e

Please sign in to comment.