2012-07-08 19:42:26 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2012 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#ifdef _XBOX
|
|
|
|
#include <xtl.h>
|
|
|
|
#endif
|
|
|
|
|
2012-07-27 13:46:15 +00:00
|
|
|
#define MAX_PADS 4
|
|
|
|
|
2012-07-08 19:42:26 +00:00
|
|
|
#include "../driver.h"
|
|
|
|
#include "../general.h"
|
|
|
|
#include "../libretro.h"
|
2012-07-31 18:56:05 +00:00
|
|
|
#include "xdk_xinput_input.h"
|
2012-07-08 19:42:26 +00:00
|
|
|
|
2012-07-31 18:09:17 +00:00
|
|
|
static uint64_t state[MAX_PADS];
|
2012-08-17 15:43:23 +00:00
|
|
|
unsigned pads_connected;
|
2012-07-31 18:56:05 +00:00
|
|
|
|
|
|
|
#ifdef _XBOX1
|
2012-07-27 13:46:15 +00:00
|
|
|
HANDLE gamepads[MAX_PADS];
|
2012-07-13 21:34:46 +00:00
|
|
|
DWORD dwDeviceMask;
|
2012-07-27 13:46:15 +00:00
|
|
|
bool bInserted[MAX_PADS];
|
|
|
|
bool bRemoved[MAX_PADS];
|
2012-07-31 18:56:05 +00:00
|
|
|
#endif
|
2012-07-08 19:42:26 +00:00
|
|
|
|
2012-07-25 17:35:21 +00:00
|
|
|
const struct platform_bind platform_keys[] = {
|
|
|
|
{ XINPUT1_GAMEPAD_B, "B button" },
|
|
|
|
{ XINPUT1_GAMEPAD_A, "A button" },
|
|
|
|
{ XINPUT1_GAMEPAD_Y, "Y button" },
|
|
|
|
{ XINPUT1_GAMEPAD_X, "X button" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_UP, "D-Pad Up" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_DOWN, "D-Pad Down" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_LEFT, "D-Pad Left" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_RIGHT, "D-Pad Right" },
|
|
|
|
{ XINPUT1_GAMEPAD_BACK, "Back button" },
|
|
|
|
{ XINPUT1_GAMEPAD_START, "Start button" },
|
2012-07-31 18:56:05 +00:00
|
|
|
#if defined(_XBOX1)
|
2012-07-25 17:35:21 +00:00
|
|
|
{ XINPUT1_GAMEPAD_WHITE, "White button" },
|
2012-07-31 18:56:05 +00:00
|
|
|
#elif defined(_XBOX360)
|
|
|
|
{ XINPUT1_GAMEPAD_WHITE, "Right shoulder" },
|
|
|
|
#endif
|
2012-07-25 17:35:21 +00:00
|
|
|
{ XINPUT1_GAMEPAD_LEFT_TRIGGER, "Left Trigger" },
|
|
|
|
{ XINPUT1_GAMEPAD_LEFT_THUMB, "Left Thumb" },
|
2012-07-31 18:56:05 +00:00
|
|
|
#if defined(_XBOX1)
|
2012-07-25 17:35:21 +00:00
|
|
|
{ XINPUT1_GAMEPAD_BLACK, "Black button" },
|
2012-07-31 18:56:05 +00:00
|
|
|
#elif defined(_XBOX360)
|
|
|
|
{ XINPUT1_GAMEPAD_BLACK, "Left shoulder" },
|
|
|
|
#endif
|
2012-07-25 17:35:21 +00:00
|
|
|
{ XINPUT1_GAMEPAD_RIGHT_TRIGGER, "Right Trigger" },
|
|
|
|
{ XINPUT1_GAMEPAD_RIGHT_THUMB, "Right Thumb" },
|
|
|
|
{ XINPUT1_GAMEPAD_LSTICK_LEFT_MASK, "LStick Left" },
|
|
|
|
{ XINPUT1_GAMEPAD_LSTICK_RIGHT_MASK, "LStick Right" },
|
|
|
|
{ XINPUT1_GAMEPAD_LSTICK_UP_MASK, "LStick Up" },
|
|
|
|
{ XINPUT1_GAMEPAD_LSTICK_DOWN_MASK, "LStick Down" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_LEFT | XINPUT1_GAMEPAD_LSTICK_LEFT_MASK, "LStick D-Pad Left" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_RIGHT | XINPUT1_GAMEPAD_LSTICK_RIGHT_MASK, "LStick D-Pad Right" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_UP | XINPUT1_GAMEPAD_LSTICK_UP_MASK, "LStick D-Pad Up" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_DOWN | XINPUT1_GAMEPAD_LSTICK_DOWN_MASK, "LStick D-Pad Down" },
|
|
|
|
{ XINPUT1_GAMEPAD_RSTICK_LEFT_MASK, "RStick Left" },
|
|
|
|
{ XINPUT1_GAMEPAD_RSTICK_RIGHT_MASK, "RStick Right" },
|
|
|
|
{ XINPUT1_GAMEPAD_RSTICK_UP_MASK, "RStick Up" },
|
|
|
|
{ XINPUT1_GAMEPAD_RSTICK_DOWN_MASK, "RStick Down" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_LEFT | XINPUT1_GAMEPAD_RSTICK_LEFT_MASK, "RStick D-Pad Left" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_RIGHT | XINPUT1_GAMEPAD_RSTICK_RIGHT_MASK, "RStick D-Pad Right" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_UP | XINPUT1_GAMEPAD_RSTICK_UP_MASK, "RStick D-Pad Up" },
|
|
|
|
{ XINPUT1_GAMEPAD_DPAD_DOWN | XINPUT1_GAMEPAD_RSTICK_DOWN_MASK, "RStick D-Pad Down" },
|
|
|
|
};
|
|
|
|
|
|
|
|
const unsigned int platform_keys_size = sizeof(platform_keys);
|
|
|
|
|
2012-12-02 05:01:39 +00:00
|
|
|
static void xdk_input_poll(void *data)
|
2012-07-08 19:42:26 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
2012-07-31 18:56:05 +00:00
|
|
|
|
|
|
|
pads_connected = 0;
|
|
|
|
|
|
|
|
#if defined(_XBOX1)
|
2012-07-13 21:34:46 +00:00
|
|
|
unsigned int dwInsertions, dwRemovals;
|
|
|
|
|
|
|
|
XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD, reinterpret_cast<PDWORD>(&dwInsertions), reinterpret_cast<PDWORD>(&dwRemovals));
|
2012-07-08 19:42:26 +00:00
|
|
|
|
2012-07-27 13:46:15 +00:00
|
|
|
for (unsigned i = 0; i < MAX_PADS; i++)
|
2012-07-08 19:42:26 +00:00
|
|
|
{
|
2012-07-27 13:46:15 +00:00
|
|
|
XINPUT_CAPABILITIES caps[MAX_PADS];
|
2012-07-25 21:24:38 +00:00
|
|
|
(void)caps;
|
2012-07-31 18:09:17 +00:00
|
|
|
state[i] = 0;
|
2012-07-13 21:34:46 +00:00
|
|
|
// handle removed devices
|
|
|
|
bRemoved[i] = (dwRemovals & (1<<i)) ? true : false;
|
2012-07-15 15:40:12 +00:00
|
|
|
|
|
|
|
if(bRemoved[i])
|
|
|
|
{
|
2012-07-13 21:34:46 +00:00
|
|
|
// if the controller was removed after XGetDeviceChanges but before
|
|
|
|
// XInputOpen, the device handle will be NULL
|
|
|
|
if(gamepads[i])
|
|
|
|
XInputClose(gamepads[i]);
|
|
|
|
|
|
|
|
gamepads[i] = NULL;
|
2012-07-08 19:42:26 +00:00
|
|
|
}
|
2012-07-13 21:34:46 +00:00
|
|
|
|
2012-07-15 15:40:12 +00:00
|
|
|
// handle inserted devices
|
|
|
|
bInserted[i] = (dwInsertions & (1<<i)) ? true : false;
|
2012-07-14 04:15:03 +00:00
|
|
|
|
2012-07-15 15:40:12 +00:00
|
|
|
if(bInserted[i])
|
|
|
|
{
|
|
|
|
XINPUT_POLLING_PARAMETERS m_pollingParameters;
|
2012-07-14 04:15:03 +00:00
|
|
|
m_pollingParameters.fAutoPoll = TRUE;
|
|
|
|
m_pollingParameters.fInterruptOut = TRUE;
|
|
|
|
m_pollingParameters.bInputInterval = 8;
|
|
|
|
m_pollingParameters.bOutputInterval = 8;
|
|
|
|
gamepads[i] = XInputOpen(XDEVICE_TYPE_GAMEPAD, i, XDEVICE_NO_SLOT, NULL);
|
2012-07-15 15:40:12 +00:00
|
|
|
}
|
2012-07-13 21:34:46 +00:00
|
|
|
|
2012-07-15 15:40:12 +00:00
|
|
|
if (gamepads[i])
|
|
|
|
{
|
2012-07-13 21:34:46 +00:00
|
|
|
unsigned long retval;
|
|
|
|
|
|
|
|
// if the controller is removed after XGetDeviceChanges but before
|
|
|
|
// XInputOpen, the device handle will be NULL
|
2012-07-31 18:09:17 +00:00
|
|
|
XINPUT_STATE state_tmp;
|
|
|
|
retval = XInputGetState(gamepads[i], &state_tmp);
|
2012-07-24 17:58:49 +00:00
|
|
|
if(retval == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
pads_connected++;
|
2012-07-31 18:09:17 +00:00
|
|
|
state[i] |= ((state_tmp.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_B]) ? XINPUT1_GAMEPAD_B : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_A]) ? XINPUT1_GAMEPAD_A : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_Y]) ? XINPUT1_GAMEPAD_Y : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_X]) ? XINPUT1_GAMEPAD_X : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) ? XINPUT1_GAMEPAD_DPAD_LEFT : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) ? XINPUT1_GAMEPAD_DPAD_RIGHT : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) ? XINPUT1_GAMEPAD_DPAD_UP : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) ? XINPUT1_GAMEPAD_DPAD_DOWN : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbLX < -DEADZONE) ? XINPUT1_GAMEPAD_LSTICK_LEFT_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbLX > DEADZONE) ? XINPUT1_GAMEPAD_LSTICK_RIGHT_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbLY > DEADZONE) ? XINPUT1_GAMEPAD_LSTICK_UP_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbLY < -DEADZONE) ? XINPUT1_GAMEPAD_LSTICK_DOWN_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbRX < -DEADZONE) ? XINPUT1_GAMEPAD_RSTICK_LEFT_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbRX > DEADZONE) ? XINPUT1_GAMEPAD_RSTICK_RIGHT_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbRY > DEADZONE) ? XINPUT1_GAMEPAD_RSTICK_UP_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbRY < -DEADZONE) ? XINPUT1_GAMEPAD_RSTICK_DOWN_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_START) ? XINPUT1_GAMEPAD_START : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_BACK) ? XINPUT1_GAMEPAD_BACK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER]) ? XINPUT1_GAMEPAD_LEFT_TRIGGER : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) ? XINPUT1_GAMEPAD_RIGHT_TRIGGER : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_WHITE]) ? XINPUT1_GAMEPAD_WHITE : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_BLACK]) ? XINPUT1_GAMEPAD_BLACK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) ? XINPUT1_GAMEPAD_LEFT_THUMB : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) ? XINPUT1_GAMEPAD_RIGHT_THUMB : 0);
|
2012-07-24 17:58:49 +00:00
|
|
|
}
|
2012-07-14 04:15:03 +00:00
|
|
|
}
|
2012-07-08 19:42:26 +00:00
|
|
|
}
|
2012-07-31 18:56:05 +00:00
|
|
|
#elif defined(_XBOX360)
|
|
|
|
for (unsigned i = 0; i < MAX_PADS; i++)
|
|
|
|
{
|
|
|
|
XINPUT_STATE state_tmp;
|
|
|
|
unsigned long retval;
|
|
|
|
{
|
|
|
|
retval = XInputGetState(i, &state_tmp);
|
|
|
|
pads_connected += (retval == ERROR_DEVICE_NOT_CONNECTED) ? 0 : 1;
|
|
|
|
state[i] = 0;
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_B) ? XINPUT1_GAMEPAD_B : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_A) ? XINPUT1_GAMEPAD_A : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_Y) ? XINPUT1_GAMEPAD_Y : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_X) ? XINPUT1_GAMEPAD_X : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) ? XINPUT1_GAMEPAD_DPAD_LEFT : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) ? XINPUT1_GAMEPAD_DPAD_RIGHT : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) ? XINPUT1_GAMEPAD_DPAD_UP : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) ? XINPUT1_GAMEPAD_DPAD_DOWN : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbLX < -DEADZONE) ? XINPUT1_GAMEPAD_LSTICK_LEFT_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbLX > DEADZONE) ? XINPUT1_GAMEPAD_LSTICK_RIGHT_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbLY > DEADZONE) ? XINPUT1_GAMEPAD_LSTICK_UP_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbLY < -DEADZONE) ? XINPUT1_GAMEPAD_LSTICK_DOWN_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbRX < -DEADZONE) ? XINPUT1_GAMEPAD_RSTICK_LEFT_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbRX > DEADZONE) ? XINPUT1_GAMEPAD_RSTICK_RIGHT_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbRY > DEADZONE) ? XINPUT1_GAMEPAD_RSTICK_UP_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.sThumbRY < -DEADZONE) ? XINPUT1_GAMEPAD_RSTICK_DOWN_MASK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_START) ? XINPUT1_GAMEPAD_START : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_BACK) ? XINPUT1_GAMEPAD_BACK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.bLeftTrigger > 128) ? XINPUT1_GAMEPAD_LEFT_TRIGGER : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.bRightTrigger > 128) ? XINPUT1_GAMEPAD_RIGHT_TRIGGER : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) ? XINPUT1_GAMEPAD_WHITE : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) ? XINPUT1_GAMEPAD_BLACK : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) ? XINPUT1_GAMEPAD_LEFT_THUMB : 0);
|
|
|
|
state[i] |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) ? XINPUT1_GAMEPAD_RIGHT_THUMB : 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2012-12-15 00:14:21 +00:00
|
|
|
|
|
|
|
g_extern.lifecycle_state &= ~((1ULL << RARCH_QUIT_KEY) | (1ULL << RARCH_RMENU_TOGGLE) | (1ULL << RARCH_RMENU_QUICKMENU_TOGGLE));
|
|
|
|
|
|
|
|
if(IS_TIMER_EXPIRED(0))
|
|
|
|
{
|
|
|
|
if((state[0] & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (state[0] & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3)))
|
|
|
|
{
|
|
|
|
g_extern.lifecycle_state |= (1ULL << RARCH_RMENU_TOGGLE);
|
|
|
|
g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
|
|
|
|
}
|
|
|
|
if(!(state[0] & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (state[0] & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3)))
|
|
|
|
{
|
|
|
|
g_extern.lifecycle_state |= (1ULL << RARCH_RMENU_QUICKMENU_TOGGLE);
|
|
|
|
g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
|
|
|
|
}
|
|
|
|
}
|
2012-07-08 19:42:26 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 05:01:39 +00:00
|
|
|
static int16_t xdk_input_state(void *data, const struct retro_keybind **binds,
|
2012-07-08 19:42:26 +00:00
|
|
|
unsigned port, unsigned device,
|
|
|
|
unsigned index, unsigned id)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
unsigned player = port;
|
2012-07-24 17:58:49 +00:00
|
|
|
uint64_t button = binds[player][id].joykey;
|
2012-07-14 15:47:30 +00:00
|
|
|
|
2012-07-31 18:09:17 +00:00
|
|
|
return (state[player] & button) ? 1 : 0;
|
2012-07-08 19:42:26 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 05:01:39 +00:00
|
|
|
static void xdk_input_free_input(void *data)
|
2012-07-08 19:42:26 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
}
|
|
|
|
|
2012-12-02 05:01:39 +00:00
|
|
|
static void xdk_set_default_keybind_lut(unsigned device, unsigned port)
|
2012-07-27 13:46:15 +00:00
|
|
|
{
|
2012-07-27 23:37:15 +00:00
|
|
|
(void)device;
|
2012-07-28 00:27:41 +00:00
|
|
|
(void)port;
|
2012-07-27 23:37:15 +00:00
|
|
|
|
2012-07-27 13:46:15 +00:00
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_B] = platform_keys[XDK_DEVICE_ID_JOYPAD_A].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_Y] = platform_keys[XDK_DEVICE_ID_JOYPAD_X].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_SELECT] = platform_keys[XDK_DEVICE_ID_JOYPAD_BACK].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_START] = platform_keys[XDK_DEVICE_ID_JOYPAD_START].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_UP] = platform_keys[XDK_DEVICE_ID_JOYPAD_UP].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_DOWN] = platform_keys[XDK_DEVICE_ID_JOYPAD_DOWN].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_LEFT] = platform_keys[XDK_DEVICE_ID_JOYPAD_LEFT].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_RIGHT] = platform_keys[XDK_DEVICE_ID_JOYPAD_RIGHT].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_A] = platform_keys[XDK_DEVICE_ID_JOYPAD_B].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_X] = platform_keys[XDK_DEVICE_ID_JOYPAD_Y].joykey;
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_L] = platform_keys[XDK_DEVICE_ID_JOYPAD_LEFT_TRIGGER].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_R] = platform_keys[XDK_DEVICE_ID_JOYPAD_RIGHT_TRIGGER].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_L2] = platform_keys[XDK_DEVICE_ID_JOYPAD_LB].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_R2] = platform_keys[XDK_DEVICE_ID_JOYPAD_RB].joykey;
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_L] = platform_keys[XDK_DEVICE_ID_JOYPAD_LB].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_R] = platform_keys[XDK_DEVICE_ID_JOYPAD_RB].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_L2] = platform_keys[XDK_DEVICE_ID_JOYPAD_LEFT_TRIGGER].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_R2] = platform_keys[XDK_DEVICE_ID_JOYPAD_RIGHT_TRIGGER].joykey;
|
|
|
|
#endif
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_L3] = platform_keys[XDK_DEVICE_ID_LSTICK_THUMB].joykey;
|
|
|
|
rarch_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_R3] = platform_keys[XDK_DEVICE_ID_RSTICK_THUMB].joykey;
|
|
|
|
}
|
|
|
|
|
2012-12-02 05:01:39 +00:00
|
|
|
static void xdk_input_set_analog_dpad_mapping(unsigned device, unsigned map_dpad_enum, unsigned controller_id)
|
2012-07-27 13:46:15 +00:00
|
|
|
{
|
2012-07-27 23:37:15 +00:00
|
|
|
(void)device;
|
2012-07-29 15:50:33 +00:00
|
|
|
|
|
|
|
switch(map_dpad_enum)
|
|
|
|
{
|
|
|
|
case DPAD_EMULATION_NONE:
|
2012-08-22 11:50:07 +00:00
|
|
|
g_settings.input.dpad_emulation[controller_id] = DPAD_EMULATION_NONE;
|
2012-07-29 15:50:33 +00:00
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = platform_keys[XDK_DEVICE_ID_JOYPAD_UP].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = platform_keys[XDK_DEVICE_ID_JOYPAD_DOWN].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = platform_keys[XDK_DEVICE_ID_JOYPAD_LEFT].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = platform_keys[XDK_DEVICE_ID_JOYPAD_RIGHT].joykey;
|
|
|
|
break;
|
|
|
|
case DPAD_EMULATION_LSTICK:
|
2012-08-22 11:50:07 +00:00
|
|
|
g_settings.input.dpad_emulation[controller_id] = DPAD_EMULATION_LSTICK;
|
2012-07-29 15:50:33 +00:00
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = platform_keys[XDK_DEVICE_ID_LSTICK_UP_DPAD].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = platform_keys[XDK_DEVICE_ID_LSTICK_DOWN_DPAD].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = platform_keys[XDK_DEVICE_ID_LSTICK_LEFT_DPAD].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = platform_keys[XDK_DEVICE_ID_LSTICK_RIGHT_DPAD].joykey;
|
|
|
|
break;
|
|
|
|
case DPAD_EMULATION_RSTICK:
|
2012-08-22 11:50:07 +00:00
|
|
|
g_settings.input.dpad_emulation[controller_id] = DPAD_EMULATION_RSTICK;
|
2012-07-29 15:50:33 +00:00
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = platform_keys[XDK_DEVICE_ID_RSTICK_UP_DPAD].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = platform_keys[XDK_DEVICE_ID_RSTICK_DOWN_DPAD].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = platform_keys[XDK_DEVICE_ID_RSTICK_LEFT_DPAD].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = platform_keys[XDK_DEVICE_ID_RSTICK_RIGHT_DPAD].joykey;
|
|
|
|
break;
|
|
|
|
}
|
2012-07-27 13:46:15 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 05:01:39 +00:00
|
|
|
static void *xdk_input_init(void)
|
2012-07-08 19:42:26 +00:00
|
|
|
{
|
2012-07-31 18:56:05 +00:00
|
|
|
#ifdef _XBOX1
|
2012-07-13 21:34:46 +00:00
|
|
|
XInitDevices(0, NULL);
|
|
|
|
|
|
|
|
dwDeviceMask = XGetDevices(XDEVICE_TYPE_GAMEPAD);
|
|
|
|
|
|
|
|
//Check the device status
|
|
|
|
switch(XGetDeviceEnumerationStatus())
|
|
|
|
{
|
|
|
|
case XDEVICE_ENUMERATION_IDLE:
|
2012-07-15 15:40:12 +00:00
|
|
|
RARCH_LOG("Input state status: XDEVICE_ENUMERATION_IDLE\n");
|
2012-07-15 16:04:54 +00:00
|
|
|
break;
|
2012-07-15 15:40:12 +00:00
|
|
|
case XDEVICE_ENUMERATION_BUSY:
|
2012-07-15 16:04:54 +00:00
|
|
|
RARCH_LOG("Input state status: XDEVICE_ENUMERATION_BUSY\n");
|
|
|
|
break;
|
2012-07-15 15:40:12 +00:00
|
|
|
}
|
2012-07-13 21:34:46 +00:00
|
|
|
|
2012-07-15 15:40:12 +00:00
|
|
|
while(XGetDeviceEnumerationStatus() == XDEVICE_ENUMERATION_BUSY) {}
|
2012-07-31 18:56:05 +00:00
|
|
|
#endif
|
2012-07-08 19:42:26 +00:00
|
|
|
|
|
|
|
return (void*)-1;
|
|
|
|
}
|
|
|
|
|
2012-07-27 23:37:15 +00:00
|
|
|
#define STUB_DEVICE 0
|
|
|
|
|
2012-12-02 05:01:39 +00:00
|
|
|
static void xdk_input_post_init(void)
|
2012-07-27 13:46:15 +00:00
|
|
|
{
|
|
|
|
for(unsigned i = 0; i < MAX_PADS; i++)
|
2012-12-02 05:01:39 +00:00
|
|
|
xdk_input_set_analog_dpad_mapping(STUB_DEVICE, g_settings.input.dpad_emulation[i], i);
|
2012-07-27 13:46:15 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 05:01:39 +00:00
|
|
|
static bool xdk_input_key_pressed(void *data, int key)
|
2012-07-08 19:42:26 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
2012-12-15 00:14:21 +00:00
|
|
|
|
|
|
|
if(g_extern.lifecycle_state & (1ULL << key))
|
|
|
|
return true;
|
2012-07-31 15:56:32 +00:00
|
|
|
|
|
|
|
switch(key)
|
|
|
|
{
|
|
|
|
case RARCH_FAST_FORWARD_HOLD_KEY:
|
2012-07-31 18:09:17 +00:00
|
|
|
return ((state[0] & XINPUT1_GAMEPAD_RSTICK_DOWN_MASK) && !(state[0] & XINPUT1_GAMEPAD_RIGHT_TRIGGER));
|
2012-07-31 15:56:32 +00:00
|
|
|
case RARCH_LOAD_STATE_KEY:
|
2012-07-31 18:09:17 +00:00
|
|
|
return ((state[0] & XINPUT1_GAMEPAD_RSTICK_UP_MASK) && (state[0] & XINPUT1_GAMEPAD_RIGHT_TRIGGER));
|
2012-07-31 15:56:32 +00:00
|
|
|
case RARCH_SAVE_STATE_KEY:
|
2012-07-31 18:09:17 +00:00
|
|
|
return ((state[0] & XINPUT1_GAMEPAD_RSTICK_DOWN_MASK) && (state[0] & XINPUT1_GAMEPAD_RIGHT_TRIGGER));
|
2012-07-31 15:56:32 +00:00
|
|
|
case RARCH_STATE_SLOT_PLUS:
|
2012-07-31 18:09:17 +00:00
|
|
|
return ((state[0] & XINPUT1_GAMEPAD_RSTICK_RIGHT_MASK) && (state[0] & XINPUT1_GAMEPAD_RIGHT_TRIGGER));
|
2012-07-31 15:56:32 +00:00
|
|
|
case RARCH_STATE_SLOT_MINUS:
|
2012-07-31 18:09:17 +00:00
|
|
|
return ((state[0] & XINPUT1_GAMEPAD_RSTICK_LEFT_MASK) && (state[0] & XINPUT1_GAMEPAD_RIGHT_TRIGGER));
|
2012-07-31 15:56:32 +00:00
|
|
|
case RARCH_REWIND:
|
2012-07-31 18:09:17 +00:00
|
|
|
return ((state[0] & XINPUT1_GAMEPAD_RSTICK_UP_MASK) && !(state[0] & XINPUT1_GAMEPAD_RIGHT_TRIGGER));
|
2012-12-15 00:14:21 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2012-07-31 15:56:32 +00:00
|
|
|
}
|
2012-07-08 19:42:26 +00:00
|
|
|
|
2012-12-15 00:14:21 +00:00
|
|
|
return false;
|
2012-07-08 19:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const input_driver_t input_xinput =
|
|
|
|
{
|
2012-12-02 05:01:39 +00:00
|
|
|
xdk_input_init,
|
|
|
|
xdk_input_poll,
|
|
|
|
xdk_input_state,
|
|
|
|
xdk_input_key_pressed,
|
|
|
|
xdk_input_free_input,
|
|
|
|
xdk_set_default_keybind_lut,
|
|
|
|
xdk_input_set_analog_dpad_mapping,
|
|
|
|
xdk_input_post_init,
|
2012-07-27 13:46:15 +00:00
|
|
|
MAX_PADS,
|
2012-07-08 19:42:26 +00:00
|
|
|
"xinput"
|
|
|
|
};
|