mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 06:40:18 +00:00
Split up input drivers into separate input_ and joypad_ files
This commit is contained in:
parent
fd3a419242
commit
00f53247cd
@ -292,12 +292,14 @@ INPUT
|
||||
#include "../input/autoconf/builtin_ps3.c"
|
||||
#elif defined(SN_TARGET_PSP2) || defined(PSP)
|
||||
#include "../input/psp_input.c"
|
||||
#include "../input/psp_input_joypad.c"
|
||||
#include "../input/autoconf/builtin_psp.c"
|
||||
#elif defined(GEKKO)
|
||||
#ifdef HAVE_LIBSICKSAXIS
|
||||
#include "../input/gx_input_sicksaxis.c"
|
||||
#endif
|
||||
#include "../input/gx_input.c"
|
||||
#include "../input/gx_input_joypad.c"
|
||||
#include "../input/autoconf/builtin_gx.c"
|
||||
#elif defined(_XBOX)
|
||||
#include "../input/xdk_xinput_input.c"
|
||||
@ -306,11 +308,13 @@ INPUT
|
||||
#include "../input/xenon360_input.c"
|
||||
#elif defined(ANDROID)
|
||||
#include "../input/android_input.c"
|
||||
#include "../input/android_input_joypad.c"
|
||||
#elif defined(IOS) || defined(OSX)
|
||||
#include "../input/apple_input.c"
|
||||
#include "../input/apple_joypad.c"
|
||||
#elif defined(__QNX__)
|
||||
#include "../input/qnx_input.c"
|
||||
#include "../input/qnx_input_joypad.c"
|
||||
#elif defined(EMSCRIPTEN)
|
||||
#include "../input/rwebinput_input.c"
|
||||
#endif
|
||||
|
@ -767,124 +767,3 @@ const input_driver_t input_android = {
|
||||
NULL,
|
||||
android_input_get_joypad_driver,
|
||||
};
|
||||
|
||||
static const char *android_joypad_name(unsigned pad)
|
||||
{
|
||||
return g_settings.input.device_names[pad];
|
||||
}
|
||||
|
||||
static bool android_joypad_init(void)
|
||||
{
|
||||
unsigned autoconf_pad;
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
||||
{
|
||||
strlcpy(g_settings.input.device_names[autoconf_pad],
|
||||
android_joypad_name(autoconf_pad),
|
||||
sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||
input_config_autoconfigure_joypad(autoconf_pad,
|
||||
android_joypad_name(autoconf_pad),
|
||||
android_joypad.ident);
|
||||
}
|
||||
|
||||
engine_handle_dpad = engine_handle_dpad_default;
|
||||
if ((dlopen("/system/lib/libandroid.so", RTLD_LOCAL | RTLD_LAZY)) == 0)
|
||||
{
|
||||
RARCH_WARN("Unable to open libandroid.so\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((p_AMotionEvent_getAxisValue = dlsym(RTLD_DEFAULT,
|
||||
"AMotionEvent_getAxisValue")))
|
||||
{
|
||||
RARCH_LOG("Set engine_handle_dpad to 'Get Axis Value' (for reading extra analog sticks)");
|
||||
engine_handle_dpad = engine_handle_dpad_getaxisvalue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool android_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
android_input_t *android = (android_input_t*)driver.input_data;
|
||||
|
||||
if (!android || port_num >= MAX_PADS)
|
||||
return false;
|
||||
|
||||
if (GET_HAT_DIR(joykey))
|
||||
{
|
||||
unsigned h = GET_HAT(joykey);
|
||||
if (h > 0)
|
||||
return false;
|
||||
switch (GET_HAT_DIR(joykey))
|
||||
{
|
||||
case HAT_LEFT_MASK: return android->hat_state[port_num][0] == -1;
|
||||
case HAT_RIGHT_MASK: return android->hat_state[port_num][0] == 1;
|
||||
case HAT_UP_MASK: return android->hat_state[port_num][1] == -1;
|
||||
case HAT_DOWN_MASK: return android->hat_state[port_num][1] == 1;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
return joykey < LAST_KEYCODE && get_bit(android->pad_state[port_num],
|
||||
joykey);
|
||||
}
|
||||
|
||||
static int16_t android_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
{
|
||||
android_input_t *android = (android_input_t*)driver.input_data;
|
||||
if (!android || joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
|
||||
int val = 0;
|
||||
|
||||
int axis = -1;
|
||||
bool is_neg = false;
|
||||
bool is_pos = false;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) < MAX_AXIS)
|
||||
{
|
||||
axis = AXIS_NEG_GET(joyaxis);
|
||||
is_neg = true;
|
||||
}
|
||||
else if (AXIS_POS_GET(joyaxis) < MAX_AXIS)
|
||||
{
|
||||
axis = AXIS_POS_GET(joyaxis);
|
||||
is_pos = true;
|
||||
}
|
||||
|
||||
val = android->analog_state[port_num][axis];
|
||||
|
||||
if (is_neg && val > 0)
|
||||
val = 0;
|
||||
else if (is_pos && val < 0)
|
||||
val = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void android_joypad_poll(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool android_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
android_input_t *android = (android_input_t*)driver.input_data;
|
||||
return (pad < MAX_PLAYERS && pad < android->pads_connected);
|
||||
}
|
||||
|
||||
|
||||
static void android_joypad_destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t android_joypad = {
|
||||
android_joypad_init,
|
||||
android_joypad_query_pad,
|
||||
android_joypad_destroy,
|
||||
android_joypad_button,
|
||||
android_joypad_axis,
|
||||
android_joypad_poll,
|
||||
NULL,
|
||||
android_joypad_name,
|
||||
"android",
|
||||
};
|
||||
|
138
input/android_input_joypad.c
Normal file
138
input/android_input_joypad.c
Normal file
@ -0,0 +1,138 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2014 - Daniel De Matteis
|
||||
* Copyright (C) 2012-2014 - Michael Lelli
|
||||
* Copyright (C) 2013-2014 - Steven Crowe
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
static const char *android_joypad_name(unsigned pad)
|
||||
{
|
||||
return g_settings.input.device_names[pad];
|
||||
}
|
||||
|
||||
static bool android_joypad_init(void)
|
||||
{
|
||||
unsigned autoconf_pad;
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
||||
{
|
||||
strlcpy(g_settings.input.device_names[autoconf_pad],
|
||||
android_joypad_name(autoconf_pad),
|
||||
sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||
input_config_autoconfigure_joypad(autoconf_pad,
|
||||
android_joypad_name(autoconf_pad),
|
||||
android_joypad.ident);
|
||||
}
|
||||
|
||||
engine_handle_dpad = engine_handle_dpad_default;
|
||||
if ((dlopen("/system/lib/libandroid.so", RTLD_LOCAL | RTLD_LAZY)) == 0)
|
||||
{
|
||||
RARCH_WARN("Unable to open libandroid.so\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((p_AMotionEvent_getAxisValue = dlsym(RTLD_DEFAULT,
|
||||
"AMotionEvent_getAxisValue")))
|
||||
{
|
||||
RARCH_LOG("Set engine_handle_dpad to 'Get Axis Value' (for reading extra analog sticks)");
|
||||
engine_handle_dpad = engine_handle_dpad_getaxisvalue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool android_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
android_input_t *android = (android_input_t*)driver.input_data;
|
||||
|
||||
if (!android || port_num >= MAX_PADS)
|
||||
return false;
|
||||
|
||||
if (GET_HAT_DIR(joykey))
|
||||
{
|
||||
unsigned h = GET_HAT(joykey);
|
||||
if (h > 0)
|
||||
return false;
|
||||
switch (GET_HAT_DIR(joykey))
|
||||
{
|
||||
case HAT_LEFT_MASK: return android->hat_state[port_num][0] == -1;
|
||||
case HAT_RIGHT_MASK: return android->hat_state[port_num][0] == 1;
|
||||
case HAT_UP_MASK: return android->hat_state[port_num][1] == -1;
|
||||
case HAT_DOWN_MASK: return android->hat_state[port_num][1] == 1;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
return joykey < LAST_KEYCODE && get_bit(android->pad_state[port_num],
|
||||
joykey);
|
||||
}
|
||||
|
||||
static int16_t android_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
{
|
||||
android_input_t *android = (android_input_t*)driver.input_data;
|
||||
if (!android || joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
|
||||
int val = 0;
|
||||
|
||||
int axis = -1;
|
||||
bool is_neg = false;
|
||||
bool is_pos = false;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) < MAX_AXIS)
|
||||
{
|
||||
axis = AXIS_NEG_GET(joyaxis);
|
||||
is_neg = true;
|
||||
}
|
||||
else if (AXIS_POS_GET(joyaxis) < MAX_AXIS)
|
||||
{
|
||||
axis = AXIS_POS_GET(joyaxis);
|
||||
is_pos = true;
|
||||
}
|
||||
|
||||
val = android->analog_state[port_num][axis];
|
||||
|
||||
if (is_neg && val > 0)
|
||||
val = 0;
|
||||
else if (is_pos && val < 0)
|
||||
val = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void android_joypad_poll(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool android_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
android_input_t *android = (android_input_t*)driver.input_data;
|
||||
return (pad < MAX_PLAYERS && pad < android->pads_connected);
|
||||
}
|
||||
|
||||
|
||||
static void android_joypad_destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t android_joypad = {
|
||||
android_joypad_init,
|
||||
android_joypad_query_pad,
|
||||
android_joypad_destroy,
|
||||
android_joypad_button,
|
||||
android_joypad_axis,
|
||||
android_joypad_poll,
|
||||
NULL,
|
||||
android_joypad_name,
|
||||
"android",
|
||||
};
|
110
input/gx_input.c
110
input/gx_input.c
@ -544,113 +544,3 @@ const input_driver_t input_gx = {
|
||||
NULL,
|
||||
gx_input_get_joypad_driver,
|
||||
};
|
||||
|
||||
|
||||
static bool gx_joypad_init(void)
|
||||
{
|
||||
PAD_Init();
|
||||
#ifdef HW_RVL
|
||||
WPADInit();
|
||||
#endif
|
||||
#ifdef HAVE_LIBSICKSAXIS
|
||||
int i;
|
||||
USB_Initialize();
|
||||
ss_init();
|
||||
for (i = 0; i < MAX_PADS; i++)
|
||||
ss_initialize(&dev[i]);
|
||||
#endif
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gx_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
gx_input_t *gx = (gx_input_t*)driver.input_data;
|
||||
|
||||
if (port_num >= MAX_PADS)
|
||||
return false;
|
||||
|
||||
return gx->pad_state[port_num] & (1ULL << joykey);
|
||||
}
|
||||
|
||||
static int16_t gx_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
{
|
||||
gx_input_t *gx = (gx_input_t*)driver.input_data;
|
||||
if (joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
|
||||
int val = 0;
|
||||
|
||||
int axis = -1;
|
||||
bool is_neg = false;
|
||||
bool is_pos = false;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_NEG_GET(joyaxis);
|
||||
is_neg = true;
|
||||
}
|
||||
else if (AXIS_POS_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_POS_GET(joyaxis);
|
||||
is_pos = true;
|
||||
}
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0: val = gx->analog_state[port_num][0][0]; break;
|
||||
case 1: val = gx->analog_state[port_num][0][1]; break;
|
||||
case 2: val = gx->analog_state[port_num][1][0]; break;
|
||||
case 3: val = gx->analog_state[port_num][1][1]; break;
|
||||
}
|
||||
|
||||
if (is_neg && val > 0)
|
||||
val = 0;
|
||||
else if (is_pos && val < 0)
|
||||
val = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void gx_joypad_poll(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool gx_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
gx_input_t *gx = (gx_input_t*)driver.input_data;
|
||||
return pad < MAX_PLAYERS && gx->pad_state[pad];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void gx_joypad_destroy(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_PADS; i++)
|
||||
{
|
||||
#ifdef HAVE_LIBSICKSAXIS
|
||||
ss_close(&dev[i]);
|
||||
USB_Deinitialize();
|
||||
#endif
|
||||
|
||||
#ifdef HW_RVL
|
||||
WPAD_Flush(i);
|
||||
WPADDisconnect(i);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t gx_joypad = {
|
||||
gx_joypad_init,
|
||||
gx_joypad_query_pad,
|
||||
gx_joypad_destroy,
|
||||
gx_joypad_button,
|
||||
gx_joypad_axis,
|
||||
gx_joypad_poll,
|
||||
NULL,
|
||||
gx_joypad_name,
|
||||
"gx",
|
||||
};
|
||||
|
122
input/gx_input_joypad.c
Normal file
122
input/gx_input_joypad.c
Normal file
@ -0,0 +1,122 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2014 - Daniel De Matteis
|
||||
* Copyright (C) 2012-2014 - Michael Lelli
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
static bool gx_joypad_init(void)
|
||||
{
|
||||
PAD_Init();
|
||||
#ifdef HW_RVL
|
||||
WPADInit();
|
||||
#endif
|
||||
#ifdef HAVE_LIBSICKSAXIS
|
||||
int i;
|
||||
USB_Initialize();
|
||||
ss_init();
|
||||
for (i = 0; i < MAX_PADS; i++)
|
||||
ss_initialize(&dev[i]);
|
||||
#endif
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gx_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
gx_input_t *gx = (gx_input_t*)driver.input_data;
|
||||
|
||||
if (port_num >= MAX_PADS)
|
||||
return false;
|
||||
|
||||
return gx->pad_state[port_num] & (1ULL << joykey);
|
||||
}
|
||||
|
||||
static int16_t gx_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
{
|
||||
gx_input_t *gx = (gx_input_t*)driver.input_data;
|
||||
if (joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
|
||||
int val = 0;
|
||||
|
||||
int axis = -1;
|
||||
bool is_neg = false;
|
||||
bool is_pos = false;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_NEG_GET(joyaxis);
|
||||
is_neg = true;
|
||||
}
|
||||
else if (AXIS_POS_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_POS_GET(joyaxis);
|
||||
is_pos = true;
|
||||
}
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0: val = gx->analog_state[port_num][0][0]; break;
|
||||
case 1: val = gx->analog_state[port_num][0][1]; break;
|
||||
case 2: val = gx->analog_state[port_num][1][0]; break;
|
||||
case 3: val = gx->analog_state[port_num][1][1]; break;
|
||||
}
|
||||
|
||||
if (is_neg && val > 0)
|
||||
val = 0;
|
||||
else if (is_pos && val < 0)
|
||||
val = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void gx_joypad_poll(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool gx_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
gx_input_t *gx = (gx_input_t*)driver.input_data;
|
||||
return pad < MAX_PLAYERS && gx->pad_state[pad];
|
||||
}
|
||||
|
||||
static void gx_joypad_destroy(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_PADS; i++)
|
||||
{
|
||||
#ifdef HAVE_LIBSICKSAXIS
|
||||
ss_close(&dev[i]);
|
||||
USB_Deinitialize();
|
||||
#endif
|
||||
|
||||
#ifdef HW_RVL
|
||||
WPAD_Flush(i);
|
||||
WPADDisconnect(i);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t gx_joypad = {
|
||||
gx_joypad_init,
|
||||
gx_joypad_query_pad,
|
||||
gx_joypad_destroy,
|
||||
gx_joypad_button,
|
||||
gx_joypad_axis,
|
||||
gx_joypad_poll,
|
||||
NULL,
|
||||
gx_joypad_name,
|
||||
"gx",
|
||||
};
|
@ -180,97 +180,3 @@ const input_driver_t input_psp = {
|
||||
NULL,
|
||||
psp_input_get_joypad_driver,
|
||||
};
|
||||
|
||||
static const char *psp_joypad_name(unsigned pad)
|
||||
{
|
||||
return "PSP Controller";
|
||||
}
|
||||
|
||||
static bool psp_joypad_init(void)
|
||||
{
|
||||
unsigned autoconf_pad;
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++)
|
||||
{
|
||||
strlcpy(g_settings.input.device_names[autoconf_pad], psp_joypad_name(autoconf_pad), sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||
input_config_autoconfigure_joypad(autoconf_pad, psp_joypad_name(autoconf_pad), psp_joypad.ident);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool psp_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
psp_input_t *psp = (psp_input_t*)driver.input_data;
|
||||
|
||||
if (port_num >= MAX_PADS)
|
||||
return false;
|
||||
|
||||
return (psp->pad_state & (1ULL << joykey));
|
||||
}
|
||||
|
||||
static int16_t psp_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
{
|
||||
psp_input_t *psp = (psp_input_t*)driver.input_data;
|
||||
if (joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
|
||||
int val = 0;
|
||||
|
||||
int axis = -1;
|
||||
bool is_neg = false;
|
||||
bool is_pos = false;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_NEG_GET(joyaxis);
|
||||
is_neg = true;
|
||||
}
|
||||
else if (AXIS_POS_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_POS_GET(joyaxis);
|
||||
is_pos = true;
|
||||
}
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0: val = psp->analog_state[port_num][0][0]; break;
|
||||
case 1: val = psp->analog_state[port_num][0][1]; break;
|
||||
case 2: val = psp->analog_state[port_num][1][0]; break;
|
||||
case 3: val = psp->analog_state[port_num][1][1]; break;
|
||||
}
|
||||
|
||||
if (is_neg && val > 0)
|
||||
val = 0;
|
||||
else if (is_pos && val < 0)
|
||||
val = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void psp_joypad_poll(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool psp_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
psp_input_t *psp = (psp_input_t*)driver.input_data;
|
||||
return pad < MAX_PLAYERS && psp->pad_state;
|
||||
}
|
||||
|
||||
|
||||
static void psp_joypad_destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t psp_joypad = {
|
||||
psp_joypad_init,
|
||||
psp_joypad_query_pad,
|
||||
psp_joypad_destroy,
|
||||
psp_joypad_button,
|
||||
psp_joypad_axis,
|
||||
psp_joypad_poll,
|
||||
NULL,
|
||||
psp_joypad_name,
|
||||
"psp",
|
||||
};
|
||||
|
109
input/psp_input_joypad.c
Normal file
109
input/psp_input_joypad.c
Normal file
@ -0,0 +1,109 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2014 - 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/>.
|
||||
*/
|
||||
|
||||
static const char *psp_joypad_name(unsigned pad)
|
||||
{
|
||||
return "PSP Controller";
|
||||
}
|
||||
|
||||
static bool psp_joypad_init(void)
|
||||
{
|
||||
unsigned autoconf_pad;
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++)
|
||||
{
|
||||
strlcpy(g_settings.input.device_names[autoconf_pad], psp_joypad_name(autoconf_pad), sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||
input_config_autoconfigure_joypad(autoconf_pad, psp_joypad_name(autoconf_pad), psp_joypad.ident);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool psp_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
psp_input_t *psp = (psp_input_t*)driver.input_data;
|
||||
|
||||
if (port_num >= MAX_PADS)
|
||||
return false;
|
||||
|
||||
return (psp->pad_state & (1ULL << joykey));
|
||||
}
|
||||
|
||||
static int16_t psp_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
{
|
||||
psp_input_t *psp = (psp_input_t*)driver.input_data;
|
||||
if (joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
|
||||
int val = 0;
|
||||
|
||||
int axis = -1;
|
||||
bool is_neg = false;
|
||||
bool is_pos = false;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_NEG_GET(joyaxis);
|
||||
is_neg = true;
|
||||
}
|
||||
else if (AXIS_POS_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_POS_GET(joyaxis);
|
||||
is_pos = true;
|
||||
}
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0: val = psp->analog_state[port_num][0][0]; break;
|
||||
case 1: val = psp->analog_state[port_num][0][1]; break;
|
||||
case 2: val = psp->analog_state[port_num][1][0]; break;
|
||||
case 3: val = psp->analog_state[port_num][1][1]; break;
|
||||
}
|
||||
|
||||
if (is_neg && val > 0)
|
||||
val = 0;
|
||||
else if (is_pos && val < 0)
|
||||
val = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void psp_joypad_poll(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool psp_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
psp_input_t *psp = (psp_input_t*)driver.input_data;
|
||||
return pad < MAX_PLAYERS && psp->pad_state;
|
||||
}
|
||||
|
||||
|
||||
static void psp_joypad_destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t psp_joypad = {
|
||||
psp_joypad_init,
|
||||
psp_joypad_query_pad,
|
||||
psp_joypad_destroy,
|
||||
psp_joypad_button,
|
||||
psp_joypad_axis,
|
||||
psp_joypad_poll,
|
||||
NULL,
|
||||
psp_joypad_name,
|
||||
"psp",
|
||||
};
|
@ -731,98 +731,3 @@ const input_driver_t input_qnx = {
|
||||
NULL,
|
||||
qnx_input_get_joypad_driver,
|
||||
};
|
||||
|
||||
static const char *qnx_joypad_name(unsigned pad)
|
||||
{
|
||||
return g_settings.input.device_names[pad];
|
||||
}
|
||||
|
||||
static bool qnx_joypad_init(void)
|
||||
{
|
||||
unsigned autoconf_pad;
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
||||
{
|
||||
strlcpy(g_settings.input.device_names[autoconf_pad], "None", sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||
input_config_autoconfigure_joypad(autoconf_pad, qnx_joypad_name(autoconf_pad), qnx_joypad.ident);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool qnx_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
qnx_input_t *qnx = (qnx_input_t*)driver.input_data;
|
||||
|
||||
if (!qnx || port_num >= MAX_PADS)
|
||||
return false;
|
||||
|
||||
return qnx->pad_state[port_num] & (1ULL << joykey);
|
||||
}
|
||||
|
||||
static int16_t qnx_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
{
|
||||
qnx_input_t *qnx = (qnx_input_t*)driver.input_data;
|
||||
|
||||
if (!qnx || joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
|
||||
int val = 0;
|
||||
|
||||
int axis = -1;
|
||||
bool is_neg = false;
|
||||
bool is_pos = false;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_NEG_GET(joyaxis);
|
||||
is_neg = true;
|
||||
}
|
||||
else if (AXIS_POS_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_POS_GET(joyaxis);
|
||||
is_pos = true;
|
||||
}
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0: val = qnx->analog_state[port_num][0][0]; break;
|
||||
case 1: val = qnx->analog_state[port_num][0][1]; break;
|
||||
case 2: val = qnx->analog_state[port_num][1][0]; break;
|
||||
case 3: val = qnx->analog_state[port_num][1][1]; break;
|
||||
}
|
||||
|
||||
if (is_neg && val > 0)
|
||||
val = 0;
|
||||
else if (is_pos && val < 0)
|
||||
val = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void qnx_joypad_poll(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool qnx_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
qnx_input_t *qnx = (qnx_input_t*)driver.input_data;
|
||||
return (qnx && pad < MAX_PLAYERS && qnx->pad_state[pad]);
|
||||
}
|
||||
|
||||
|
||||
static void qnx_joypad_destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t qnx_joypad = {
|
||||
qnx_joypad_init,
|
||||
qnx_joypad_query_pad,
|
||||
qnx_joypad_destroy,
|
||||
qnx_joypad_button,
|
||||
qnx_joypad_axis,
|
||||
qnx_joypad_poll,
|
||||
NULL,
|
||||
qnx_joypad_name,
|
||||
"qnx",
|
||||
};
|
||||
|
111
input/qnx_input_joypad.c
Normal file
111
input/qnx_input_joypad.c
Normal file
@ -0,0 +1,111 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2014 - Daniel De Matteis
|
||||
* Copyright (C) 2013-2014 - CatalystG
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
static const char *qnx_joypad_name(unsigned pad)
|
||||
{
|
||||
return g_settings.input.device_names[pad];
|
||||
}
|
||||
|
||||
static bool qnx_joypad_init(void)
|
||||
{
|
||||
unsigned autoconf_pad;
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
||||
{
|
||||
strlcpy(g_settings.input.device_names[autoconf_pad], "None", sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||
input_config_autoconfigure_joypad(autoconf_pad, qnx_joypad_name(autoconf_pad), qnx_joypad.ident);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool qnx_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
qnx_input_t *qnx = (qnx_input_t*)driver.input_data;
|
||||
|
||||
if (!qnx || port_num >= MAX_PADS)
|
||||
return false;
|
||||
|
||||
return qnx->pad_state[port_num] & (1ULL << joykey);
|
||||
}
|
||||
|
||||
static int16_t qnx_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
{
|
||||
qnx_input_t *qnx = (qnx_input_t*)driver.input_data;
|
||||
|
||||
if (!qnx || joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
|
||||
int val = 0;
|
||||
|
||||
int axis = -1;
|
||||
bool is_neg = false;
|
||||
bool is_pos = false;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_NEG_GET(joyaxis);
|
||||
is_neg = true;
|
||||
}
|
||||
else if (AXIS_POS_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_POS_GET(joyaxis);
|
||||
is_pos = true;
|
||||
}
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0: val = qnx->analog_state[port_num][0][0]; break;
|
||||
case 1: val = qnx->analog_state[port_num][0][1]; break;
|
||||
case 2: val = qnx->analog_state[port_num][1][0]; break;
|
||||
case 3: val = qnx->analog_state[port_num][1][1]; break;
|
||||
}
|
||||
|
||||
if (is_neg && val > 0)
|
||||
val = 0;
|
||||
else if (is_pos && val < 0)
|
||||
val = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void qnx_joypad_poll(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool qnx_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
qnx_input_t *qnx = (qnx_input_t*)driver.input_data;
|
||||
return (qnx && pad < MAX_PLAYERS && qnx->pad_state[pad]);
|
||||
}
|
||||
|
||||
|
||||
static void qnx_joypad_destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t qnx_joypad = {
|
||||
qnx_joypad_init,
|
||||
qnx_joypad_query_pad,
|
||||
qnx_joypad_destroy,
|
||||
qnx_joypad_button,
|
||||
qnx_joypad_axis,
|
||||
qnx_joypad_poll,
|
||||
NULL,
|
||||
qnx_joypad_name,
|
||||
"qnx",
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user