mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-12 04:31:19 +00:00
(joypad drivers) Cleanups
This commit is contained in:
parent
52a800a520
commit
334cb3d5d4
@ -49,10 +49,10 @@ static int LockData(void *a, int size)
|
||||
if (__dpmi_get_segment_base_address(_my_ds(), &baseaddr) != -1)
|
||||
{
|
||||
__dpmi_meminfo region;
|
||||
region.handle = 0;
|
||||
region.size = size;
|
||||
region.address = baseaddr + (uint32_t)a;
|
||||
if (__dpmi_lock_linear_region(®ion) != -1)
|
||||
region.handle = 0;
|
||||
region.size = size;
|
||||
region.address = baseaddr + (uint32_t)a;
|
||||
if (__dpmi_lock_linear_region(®ion) != -1)
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
|
@ -77,12 +77,12 @@ static int32_t ps3_joypad_button(unsigned port, uint16_t joykey)
|
||||
|
||||
static void ps3_joypad_get_buttons(unsigned port_num, input_bits_t *state)
|
||||
{
|
||||
if (port_num < DEFAULT_MAX_PADS)
|
||||
if (port_num < DEFAULT_MAX_PADS)
|
||||
{
|
||||
BITS_COPY16_PTR( state, pad_state[port_num] );
|
||||
}
|
||||
BITS_COPY16_PTR( state, pad_state[port_num] );
|
||||
}
|
||||
else
|
||||
BIT256_CLEAR_ALL_PTR(state);
|
||||
BIT256_CLEAR_ALL_PTR(state);
|
||||
}
|
||||
|
||||
static int16_t ps3_joypad_axis_state(unsigned port, uint32_t joyaxis)
|
||||
@ -138,29 +138,29 @@ static int16_t ps3_joypad_state(
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = 0;
|
||||
uint16_t port_idx = joypad_info->joy_idx;
|
||||
|
||||
if (port_idx >= DEFAULT_MAX_PADS)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
if (port_idx < DEFAULT_MAX_PADS)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[i].joykey != NO_BTN)
|
||||
? binds[i].joykey : joypad_info->auto_binds[i].joykey;
|
||||
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
|
||||
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
||||
if (
|
||||
unsigned i;
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[i].joykey != NO_BTN)
|
||||
? binds[i].joykey : joypad_info->auto_binds[i].joykey;
|
||||
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
|
||||
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
||||
if (
|
||||
(uint16_t)joykey != NO_BTN
|
||||
&& pad_state[port_idx] & (UINT64_C(1) << (uint16_t)joykey)
|
||||
)
|
||||
ret |= ( 1 << i);
|
||||
else if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(ps3_joypad_axis_state(port_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
ret |= (1 << i);
|
||||
&& pad_state[port_idx] & (UINT64_C(1) << (uint16_t)joykey)
|
||||
)
|
||||
ret |= ( 1 << i);
|
||||
else if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(ps3_joypad_axis_state(port_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -175,6 +175,7 @@ static void ps3_joypad_poll(void)
|
||||
|
||||
for (port = 0; port < DEFAULT_MAX_PADS; port++)
|
||||
{
|
||||
int i, j;
|
||||
padData state_tmp;
|
||||
|
||||
if (pad_info.port_status[port] & CELL_PAD_STATUS_ASSIGN_CHANGES)
|
||||
@ -250,8 +251,8 @@ static void ps3_joypad_poll(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
for (i = 0; i < 2; i++)
|
||||
for (j = 0; j < 2; j++)
|
||||
if (analog_state[port][i][j] == -0x8000)
|
||||
analog_state[port][i][j] = -0x7fff;
|
||||
}
|
||||
|
@ -73,25 +73,25 @@ static int16_t hidpad_state(
|
||||
int16_t ret = 0;
|
||||
uint16_t port_idx = joypad_info->joy_idx;
|
||||
|
||||
if (!hidpad_query_pad(port_idx))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
if (hidpad_query_pad(port_idx))
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[i].joykey != NO_BTN)
|
||||
? binds[i].joykey : joypad_info->auto_binds[i].joykey;
|
||||
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
|
||||
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
||||
if (
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[i].joykey != NO_BTN)
|
||||
? binds[i].joykey : joypad_info->auto_binds[i].joykey;
|
||||
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
|
||||
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
||||
if (
|
||||
(uint16_t)joykey != NO_BTN
|
||||
&& wiiu_hid.button(hid_driver_get_data(), port_idx, (uint16_t)joykey)
|
||||
)
|
||||
ret |= ( 1 << i);
|
||||
else if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(wiiu_hid.axis(hid_driver_get_data(), port_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
ret |= (1 << i);
|
||||
&& wiiu_hid.button(hid_driver_get_data(), port_idx, (uint16_t)joykey)
|
||||
)
|
||||
ret |= ( 1 << i);
|
||||
else if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(wiiu_hid.axis(hid_driver_get_data(), port_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -45,8 +45,8 @@ static int get_slot_for_channel(unsigned channel)
|
||||
int slot = pad_connection_find_vacant_pad(joypad_state.pads);
|
||||
if (slot >= 0)
|
||||
{
|
||||
joypad_state.kpad.channel_slot_map[channel] = slot;
|
||||
joypad_state.pads[slot].connected = true;
|
||||
joypad_state.kpad.channel_slot_map[channel] = slot;
|
||||
joypad_state.pads[slot].connected = true;
|
||||
}
|
||||
|
||||
return slot;
|
||||
@ -54,11 +54,13 @@ static int get_slot_for_channel(unsigned channel)
|
||||
|
||||
static void *kpad_init(void *data)
|
||||
{
|
||||
int i;
|
||||
memset(&joypad_state.kpad, 0, sizeof(joypad_state.kpad));
|
||||
|
||||
for(int i = 0; i < WIIU_WIIMOTE_CHANNELS; i++) {
|
||||
for (i = 0; i < WIIU_WIIMOTE_CHANNELS; i++)
|
||||
{
|
||||
joypad_state.kpad.channel_slot_map[i] = -1;
|
||||
joypad_state.kpad.wiimotes[i].type = WIIMOTE_TYPE_NONE;
|
||||
joypad_state.kpad.wiimotes[i].type = WIIMOTE_TYPE_NONE;
|
||||
}
|
||||
|
||||
kpad_poll();
|
||||
@ -79,15 +81,14 @@ static void kpad_destroy(void)
|
||||
|
||||
static int32_t kpad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
int channel;
|
||||
if (!kpad_query_pad(port))
|
||||
return 0;
|
||||
|
||||
channel = to_wiimote_channel(port);
|
||||
if (channel < 0)
|
||||
return 0;
|
||||
return (joypad_state.kpad.wiimotes[channel].button_state
|
||||
& (UINT64_C(1) << joykey));
|
||||
if (kpad_query_pad(port))
|
||||
{
|
||||
int channel = to_wiimote_channel(port);
|
||||
if (channel >= 0)
|
||||
return (joypad_state.kpad.wiimotes[channel].button_state
|
||||
& (UINT64_C(1) << joykey));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void kpad_get_buttons(unsigned port, input_bits_t *state)
|
||||
@ -149,15 +150,14 @@ static void kpad_register(unsigned channel, uint8_t device_type)
|
||||
{
|
||||
int slot;
|
||||
|
||||
if(device_type == WIIMOTE_TYPE_NONE) {
|
||||
if (device_type == WIIMOTE_TYPE_NONE)
|
||||
{
|
||||
kpad_deregister(channel);
|
||||
return;
|
||||
}
|
||||
|
||||
slot = joypad_state.kpad.channel_slot_map[channel];
|
||||
if(slot < 0) {
|
||||
if ((slot = joypad_state.kpad.channel_slot_map[channel]) < 0)
|
||||
slot = get_slot_for_channel(channel);
|
||||
}
|
||||
|
||||
if (slot < 0)
|
||||
{
|
||||
@ -176,7 +176,7 @@ static void kpad_register(unsigned channel, uint8_t device_type)
|
||||
static void kpad_poll_one_channel(unsigned channel, KPADData *kpad)
|
||||
{
|
||||
kpad_register(channel, kpad->device_type);
|
||||
switch(kpad->device_type)
|
||||
switch (kpad->device_type)
|
||||
{
|
||||
case WIIMOTE_TYPE_PRO:
|
||||
joypad_state.kpad.wiimotes[channel].button_state = kpad->classic.btns_h
|
||||
@ -226,33 +226,30 @@ static void kpad_deregister(unsigned channel)
|
||||
|
||||
static void kpad_poll(void)
|
||||
{
|
||||
unsigned channel;
|
||||
KPADData kpad;
|
||||
unsigned channel;
|
||||
int32_t result = 0;
|
||||
|
||||
for (channel = 0; channel < WIIU_WIIMOTE_CHANNELS; channel++)
|
||||
{
|
||||
memset(&kpad, 0, sizeof(kpad));
|
||||
|
||||
result = KPADRead(channel, &kpad, 1);
|
||||
/* this is a hack to prevent spurious disconnects */
|
||||
/* This is a hack to prevent spurious disconnects */
|
||||
/* TODO: use KPADSetConnectCallback and use callbacks to detect */
|
||||
/* pad disconnects properly. */
|
||||
if (result == 0)
|
||||
if ((result = KPADRead(channel, &kpad, 1)) == 0)
|
||||
{
|
||||
joypad_state.kpad.poll_failures[channel]++;
|
||||
if (joypad_state.kpad.poll_failures[channel] > 5) {
|
||||
if (joypad_state.kpad.poll_failures[channel] > 5)
|
||||
kpad_deregister(channel);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
joypad_state.kpad.poll_failures[channel] = 0;
|
||||
|
||||
/* Several reads when a device is connected or an attachment added give */
|
||||
/* bogus results, try to weed them out */
|
||||
if (kpad.wpad_error || kpad.device_type == 255) {
|
||||
if (kpad.wpad_error || kpad.device_type == 255)
|
||||
continue;
|
||||
}
|
||||
|
||||
kpad_poll_one_channel(channel, &kpad);
|
||||
}
|
||||
@ -264,7 +261,7 @@ static const char *kpad_name(unsigned pad)
|
||||
if (channel < 0)
|
||||
return "unknown";
|
||||
|
||||
switch(joypad_state.kpad.wiimotes[channel].type)
|
||||
switch (joypad_state.kpad.wiimotes[channel].type)
|
||||
{
|
||||
case WIIMOTE_TYPE_PRO:
|
||||
return PAD_NAME_WIIU_PRO;
|
||||
|
@ -71,12 +71,12 @@ void wiiu_pad_set_axis_value(
|
||||
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;
|
||||
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;
|
||||
state[RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = right_x;
|
||||
state[RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = right_y;
|
||||
state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_X] = touch_x;
|
||||
state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_Y] = touch_y;
|
||||
state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_X] = touch_x;
|
||||
state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_Y] = touch_y;
|
||||
}
|
||||
|
||||
wiiu_pad_functions_t pad_functions = {
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#define WPAD_INVALID_CHANNEL -1
|
||||
|
||||
static VPADChan to_gamepad_channel(unsigned pad)
|
||||
static VPADChan wpad_to_gamepad_channel(unsigned pad)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@ -63,7 +63,7 @@ static void wpad_deregister(unsigned channel)
|
||||
return;
|
||||
|
||||
input_autoconfigure_disconnect(slot, wpad_driver.ident);
|
||||
joypad_state.pads[slot].connected = false;
|
||||
joypad_state.pads[slot].connected = false;
|
||||
joypad_state.wpad.channel_slot_map[channel] = WPAD_INVALID_CHANNEL;
|
||||
}
|
||||
|
||||
@ -80,8 +80,7 @@ static void wpad_register(unsigned channel)
|
||||
if (joypad_state.wpad.channel_slot_map[channel] != WPAD_INVALID_CHANNEL)
|
||||
return;
|
||||
|
||||
slot = pad_connection_find_vacant_pad(joypad_state.pads);
|
||||
if(slot < 0)
|
||||
if ((slot = pad_connection_find_vacant_pad(joypad_state.pads)) < 0)
|
||||
return;
|
||||
|
||||
joypad_state.pads[slot].connected = true;
|
||||
@ -90,12 +89,12 @@ static void wpad_register(unsigned channel)
|
||||
joypad_state.wpad.channel_slot_map[channel] = slot;
|
||||
}
|
||||
|
||||
static void update_button_state(uint64_t *state, uint32_t held_buttons)
|
||||
static void wpad_update_button_state(uint64_t *state, uint32_t held_buttons)
|
||||
{
|
||||
*state = held_buttons & VPAD_MASK_BUTTONS;
|
||||
}
|
||||
|
||||
static void update_analog_state(int16_t state[3][2], VPADStatus *vpad)
|
||||
static void wpad_update_analog_state(int16_t state[3][2], VPADStatus *vpad)
|
||||
{
|
||||
state[RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = WIIU_READ_STICK(vpad->leftStick.x);
|
||||
state[RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = WIIU_READ_STICK(vpad->leftStick.y);
|
||||
@ -103,7 +102,7 @@ static void update_analog_state(int16_t state[3][2], VPADStatus *vpad)
|
||||
state[RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = WIIU_READ_STICK(vpad->rightStick.y);
|
||||
}
|
||||
|
||||
static int16_t scale_touchpad(int16_t from_min, int16_t from_max,
|
||||
static int16_t wpad_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;
|
||||
@ -112,17 +111,17 @@ static int16_t scale_touchpad(int16_t from_min, int16_t from_max,
|
||||
return (((value - from_min) * to_range) / from_range) + to_min;
|
||||
}
|
||||
|
||||
static void get_calibrated_point(VPADTouchData *point,
|
||||
static void wpad_get_calibrated_point(VPADTouchData *point,
|
||||
struct video_viewport *viewport, VPADStatus *vpad, unsigned channel)
|
||||
{
|
||||
VPADTouchData calibrated720p = {0};
|
||||
|
||||
VPADGetTPCalibratedPoint(channel, &calibrated720p, &(vpad->tpNormal));
|
||||
point->x = scale_touchpad(12, 1268, 0, viewport->full_width, calibrated720p.x);
|
||||
point->y = scale_touchpad(12, 708, 0, viewport->full_height, calibrated720p.y);
|
||||
point->x = wpad_scale_touchpad(12, 1268, 0, viewport->full_width, calibrated720p.x);
|
||||
point->y = wpad_scale_touchpad(12, 708, 0, viewport->full_height, calibrated720p.y);
|
||||
}
|
||||
|
||||
static void apply_clamping(VPADTouchData *point, struct video_viewport *viewport, bool *clamped)
|
||||
static void wpad_apply_clamping(VPADTouchData *point, struct video_viewport *viewport, bool *clamped)
|
||||
{
|
||||
/* clamp the x domain to the viewport */
|
||||
if (point->x < viewport->x)
|
||||
@ -149,11 +148,11 @@ static void apply_clamping(VPADTouchData *point, struct video_viewport *viewport
|
||||
}
|
||||
}
|
||||
|
||||
static void get_touch_coordinates(VPADTouchData *point, VPADStatus *vpad,
|
||||
static void wpad_get_touch_coordinates(VPADTouchData *point, VPADStatus *vpad,
|
||||
VPADChan channel, struct video_viewport *viewport, bool *clamped)
|
||||
{
|
||||
get_calibrated_point(point, viewport, vpad, channel);
|
||||
apply_clamping(point, viewport, clamped);
|
||||
wpad_get_calibrated_point(point, viewport, vpad, channel);
|
||||
wpad_apply_clamping(point, viewport, clamped);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -173,7 +172,7 @@ static int16_t bitwise_abs(int16_t value)
|
||||
/**
|
||||
* printf doesn't have a concept of a signed hex digit, so we fake it.
|
||||
*/
|
||||
static void log_coords(int16_t x, int16_t y)
|
||||
static void wpad_log_coords(int16_t x, int16_t y)
|
||||
{
|
||||
bool x_negative = x & 0x8000;
|
||||
bool y_negative = y & 0x8000;
|
||||
@ -189,7 +188,7 @@ static void log_coords(int16_t x, int16_t y)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void update_touch_state(int16_t state[3][2],
|
||||
static void wpad_update_touch_state(int16_t state[3][2],
|
||||
uint64_t *buttons, VPADStatus *vpad, VPADChan channel)
|
||||
{
|
||||
VPADTouchData point = {0};
|
||||
@ -203,15 +202,15 @@ static void update_touch_state(int16_t state[3][2],
|
||||
}
|
||||
|
||||
video_driver_get_viewport_info(&viewport);
|
||||
get_touch_coordinates(&point, vpad, channel, &viewport, &touch_clamped);
|
||||
wpad_get_touch_coordinates(&point, vpad, channel, &viewport, &touch_clamped);
|
||||
|
||||
state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_X] = scale_touchpad(
|
||||
state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_X] = wpad_scale_touchpad(
|
||||
viewport.x, viewport.x + viewport.width, -0x7fff, 0x7fff, point.x);
|
||||
state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_Y] = scale_touchpad(
|
||||
state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_Y] = wpad_scale_touchpad(
|
||||
viewport.y, viewport.y + viewport.height, -0x7fff, 0x7fff, point.y);
|
||||
|
||||
#if 0
|
||||
log_coords(state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_X],
|
||||
wpad_log_coords(state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_X],
|
||||
state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_Y]);
|
||||
#endif
|
||||
|
||||
@ -221,7 +220,7 @@ static void update_touch_state(int16_t state[3][2],
|
||||
*buttons &= ~VPAD_BUTTON_TOUCH;
|
||||
}
|
||||
|
||||
static void check_panic_button(uint32_t held_buttons)
|
||||
static void wpad_check_panic_button(uint32_t held_buttons)
|
||||
{
|
||||
if ((held_buttons & PANIC_BUTTON_MASK) == PANIC_BUTTON_MASK)
|
||||
command_event(CMD_EVENT_QUIT, NULL);
|
||||
@ -245,20 +244,20 @@ static void wpad_poll(void)
|
||||
|
||||
if (error == VPAD_READ_SUCCESS)
|
||||
{
|
||||
update_button_state(&joypad_state.wpad.pads[channel].button_state, vpad.hold);
|
||||
update_analog_state(joypad_state.wpad.pads[channel].analog_state, &vpad);
|
||||
update_touch_state(joypad_state.wpad.pads[channel].analog_state, &joypad_state.wpad.pads[channel].button_state, &vpad, channel);
|
||||
check_panic_button(vpad.hold);
|
||||
wpad_update_button_state(&joypad_state.wpad.pads[channel].button_state, vpad.hold);
|
||||
wpad_update_analog_state(joypad_state.wpad.pads[channel].analog_state, &vpad);
|
||||
wpad_update_touch_state(joypad_state.wpad.pads[channel].analog_state, &joypad_state.wpad.pads[channel].button_state, &vpad, channel);
|
||||
wpad_check_panic_button(vpad.hold);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void *wpad_init(void *data)
|
||||
{
|
||||
int i;
|
||||
memset(&joypad_state.wpad, 0, sizeof(joypad_state.wpad));
|
||||
for(int i = 0; i < WIIU_GAMEPAD_CHANNELS; i++) {
|
||||
for (i = 0; i < WIIU_GAMEPAD_CHANNELS; i++)
|
||||
joypad_state.wpad.channel_slot_map[i] = WPAD_INVALID_CHANNEL;
|
||||
}
|
||||
wpad_poll();
|
||||
return (void*)-1;
|
||||
}
|
||||
@ -266,20 +265,20 @@ static void *wpad_init(void *data)
|
||||
static bool wpad_query_pad(unsigned port)
|
||||
{
|
||||
return port < MAX_USERS &&
|
||||
(to_gamepad_channel(port) != WPAD_INVALID_CHANNEL);
|
||||
(wpad_to_gamepad_channel(port) != WPAD_INVALID_CHANNEL);
|
||||
}
|
||||
|
||||
static void wpad_destroy(void) { }
|
||||
|
||||
static int32_t wpad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
VPADChan channel;
|
||||
if (!wpad_query_pad(port))
|
||||
return 0;
|
||||
channel = to_gamepad_channel(port);
|
||||
if (channel < 0)
|
||||
return 0;
|
||||
return (joypad_state.wpad.pads[channel].button_state & (UINT64_C(1) << joykey));
|
||||
if (wpad_query_pad(port))
|
||||
{
|
||||
VPADChan channel = wpad_to_gamepad_channel(port);
|
||||
if (channel >= 0)
|
||||
return (joypad_state.wpad.pads[channel].button_state & (UINT64_C(1) << joykey));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wpad_get_buttons(unsigned port, input_bits_t *state)
|
||||
@ -292,8 +291,7 @@ static void wpad_get_buttons(unsigned port, input_bits_t *state)
|
||||
return;
|
||||
}
|
||||
|
||||
channel = to_gamepad_channel(port);
|
||||
if (channel < 0)
|
||||
if ((channel = wpad_to_gamepad_channel(port)) < 0)
|
||||
{
|
||||
BIT256_CLEAR_ALL_PTR(state);
|
||||
return;
|
||||
@ -310,7 +308,7 @@ static int16_t wpad_axis(unsigned port, uint32_t axis)
|
||||
if (!wpad_query_pad(port))
|
||||
return 0;
|
||||
|
||||
channel = to_gamepad_channel(port);
|
||||
channel = wpad_to_gamepad_channel(port);
|
||||
if (channel < 0)
|
||||
return 0;
|
||||
|
||||
|
@ -198,34 +198,32 @@ static int16_t xdk_joypad_state(
|
||||
const struct retro_keybind *binds,
|
||||
unsigned port)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = 0;
|
||||
XINPUT_GAMEPAD *pad = NULL;
|
||||
uint16_t btn_word = 0;
|
||||
uint16_t port_idx = joypad_info->joy_idx;
|
||||
int16_t ret = 0;
|
||||
uint16_t port_idx = joypad_info->joy_idx;
|
||||
|
||||
if (port_idx >= DEFAULT_MAX_PADS)
|
||||
return 0;
|
||||
|
||||
pad = &(g_xinput_states[port_idx].xstate.Gamepad);
|
||||
btn_word = pad->wButtons;
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
if (port_idx < DEFAULT_MAX_PADS)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[i].joykey != NO_BTN)
|
||||
? binds[i].joykey : joypad_info->auto_binds[i].joykey;
|
||||
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
|
||||
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
||||
if (
|
||||
unsigned i;
|
||||
XINPUT_GAMEPAD *pad = &(g_xinput_states[port_idx].xstate.Gamepad);
|
||||
uint16_t btn_word = pad->wButtons;
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[i].joykey != NO_BTN)
|
||||
? binds[i].joykey : joypad_info->auto_binds[i].joykey;
|
||||
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
|
||||
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
||||
if (
|
||||
(uint16_t)joykey != NO_BTN
|
||||
&& xdk_joypad_button_state(
|
||||
pad, btn_word, port_idx, (uint16_t)joykey))
|
||||
ret |= ( 1 << i);
|
||||
else if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(xdk_joypad_axis_state(pad, port_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
ret |= (1 << i);
|
||||
&& xdk_joypad_button_state(
|
||||
pad, btn_word, port_idx, (uint16_t)joykey))
|
||||
ret |= ( 1 << i);
|
||||
else if (joyaxis != AXIS_NONE &&
|
||||
((float)abs(xdk_joypad_axis_state(pad, port_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -248,17 +246,8 @@ static void xdk_joypad_poll(void)
|
||||
|
||||
for (port = 0; port < DEFAULT_MAX_PADS; port++)
|
||||
{
|
||||
bool device_removed = false;
|
||||
bool device_inserted = false;
|
||||
|
||||
/* handle inserted devices. */
|
||||
/* handle removed devices. */
|
||||
/* Handle removed devices. */
|
||||
if (dwRemovals & (1 << port))
|
||||
device_removed = true;
|
||||
if (dwInsertions & (1 << port))
|
||||
device_inserted = true;
|
||||
|
||||
if (device_removed)
|
||||
{
|
||||
/* if the controller was removed after
|
||||
* XGetDeviceChanges but before
|
||||
@ -271,7 +260,8 @@ static void xdk_joypad_poll(void)
|
||||
input_autoconfigure_disconnect(port, xdk_joypad.ident);
|
||||
}
|
||||
|
||||
if (device_inserted)
|
||||
/* Handle inserted devices. */
|
||||
if (dwInsertions & (1 << port))
|
||||
{
|
||||
XINPUT_POLLING_PARAMETERS m_pollingParameters;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user