mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 16:20:27 +00:00
Cleanups
This commit is contained in:
parent
d4255b0e55
commit
02876aecae
@ -46,7 +46,7 @@ typedef struct wiiu_input
|
||||
|
||||
void kb_connection_callback(KBDKeyEvent *key)
|
||||
{
|
||||
keyboardChannel = keyboardChannel + (key->channel + 0x01);
|
||||
keyboardChannel = keyboardChannel + (key->channel + 0x01);
|
||||
}
|
||||
|
||||
void kb_disconnection_callback(KBDKeyEvent *key)
|
||||
@ -116,10 +116,10 @@ static void wiiu_input_poll(void *data)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
|
||||
if(!wiiu)
|
||||
if (!wiiu)
|
||||
return;
|
||||
|
||||
if(wiiu->joypad)
|
||||
if (wiiu->joypad)
|
||||
wiiu->joypad->poll();
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ static int16_t wiiu_input_state(void *data,
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
|
||||
if(!wiiu || !(port < DEFAULT_MAX_PADS) || !binds || !binds[port])
|
||||
if (!wiiu || !(port < DEFAULT_MAX_PADS) || !binds || !binds[port])
|
||||
return 0;
|
||||
|
||||
switch (device)
|
||||
|
@ -57,7 +57,7 @@ static int channel_slot_map[] = { -1, -1, -1, -1 };
|
||||
|
||||
static int to_wiimote_channel(unsigned pad)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for(i = 0; i < WIIU_WIIMOTE_CHANNELS; i++)
|
||||
if(channel_slot_map[i] == pad)
|
||||
@ -72,7 +72,7 @@ static int get_slot_for_channel(unsigned channel)
|
||||
if(slot >= 0)
|
||||
{
|
||||
RARCH_LOG("[kpad]: got slot %d\n", slot);
|
||||
channel_slot_map[channel] = slot;
|
||||
channel_slot_map[channel] = slot;
|
||||
hid_instance.pad_list[slot].connected = true;
|
||||
}
|
||||
|
||||
@ -99,10 +99,11 @@ static void kpad_destroy(void)
|
||||
|
||||
static bool kpad_button(unsigned pad, uint16_t button_bit)
|
||||
{
|
||||
int channel;
|
||||
if (!kpad_query_pad(pad))
|
||||
return false;
|
||||
|
||||
int channel = to_wiimote_channel(pad);
|
||||
channel = to_wiimote_channel(pad);
|
||||
if(channel < 0)
|
||||
return false;
|
||||
|
||||
@ -122,8 +123,9 @@ static void kpad_get_buttons(unsigned pad, input_bits_t *state)
|
||||
|
||||
static int16_t kpad_axis(unsigned pad, uint32_t axis)
|
||||
{
|
||||
int channel = to_wiimote_channel(pad);
|
||||
axis_data data;
|
||||
int channel = to_wiimote_channel(pad);
|
||||
|
||||
if (!kpad_query_pad(pad) || channel < 0 || axis == AXIS_NONE)
|
||||
return 0;
|
||||
|
||||
@ -222,7 +224,8 @@ static void kpad_poll(void)
|
||||
/* this is a hack to prevent spurious disconnects */
|
||||
/* TODO: use KPADSetConnectCallback and use callbacks to detect */
|
||||
/* pad disconnects properly. */
|
||||
if (result == 0) {
|
||||
if (result == 0)
|
||||
{
|
||||
poll_failures[channel]++;
|
||||
if(poll_failures[channel] > 5)
|
||||
kpad_deregister(channel);
|
||||
@ -253,8 +256,10 @@ static const char *kpad_name(unsigned pad)
|
||||
case WIIMOTE_TYPE_NONE:
|
||||
default:
|
||||
RARCH_LOG("[kpad]: Unknown pad type %d\n", wiimotes[pad].type);
|
||||
return "N/A";
|
||||
break;
|
||||
}
|
||||
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
input_device_driver_t kpad_driver =
|
||||
|
@ -64,8 +64,11 @@ static int16_t wiiu_pad_get_axis_value(int32_t axis,
|
||||
return clamp_axis(value, is_negative);
|
||||
}
|
||||
|
||||
void wiiu_pad_set_axis_value(int16_t state[3][2], int16_t left_x, int16_t left_y,
|
||||
int16_t right_x, int16_t right_y, int16_t touch_x, int16_t touch_y)
|
||||
void wiiu_pad_set_axis_value(
|
||||
int16_t state[3][2],
|
||||
int16_t left_x, int16_t left_y,
|
||||
int16_t right_x, int16_t right_y,
|
||||
int16_t touch_x, int16_t touch_y)
|
||||
{
|
||||
state[RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_X] = left_x;
|
||||
state[RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_Y] = left_y;
|
||||
|
@ -46,7 +46,7 @@ static int16_t scale_touchpad(int16_t from_min, int16_t from_max,
|
||||
int16_t to_min, int16_t to_max, int16_t value )
|
||||
{
|
||||
int32_t from_range = from_max - from_min;
|
||||
int32_t to_range = to_max - to_min;
|
||||
int32_t to_range = to_max - to_min;
|
||||
|
||||
return (((value - from_min) * to_range) / from_range) + to_min;
|
||||
}
|
||||
@ -129,10 +129,9 @@ static void log_coords(int16_t x, int16_t y)
|
||||
|
||||
static void update_touch_state(int16_t state[3][2], uint64_t *buttons, VPADStatus *vpad)
|
||||
{
|
||||
VPADTouchData point = {0};
|
||||
VPADTouchData point = {0};
|
||||
struct video_viewport viewport = {0};
|
||||
|
||||
bool touch_clamped = false;
|
||||
bool touch_clamped = false;
|
||||
|
||||
if (!vpad->tpNormal.touched || vpad->tpNormal.validity != VPAD_VALID)
|
||||
{
|
||||
@ -232,8 +231,9 @@ static int16_t wpad_axis(unsigned pad, uint32_t axis)
|
||||
return pad_functions.get_axis_value(data.axis, analog_state, data.is_negative);
|
||||
}
|
||||
|
||||
static const char *wpad_name(unsigned pad) {
|
||||
return PAD_NAME_WIIU_GAMEPAD;
|
||||
static const char *wpad_name(unsigned pad)
|
||||
{
|
||||
return PAD_NAME_WIIU_GAMEPAD;
|
||||
}
|
||||
|
||||
input_device_driver_t wpad_driver =
|
||||
|
@ -23,15 +23,6 @@ extern pad_connection_listener_t wiiu_pad_connection_listener;
|
||||
|
||||
static bool ready = false;
|
||||
|
||||
static bool wiiu_joypad_init(void *data);
|
||||
static bool wiiu_joypad_query_pad(unsigned pad);
|
||||
static void wiiu_joypad_destroy(void);
|
||||
static bool wiiu_joypad_button(unsigned pad, uint16_t button);
|
||||
static void wiiu_joypad_get_buttons(unsigned pad, input_bits_t *state);
|
||||
static int16_t wiiu_joypad_axis(unsigned pad, uint32_t axis);
|
||||
static void wiiu_joypad_poll(void);
|
||||
static const char *wiiu_joypad_name(unsigned pad);
|
||||
|
||||
static bool wiiu_joypad_init(void* data)
|
||||
{
|
||||
set_connection_listener(&wiiu_pad_connection_listener);
|
||||
@ -52,59 +43,59 @@ static bool wiiu_joypad_init(void* data)
|
||||
|
||||
static bool wiiu_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
return ready &&
|
||||
pad < MAX_USERS &&
|
||||
pad_drivers[pad] != NULL &&
|
||||
pad_drivers[pad]->query_pad(pad);
|
||||
return ready &&
|
||||
pad < MAX_USERS &&
|
||||
pad_drivers[pad] != NULL &&
|
||||
pad_drivers[pad]->query_pad(pad);
|
||||
}
|
||||
|
||||
static void wiiu_joypad_destroy(void)
|
||||
{
|
||||
ready = false;
|
||||
ready = false;
|
||||
|
||||
wpad_driver.destroy();
|
||||
kpad_driver.destroy();
|
||||
wpad_driver.destroy();
|
||||
kpad_driver.destroy();
|
||||
#ifdef WIIU_HID
|
||||
hidpad_driver.destroy();
|
||||
hidpad_driver.destroy();
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool wiiu_joypad_button(unsigned pad, uint16_t key)
|
||||
{
|
||||
if(!wiiu_joypad_query_pad(pad))
|
||||
return false;
|
||||
if (!wiiu_joypad_query_pad(pad))
|
||||
return false;
|
||||
|
||||
return pad_drivers[pad]->button(pad, key);
|
||||
return pad_drivers[pad]->button(pad, key);
|
||||
}
|
||||
|
||||
static void wiiu_joypad_get_buttons(unsigned pad, input_bits_t *state)
|
||||
{
|
||||
if(!wiiu_joypad_query_pad(pad))
|
||||
return;
|
||||
if (!wiiu_joypad_query_pad(pad))
|
||||
return;
|
||||
|
||||
pad_drivers[pad]->get_buttons(pad, state);
|
||||
pad_drivers[pad]->get_buttons(pad, state);
|
||||
}
|
||||
|
||||
static int16_t wiiu_joypad_axis(unsigned pad, uint32_t joyaxis)
|
||||
{
|
||||
if(!wiiu_joypad_query_pad(pad))
|
||||
return 0;
|
||||
if (!wiiu_joypad_query_pad(pad))
|
||||
return 0;
|
||||
|
||||
return pad_drivers[pad]->axis(pad, joyaxis);
|
||||
return pad_drivers[pad]->axis(pad, joyaxis);
|
||||
}
|
||||
|
||||
static void wiiu_joypad_poll(void)
|
||||
{
|
||||
wpad_driver.poll();
|
||||
kpad_driver.poll();
|
||||
wpad_driver.poll();
|
||||
kpad_driver.poll();
|
||||
#ifdef WIIU_HID
|
||||
hidpad_driver.poll();
|
||||
hidpad_driver.poll();
|
||||
#endif
|
||||
}
|
||||
|
||||
static const char* wiiu_joypad_name(unsigned pad)
|
||||
{
|
||||
if(!wiiu_joypad_query_pad(pad))
|
||||
if (!wiiu_joypad_query_pad(pad))
|
||||
return "N/A";
|
||||
|
||||
return pad_drivers[pad]->name(pad);
|
||||
@ -113,7 +104,7 @@ static const char* wiiu_joypad_name(unsigned pad)
|
||||
static void wiiu_joypad_connection_listener(unsigned pad,
|
||||
input_device_driver_t *driver)
|
||||
{
|
||||
if(pad < MAX_USERS)
|
||||
if (pad < MAX_USERS)
|
||||
pad_drivers[pad] = driver;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user