2014-08-30 03:48:51 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 13:40:32 +01:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2017-11-28 10:04:34 +00:00
|
|
|
*
|
2014-08-30 03:48:51 +02:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-09-05 18:31:32 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2019-07-19 12:55:38 +02:00
|
|
|
#include "../../config.def.h"
|
|
|
|
|
2017-08-31 02:25:04 +02:00
|
|
|
#include "../input_driver.h"
|
2016-12-01 20:38:20 +01:00
|
|
|
#include "../../tasks/tasks_internal.h"
|
2014-10-26 01:53:13 +02:00
|
|
|
|
2018-01-20 18:44:35 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
XINPUT_STATE xstate;
|
|
|
|
bool connected;
|
|
|
|
} xinput_joypad_state;
|
|
|
|
|
2019-07-19 12:55:38 +02:00
|
|
|
static xinput_joypad_state g_xinput_states[DEFAULT_MAX_PADS];
|
2018-01-20 18:44:35 +01:00
|
|
|
|
2018-01-21 01:48:28 +01:00
|
|
|
#ifdef _XBOX1
|
2019-07-19 12:55:38 +02:00
|
|
|
static HANDLE gamepads[DEFAULT_MAX_PADS];
|
2018-01-21 01:48:28 +01:00
|
|
|
#endif
|
|
|
|
|
2014-08-30 03:48:51 +02:00
|
|
|
static const char* const XBOX_CONTROLLER_NAMES[4] =
|
|
|
|
{
|
2015-01-05 02:03:17 +01:00
|
|
|
"XInput Controller (User 1)",
|
|
|
|
"XInput Controller (User 2)",
|
|
|
|
"XInput Controller (User 3)",
|
|
|
|
"XInput Controller (User 4)"
|
2014-08-30 03:48:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char *xdk_joypad_name(unsigned pad)
|
|
|
|
{
|
2018-01-20 03:13:55 +01:00
|
|
|
return XBOX_CONTROLLER_NAMES[pad];
|
2014-08-30 03:48:51 +02:00
|
|
|
}
|
|
|
|
|
2015-04-06 02:24:08 +02:00
|
|
|
static void xdk_joypad_autodetect_add(unsigned autoconf_pad)
|
|
|
|
{
|
2019-07-16 15:28:22 +02:00
|
|
|
input_autoconfigure_connect(
|
2016-12-31 07:43:34 +01:00
|
|
|
xdk_joypad_name(autoconf_pad),
|
|
|
|
NULL,
|
|
|
|
xdk_joypad.ident,
|
|
|
|
autoconf_pad,
|
|
|
|
0,
|
2019-07-16 15:28:22 +02:00
|
|
|
0);
|
2015-04-06 02:24:08 +02:00
|
|
|
}
|
|
|
|
|
2015-06-03 18:22:54 +02:00
|
|
|
static bool xdk_joypad_init(void *data)
|
2014-08-30 03:48:51 +02:00
|
|
|
{
|
2014-10-05 17:39:54 +02:00
|
|
|
#ifdef _XBOX1
|
|
|
|
XInitDevices(0, NULL);
|
2018-01-19 07:02:47 +01:00
|
|
|
#else
|
|
|
|
unsigned autoconf_pad;
|
2015-04-06 02:24:08 +02:00
|
|
|
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
|
|
|
xdk_joypad_autodetect_add(autoconf_pad);
|
2018-01-19 07:02:47 +01:00
|
|
|
#endif
|
2014-10-05 17:39:54 +02:00
|
|
|
|
2015-06-03 18:22:54 +02:00
|
|
|
(void)data;
|
2014-08-30 03:48:51 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-01-20 23:38:06 +01:00
|
|
|
#ifndef _XBOX1
|
2018-01-20 19:05:39 +01:00
|
|
|
/* Buttons are provided by XInput as bits of a uint16.
|
|
|
|
* Map from rarch button index (0..10) to a mask to bitwise-& the buttons against.
|
|
|
|
* dpad is handled seperately. */
|
|
|
|
static const uint16_t button_index_to_bitmap_code[] = {
|
|
|
|
XINPUT_GAMEPAD_A,
|
|
|
|
XINPUT_GAMEPAD_B,
|
|
|
|
XINPUT_GAMEPAD_X,
|
|
|
|
XINPUT_GAMEPAD_Y,
|
|
|
|
XINPUT_GAMEPAD_LEFT_SHOULDER,
|
|
|
|
XINPUT_GAMEPAD_RIGHT_SHOULDER,
|
|
|
|
XINPUT_GAMEPAD_START,
|
|
|
|
XINPUT_GAMEPAD_BACK,
|
|
|
|
XINPUT_GAMEPAD_LEFT_THUMB,
|
2018-01-20 23:42:10 +01:00
|
|
|
XINPUT_GAMEPAD_RIGHT_THUMB
|
2018-01-20 19:05:39 +01:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2020-07-19 03:18:12 +02:00
|
|
|
static int16_t xdk_joypad_button_state(XINPUT_GAMEPAD *pad,
|
|
|
|
unsigned port, uint16_t joykey)
|
2014-08-30 03:48:51 +02:00
|
|
|
{
|
2020-07-19 03:18:12 +02:00
|
|
|
uint16_t btn_word = pad->wButtons;
|
|
|
|
unsigned hat_dir = GET_HAT_DIR(joykey);
|
2018-01-20 23:38:06 +01:00
|
|
|
|
2020-07-19 03:18:12 +02:00
|
|
|
if (hat_dir)
|
2018-01-20 19:05:39 +01:00
|
|
|
{
|
2020-07-19 03:18:12 +02:00
|
|
|
switch (hat_dir)
|
2018-01-20 19:05:39 +01:00
|
|
|
{
|
2020-07-19 03:18:12 +02:00
|
|
|
case HAT_UP_MASK:
|
|
|
|
return (btn_word & XINPUT_GAMEPAD_DPAD_UP);
|
|
|
|
case HAT_DOWN_MASK:
|
|
|
|
return (btn_word & XINPUT_GAMEPAD_DPAD_DOWN);
|
|
|
|
case HAT_LEFT_MASK:
|
|
|
|
return (btn_word & XINPUT_GAMEPAD_DPAD_LEFT);
|
|
|
|
case HAT_RIGHT_MASK:
|
|
|
|
return (btn_word & XINPUT_GAMEPAD_DPAD_RIGHT);
|
|
|
|
default:
|
|
|
|
break;
|
2018-01-20 19:05:39 +01:00
|
|
|
}
|
2020-07-19 03:18:12 +02:00
|
|
|
/* hat requested and no hat button down */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-18 19:51:14 +02:00
|
|
|
#ifdef _XBOX1
|
2020-07-19 03:18:12 +02:00
|
|
|
switch (joykey)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_A:
|
|
|
|
return (pad->bAnalogButtons[XINPUT_GAMEPAD_B] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_B:
|
|
|
|
return (pad->bAnalogButtons[XINPUT_GAMEPAD_A] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_Y:
|
|
|
|
return (pad->bAnalogButtons[XINPUT_GAMEPAD_X] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_X:
|
|
|
|
return (pad->bAnalogButtons[XINPUT_GAMEPAD_Y] > XINPUT_GAMEPAD_MAX_CROSSTALK)
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_START:
|
|
|
|
return (pad->wButtons & XINPUT_GAMEPAD_START);
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_SELECT:
|
|
|
|
return (pad->wButtons & XINPUT_GAMEPAD_BACK);
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_L3:
|
|
|
|
return (pad->wButtons & XINPUT_GAMEPAD_LEFT_THUMB);
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_R3:
|
|
|
|
return (pad->wButtons & XINPUT_GAMEPAD_RIGHT_THUMB);
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_L2:
|
|
|
|
return (pad->bAnalogButtons[XINPUT_GAMEPAD_WHITE] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_R2:
|
|
|
|
return (pad->bAnalogButtons[XINPUT_GAMEPAD_BLACK] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_L:
|
|
|
|
return (pad->bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
|
|
|
case RETRO_DEVICE_ID_JOYPAD_R:
|
|
|
|
return (pad->bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER] > XINPUT_GAMEPAD_MAX_CROSSTALK);
|
|
|
|
default:
|
2020-07-18 19:51:14 +02:00
|
|
|
break;
|
2020-07-19 03:18:12 +02:00
|
|
|
}
|
2018-01-20 23:38:06 +01:00
|
|
|
#else
|
2020-07-19 03:18:12 +02:00
|
|
|
if (joykey < 10)
|
|
|
|
return (btn_word & button_index_to_bitmap_code[joykey]);
|
2018-01-20 19:34:01 +01:00
|
|
|
#endif
|
2020-07-18 18:07:57 +02:00
|
|
|
}
|
2020-07-19 03:18:12 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2018-01-20 19:34:01 +01:00
|
|
|
|
2020-07-19 03:18:12 +02:00
|
|
|
static int16_t xdk_joypad_button(unsigned port, uint16_t joykey)
|
|
|
|
{
|
|
|
|
XINPUT_GAMEPAD *pad = &(g_xinput_states[port].xstate.Gamepad);
|
|
|
|
if (port >= DEFAULT_MAX_PADS)
|
|
|
|
return 0;
|
|
|
|
return xdk_joypad_button_state(pad, port, joykey);
|
2014-08-30 03:48:51 +02:00
|
|
|
}
|
|
|
|
|
2020-07-19 03:18:12 +02:00
|
|
|
static int16_t xdk_joypad_axis_state(XINPUT_GAMEPAD *pad,
|
|
|
|
unsigned port, uint32_t joyaxis)
|
2014-08-30 03:48:51 +02:00
|
|
|
{
|
2018-01-20 18:54:21 +01:00
|
|
|
int val = 0;
|
|
|
|
int axis = -1;
|
|
|
|
bool is_neg = false;
|
|
|
|
bool is_pos = false;
|
2020-07-19 18:51:05 +02:00
|
|
|
|
2018-01-20 18:55:28 +01:00
|
|
|
if (AXIS_NEG_GET(joyaxis) <= 3)
|
2014-08-30 03:48:51 +02:00
|
|
|
{
|
2020-07-19 18:51:05 +02:00
|
|
|
axis = AXIS_NEG_GET(joyaxis);
|
2014-08-30 03:48:51 +02:00
|
|
|
is_neg = true;
|
|
|
|
}
|
2018-01-20 18:55:28 +01:00
|
|
|
else if (AXIS_POS_GET(joyaxis) <= 5)
|
2014-08-30 03:48:51 +02:00
|
|
|
{
|
2020-07-19 18:51:05 +02:00
|
|
|
axis = AXIS_POS_GET(joyaxis);
|
2014-08-30 03:48:51 +02:00
|
|
|
is_pos = true;
|
|
|
|
}
|
2020-07-19 18:51:05 +02:00
|
|
|
else
|
|
|
|
return 0;
|
2018-01-20 18:54:21 +01:00
|
|
|
|
2014-08-30 03:48:51 +02:00
|
|
|
switch (axis)
|
|
|
|
{
|
2014-09-09 18:15:17 +02:00
|
|
|
case 0:
|
2018-01-20 18:54:21 +01:00
|
|
|
val = pad->sThumbLX;
|
2014-09-09 18:15:17 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-01-20 18:54:21 +01:00
|
|
|
val = pad->sThumbLY;
|
2014-09-09 18:15:17 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2018-01-20 18:54:21 +01:00
|
|
|
val = pad->sThumbRX;
|
2014-09-09 18:15:17 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2018-01-20 18:54:21 +01:00
|
|
|
val = pad->sThumbRY;
|
2014-09-09 18:15:17 +02:00
|
|
|
break;
|
2018-01-20 19:57:14 +01:00
|
|
|
case 4:
|
|
|
|
#ifdef _XBOX360
|
|
|
|
val = pad->bLeftTrigger * 32767 / 255;
|
|
|
|
#endif
|
|
|
|
break; /* map 0..255 to 0..32767 */
|
|
|
|
case 5:
|
|
|
|
#ifdef _XBOX360
|
|
|
|
val = pad->bRightTrigger * 32767 / 255;
|
|
|
|
#endif
|
|
|
|
break;
|
2014-08-30 03:48:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_neg && val > 0)
|
2020-07-19 18:51:05 +02:00
|
|
|
return 0;
|
2014-08-30 03:48:51 +02:00
|
|
|
else if (is_pos && val < 0)
|
2020-07-19 18:51:05 +02:00
|
|
|
return 0;
|
2018-01-20 18:54:21 +01:00
|
|
|
/* Clamp to avoid warnings */
|
2020-07-19 18:51:05 +02:00
|
|
|
else if (val == -32768)
|
|
|
|
return -32767;
|
2014-08-30 03:48:51 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2020-07-19 03:18:12 +02:00
|
|
|
static int16_t xdk_joypad_axis(unsigned port, uint32_t joyaxis)
|
|
|
|
{
|
|
|
|
XINPUT_GAMEPAD *pad = &(g_xinput_states[port].xstate.Gamepad);
|
|
|
|
if (port >= DEFAULT_MAX_PADS)
|
|
|
|
return 0;
|
|
|
|
return xdk_joypad_axis_state(pad, port, joyaxis);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int16_t xdk_joypad_state(
|
|
|
|
rarch_joypad_info_t *joypad_info,
|
|
|
|
const struct retro_keybind *binds,
|
|
|
|
unsigned port)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
int16_t ret = 0;
|
|
|
|
XINPUT_GAMEPAD *pad = &(g_xinput_states[port].xstate.Gamepad);
|
|
|
|
|
|
|
|
if (port >= DEFAULT_MAX_PADS)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
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, port, (uint16_t)joykey))
|
|
|
|
ret |= ( 1 << i);
|
|
|
|
else if (joyaxis != AXIS_NONE &&
|
|
|
|
((float)abs(xdk_joypad_axis_state(pad, port, joyaxis))
|
|
|
|
/ 0x8000) > joypad_info->axis_threshold)
|
|
|
|
ret |= (1 << i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-08-30 03:48:51 +02:00
|
|
|
static void xdk_joypad_poll(void)
|
|
|
|
{
|
2014-10-21 05:44:09 +02:00
|
|
|
unsigned port;
|
2018-01-19 07:02:47 +01:00
|
|
|
#if defined(_XBOX1)
|
2018-01-19 21:24:28 +01:00
|
|
|
DWORD dwInsertions, dwRemovals;
|
2014-10-05 17:39:54 +02:00
|
|
|
|
2018-01-03 14:13:29 +01:00
|
|
|
#ifdef __cplusplus
|
2014-10-05 17:39:54 +02:00
|
|
|
XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD,
|
|
|
|
reinterpret_cast<PDWORD>(&dwInsertions),
|
|
|
|
reinterpret_cast<PDWORD>(&dwRemovals));
|
2018-01-03 14:13:29 +01:00
|
|
|
#else
|
|
|
|
XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD,
|
|
|
|
(PDWORD)&dwInsertions,
|
|
|
|
(PDWORD)&dwRemovals);
|
|
|
|
#endif
|
2014-10-05 17:39:54 +02:00
|
|
|
#endif
|
|
|
|
|
2019-07-19 12:55:38 +02:00
|
|
|
for (port = 0; port < DEFAULT_MAX_PADS; port++)
|
2014-10-05 17:39:54 +02:00
|
|
|
{
|
2018-01-19 21:24:28 +01:00
|
|
|
#if defined(_XBOX1)
|
|
|
|
bool device_removed = false;
|
|
|
|
bool device_inserted = false;
|
2014-10-05 17:39:54 +02:00
|
|
|
|
2018-01-19 21:24:28 +01:00
|
|
|
/* handle inserted devices. */
|
2014-10-05 17:39:54 +02:00
|
|
|
/* handle removed devices. */
|
2018-01-19 21:24:28 +01:00
|
|
|
if (dwRemovals & (1 << port))
|
|
|
|
device_removed = true;
|
|
|
|
if (dwInsertions & (1 << port))
|
|
|
|
device_inserted = true;
|
2014-10-05 17:39:54 +02:00
|
|
|
|
2018-01-19 21:24:28 +01:00
|
|
|
if (device_removed)
|
2014-10-05 17:39:54 +02:00
|
|
|
{
|
2017-11-28 10:04:34 +00:00
|
|
|
/* if the controller was removed after
|
2014-10-05 17:39:54 +02:00
|
|
|
* XGetDeviceChanges but before
|
|
|
|
* XInputOpen, the device handle will be NULL. */
|
2018-01-21 01:48:28 +01:00
|
|
|
if (gamepads[port])
|
|
|
|
XInputClose(gamepads[port]);
|
2014-10-05 17:39:54 +02:00
|
|
|
|
2018-01-21 01:48:28 +01:00
|
|
|
gamepads[port] = 0;
|
2015-04-06 02:30:27 +02:00
|
|
|
|
2016-12-01 18:52:34 +01:00
|
|
|
input_autoconfigure_disconnect(port, xdk_joypad.ident);
|
2014-10-05 17:39:54 +02:00
|
|
|
}
|
|
|
|
|
2018-01-19 21:24:28 +01:00
|
|
|
if (device_inserted)
|
2014-10-05 17:39:54 +02:00
|
|
|
{
|
|
|
|
XINPUT_POLLING_PARAMETERS m_pollingParameters;
|
2018-01-19 21:24:28 +01:00
|
|
|
|
|
|
|
m_pollingParameters.fAutoPoll = FALSE;
|
|
|
|
m_pollingParameters.fInterruptOut = TRUE;
|
|
|
|
m_pollingParameters.bInputInterval = 8;
|
2014-10-05 17:39:54 +02:00
|
|
|
m_pollingParameters.bOutputInterval = 8;
|
2018-01-19 21:24:28 +01:00
|
|
|
|
2018-01-21 01:48:28 +01:00
|
|
|
gamepads[port] = XInputOpen(
|
2018-01-19 21:24:28 +01:00
|
|
|
XDEVICE_TYPE_GAMEPAD, port,
|
2018-01-19 06:56:44 +01:00
|
|
|
XDEVICE_NO_SLOT, &m_pollingParameters);
|
2017-11-28 10:04:34 +00:00
|
|
|
|
2015-04-06 02:24:08 +02:00
|
|
|
xdk_joypad_autodetect_add(port);
|
2014-10-05 17:39:54 +02:00
|
|
|
}
|
|
|
|
|
2018-01-21 01:48:28 +01:00
|
|
|
if (!gamepads[port])
|
2014-10-05 17:39:54 +02:00
|
|
|
continue;
|
|
|
|
|
2017-11-28 10:04:34 +00:00
|
|
|
/* if the controller is removed after
|
2014-10-05 17:39:54 +02:00
|
|
|
* XGetDeviceChanges but before XInputOpen,
|
|
|
|
* the device handle will be NULL. */
|
2018-01-21 01:48:28 +01:00
|
|
|
if (XInputPoll(gamepads[port]) != ERROR_SUCCESS)
|
2014-10-05 17:39:54 +02:00
|
|
|
continue;
|
2018-01-20 17:59:59 +01:00
|
|
|
#endif
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2018-01-20 18:44:35 +01:00
|
|
|
memset(&g_xinput_states[port], 0, sizeof(xinput_joypad_state));
|
2014-10-05 17:39:54 +02:00
|
|
|
|
2018-01-20 18:44:35 +01:00
|
|
|
g_xinput_states[port].connected = !
|
|
|
|
(XInputGetState(
|
2018-01-20 23:42:10 +01:00
|
|
|
#ifdef _XBOX1
|
2018-01-21 01:48:28 +01:00
|
|
|
gamepads[port]
|
2018-01-20 17:59:59 +01:00
|
|
|
#else
|
|
|
|
port
|
2014-10-05 17:39:54 +02:00
|
|
|
#endif
|
2018-01-20 18:46:13 +01:00
|
|
|
, &g_xinput_states[port].xstate) == ERROR_DEVICE_NOT_CONNECTED);
|
2014-10-05 17:39:54 +02:00
|
|
|
}
|
2014-08-30 03:48:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool xdk_joypad_query_pad(unsigned pad)
|
|
|
|
{
|
2018-01-20 18:44:35 +01:00
|
|
|
return pad < MAX_USERS && g_xinput_states[pad].connected;
|
2014-08-30 03:48:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void xdk_joypad_destroy(void)
|
|
|
|
{
|
2018-01-19 21:24:28 +01:00
|
|
|
unsigned i;
|
|
|
|
|
2019-07-19 12:55:38 +02:00
|
|
|
for (i = 0; i < DEFAULT_MAX_PADS; i++)
|
2018-01-19 21:24:28 +01:00
|
|
|
{
|
2018-01-20 18:50:24 +01:00
|
|
|
memset(&g_xinput_states[i], 0, sizeof(xinput_joypad_state));
|
2018-01-19 21:24:28 +01:00
|
|
|
#if defined(_XBOX1)
|
2018-01-21 01:48:28 +01:00
|
|
|
if (gamepads[i])
|
|
|
|
XInputClose(gamepads[i]);
|
|
|
|
gamepads[i] = 0;
|
2018-01-19 21:24:28 +01:00
|
|
|
#endif
|
|
|
|
}
|
2014-08-30 03:48:51 +02:00
|
|
|
}
|
|
|
|
|
2015-04-14 16:37:59 +02:00
|
|
|
input_device_driver_t xdk_joypad = {
|
2014-08-30 03:48:51 +02:00
|
|
|
xdk_joypad_init,
|
|
|
|
xdk_joypad_query_pad,
|
|
|
|
xdk_joypad_destroy,
|
|
|
|
xdk_joypad_button,
|
2020-07-19 03:18:12 +02:00
|
|
|
xdk_joypad_state,
|
2018-01-20 18:47:39 +01:00
|
|
|
NULL,
|
2014-08-30 03:48:51 +02:00
|
|
|
xdk_joypad_axis,
|
|
|
|
xdk_joypad_poll,
|
|
|
|
NULL,
|
|
|
|
xdk_joypad_name,
|
|
|
|
"xdk",
|
|
|
|
};
|