Skip to content

Commit

Permalink
(Xenon) Fixes/cleanups (remnants of old SSNES eradicated)
Browse files Browse the repository at this point in the history
  • Loading branch information
twinaphex committed Jan 13, 2013
1 parent 79e9dc0 commit 25908c7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Makefile.xenon
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OBJ = console/griffin/griffin.o

LIBS = -lretro_xenon360 -lxenon -lm -lc
DEFINES = -std=gnu99 -DPACKAGE_VERSION=\"0.9.8-beta3\" -DRARCH_CONSOLE -DHAVE_THREAD -DHAVE_GETOPT_LONG=1 -DHAVE_GRIFFIN -Dmain=rarch_main
DEFINES += -maltivec -mhard-float -m32 -mpowerpc64 -mcpu=cell -mtune=cell -fno-pic -g -Wall -DXENON $(INCDIRS)
DEFINES += -maltivec -mhard-float -m32 -mpowerpc64 -mcpu=cell -mtune=cell -fno-pic -g -Wall -DXENON $(INCDIRS) -Wno-char-subscripts
DEFINES += -u read -u _start -u exc_base

ifeq ($(DEBUG), 1)
Expand Down
5 changes: 5 additions & 0 deletions driver_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ static inline bool input_key_pressed_func(int key)
#elif defined(_XBOX) && (defined(HAVE_D3D8) || defined(HAVE_D3D9)) /* D3D */
#define MAKENAME_VIDEO(A) CONCAT2(xdk_d3d, A)

#elif defined(XENON) /* XENON */
#define MAKENAME_VIDEO(A) CONCAT2(xenon360, A)

#define video_set_aspect_ratio_func(aspectratio_idx) gfx_ctx_set_aspect_ratio(driver.video_data, aspectratio_idx)

#define gfx_ctx_window_has_focus() (true)
Expand Down Expand Up @@ -163,6 +166,8 @@ static inline bool input_key_pressed_func(int key)
#define MAKENAME_INPUT(A) CONCAT2(ps3, A)
#elif defined(ANDROID) /* ANDROID */
#define MAKENAME_INPUT(A) CONCAT2(android, A)
#elif defined(XENON) /* XENON */
#define MAKENAME_INPUT(A) CONCAT2(xenon360, A)
#else
#define MAKENAME_INPUT(A) CONCAT2(nullinput, A)
#endif
Expand Down
91 changes: 32 additions & 59 deletions xenon/xenon360_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,33 @@
#include <input/input.h>
#include <usb/usbmain.h>

#define MAX_PADS
#define MAX_PADS 4

static struct controller_data_s pad[MAX_PADS];
static uint64_t state[MAX_PADS];

static void xenon360_input_poll(void *data)
{
(void)data;
for (unsigned i = 0; i < MAX_PADS; i++)
{
struct controller_data_s pad;
usb_do_poll();
get_controller_data(&pad[i], i);
get_controller_data(&pad, i);

uint64_t *cur_state = &state[i];

*cur_state |= pad.b ? RETRO_DEVICE_ID_JOYPAD_A : 0;
*cur_state |= pad.a ? RETRO_DEVICE_ID_JOYPAD_B : 0;
*cur_state |= pad.y ? RETRO_DEVICE_ID_JOYPAD_X : 0;
*cur_state |= pad.x ? RETRO_DEVICE_ID_JOYPAD_Y : 0;
*cur_state |= pad.left ? RETRO_DEVICE_ID_JOYPAD_LEFT : 0;
*cur_state |= pad.right ? RETRO_DEVICE_ID_JOYPAD_RIGHT : 0;
*cur_state |= pad.up ? RETRO_DEVICE_ID_JOYPAD_UP : 0;
*cur_state |= pad.down ? RETRO_DEVICE_ID_JOYPAD_DOWN : 0;
*cur_state |= pad.start ? RETRO_DEVICE_ID_JOYPAD_START : 0;
*cur_state |= pad.back ? RETRO_DEVICE_ID_JOYPAD_SELECT : 0;
*cur_state |= pad.lt ? RETRO_DEVICE_ID_JOYPAD_L : 0;
*cur_state |= pad.rt ? RETRO_DEVICE_ID_JOYPAD_R : 0;
}
}

Expand All @@ -43,68 +59,25 @@ static int16_t xenon360_input_state(void *data, const struct retro_keybind **bin
unsigned index, unsigned id)
{
(void)data;
(void)binds;
(void)index;
unsigned player = port;
uint64_t button = binds[player][id].joykey;
int16_t retval = 0;

if (device != SNES_DEVICE_JOYPAD)
return 0;

unsigned player = 0;
if (port == SNES_PORT_2 && device == SNES_DEVICE_MULTITAP)
player = index + 1;
else if (port == SNES_PORT_2)
player = 1;

bool button;

// Hardcoded binds.
switch (id)
if(player < MAX_PADS)
{
case SNES_DEVICE_ID_JOYPAD_A:
button = pad[player].b;
break;
case SNES_DEVICE_ID_JOYPAD_B:
button = pad[player].a;
break;
case SNES_DEVICE_ID_JOYPAD_X:
button = pad[player].y;
break;
case SNES_DEVICE_ID_JOYPAD_Y:
button = pad[player].x;
break;
case SNES_DEVICE_ID_JOYPAD_LEFT:
button = pad[player].left;
break;
case SNES_DEVICE_ID_JOYPAD_RIGHT:
button = pad[player].right;
break;
case SNES_DEVICE_ID_JOYPAD_UP:
button = pad[player].up;
break;
case SNES_DEVICE_ID_JOYPAD_DOWN:
button = pad[player].down;
break;
case SNES_DEVICE_ID_JOYPAD_START:
button = pad[player].start;
break;
case SNES_DEVICE_ID_JOYPAD_SELECT:
button = pad[player].select;
break;
case SNES_DEVICE_ID_JOYPAD_L:
button = pad[player].lt;
break;
case SNES_DEVICE_ID_JOYPAD_R:
button = pad[player].rt;
break;
default:
button = false;
break;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
retval = (state[player] & button) ? 1 : 0;
break;
}
}

return button;
return retval;
}

static void xenon360_free_input(void *data)
static void xenon360_input_free_input(void *data)
{
(void)data;
}
Expand Down Expand Up @@ -138,7 +111,7 @@ const input_driver_t input_xenon360 = {
.poll = xenon360_input_poll,
.input_state = xenon360_input_state,
.key_pressed = xenon360_key_pressed,
.free = xenon360_free_input,
.free = xenon360_input_free_input,
.set_default_keybind_lut = xenon360_input_set_default_keybind_lut,
.set_analog_dpad_mapping = xenon360_input_set_analog_dpad_mapping,
.max_pads = MAX_PADS,
Expand Down

0 comments on commit 25908c7

Please sign in to comment.