This commit is contained in:
twinaphex 2020-08-03 17:58:32 +02:00
parent 3cbbccef52
commit d864fd9ead
3 changed files with 20 additions and 19 deletions

View File

@ -38,20 +38,18 @@ struct _wiimote_state
uint8_t type;
};
/* it would be nice to use designated initializers here,
* but those are only in C99 and newer. Oh well.
*/
wiimote_state wiimotes[WIIU_WIIMOTE_CHANNELS] = {
/* static global variables */
static bool kpad_ready = false;
static int channel_slot_map[] = { -1, -1, -1, -1 };
static int poll_failures[WIIU_WIIMOTE_CHANNELS] = { 0, 0, 0, 0 };
static wiimote_state
wiimotes[WIIU_WIIMOTE_CHANNELS] = {
{ 0, {{0,0},{0,0},{0,0}}, WIIMOTE_TYPE_NONE },
{ 0, {{0,0},{0,0},{0,0}}, WIIMOTE_TYPE_NONE },
{ 0, {{0,0},{0,0},{0,0}}, WIIMOTE_TYPE_NONE },
{ 0, {{0,0},{0,0},{0,0}}, WIIMOTE_TYPE_NONE },
};
/* static global variables */
static bool kpad_ready = false;
static int channel_slot_map[] = { -1, -1, -1, -1 };
static int poll_failures[WIIU_WIIMOTE_CHANNELS] = { 0, 0, 0, 0 };
static int to_wiimote_channel(unsigned pad)
{
@ -78,8 +76,6 @@ static int get_slot_for_channel(unsigned channel)
static bool kpad_init(void *data)
{
(void)data;
kpad_poll();
kpad_ready = true;

View File

@ -16,8 +16,9 @@
#include "wiiu/input.h"
enum wiiu_pad_axes {
WIIU_AXIS_LEFT_ANALOG_X,
enum wiiu_pad_axes
{
WIIU_AXIS_LEFT_ANALOG_X = 0,
WIIU_AXIS_LEFT_ANALOG_Y,
WIIU_AXIS_RIGHT_ANALOG_X,
WIIU_AXIS_RIGHT_ANALOG_Y,
@ -28,9 +29,9 @@ enum wiiu_pad_axes {
static int16_t clamp_axis(int16_t value, bool is_negative)
{
if(is_negative && value > 0)
if (is_negative && value > 0)
return 0;
if(!is_negative && value < 0)
if (!is_negative && value < 0)
return 0;
return value;
@ -41,7 +42,7 @@ static int16_t wiiu_pad_get_axis_value(int32_t axis,
{
int16_t value = 0;
switch(axis)
switch (axis)
{
case WIIU_AXIS_LEFT_ANALOG_X:
value = state[RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_X];

View File

@ -25,15 +25,17 @@
#define PANIC_BUTTON_MASK (VPAD_BUTTON_R | VPAD_BUTTON_L | VPAD_BUTTON_STICK_R | VPAD_BUTTON_STICK_L)
#define WPAD_INVALID_CHANNEL -1
typedef struct _drc_state drc_state;
struct _drc_state
{
uint64_t button_state;
int16_t analog_state[3][2];
};
static drc_state gamepads[WIIU_GAMEPAD_CHANNELS] = { 0 };
#define WPAD_INVALID_CHANNEL -1
/* TODO/FIXME - static global variables */
static drc_state gamepads[WIIU_GAMEPAD_CHANNELS] = { 0 };
static int channel_slot_map[WIIU_GAMEPAD_CHANNELS] = { WPAD_INVALID_CHANNEL, WPAD_INVALID_CHANNEL };
static VPADChan to_gamepad_channel(unsigned pad)
@ -270,7 +272,8 @@ static bool wpad_init(void *data)
static bool wpad_query_pad(unsigned port)
{
return port < MAX_USERS && (to_gamepad_channel(port) != WPAD_INVALID_CHANNEL);
return port < MAX_USERS &&
(to_gamepad_channel(port) != WPAD_INVALID_CHANNEL);
}
static void wpad_destroy(void) { }
@ -319,7 +322,8 @@ static int16_t wpad_axis(unsigned port, uint32_t axis)
return 0;
pad_functions.read_axis_data(axis, &data);
return pad_functions.get_axis_value(data.axis, gamepads[channel].analog_state, data.is_negative);
return pad_functions.get_axis_value(data.axis,
gamepads[channel].analog_state, data.is_negative);
}
static int16_t wpad_state(