2014-08-30 03:46:57 +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
|
2014-08-30 03:46:57 +02:00
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2016-12-01 20:38:20 +01:00
|
|
|
#include "../../tasks/tasks_internal.h"
|
2016-09-05 18:31:32 +02:00
|
|
|
#include "../../configuration.h"
|
|
|
|
|
2014-08-30 03:46:57 +02:00
|
|
|
static const char *qnx_joypad_name(unsigned pad)
|
|
|
|
{
|
2017-04-25 16:04:28 +02:00
|
|
|
return input_config_get_device_name(pad);
|
2014-08-30 03:46:57 +02:00
|
|
|
}
|
|
|
|
|
2015-06-03 18:22:54 +02:00
|
|
|
static bool qnx_joypad_init(void *data)
|
2014-08-30 03:46:57 +02:00
|
|
|
{
|
|
|
|
unsigned autoconf_pad;
|
|
|
|
|
2015-06-03 18:22:54 +02:00
|
|
|
(void)data;
|
|
|
|
|
2015-01-05 01:58:00 +01:00
|
|
|
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
2019-07-16 15:28:22 +02:00
|
|
|
input_autoconfigure_connect(
|
2016-12-31 07:43:34 +01:00
|
|
|
qnx_joypad_name(autoconf_pad),
|
|
|
|
NULL,
|
|
|
|
qnx_joypad.ident,
|
|
|
|
autoconf_pad,
|
|
|
|
0,
|
|
|
|
0
|
2019-07-16 15:28:22 +02:00
|
|
|
);
|
2014-08-30 03:46:57 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool qnx_joypad_button(unsigned port_num, uint16_t joykey)
|
|
|
|
{
|
2019-07-16 14:41:09 +02:00
|
|
|
qnx_input_device_t* controller = NULL;
|
|
|
|
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
|
2014-08-30 03:46:57 +02:00
|
|
|
|
2019-07-16 14:41:09 +02:00
|
|
|
if (!qnx || port_num >= MAX_PADS)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
controller = (qnx_input_device_t*)&qnx->devices[port_num];
|
2014-08-30 03:46:57 +02:00
|
|
|
|
2019-07-16 14:41:09 +02:00
|
|
|
if(port_num < MAX_USERS && joykey <= 19)
|
|
|
|
return (controller->buttons & (1 << joykey)) != 0;
|
2015-02-15 01:57:29 +01:00
|
|
|
|
2019-07-16 14:41:09 +02:00
|
|
|
return false;
|
2015-02-15 01:57:29 +01:00
|
|
|
}
|
|
|
|
|
2014-08-30 03:46:57 +02:00
|
|
|
static int16_t qnx_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
|
|
|
{
|
2015-04-03 01:02:46 +02:00
|
|
|
int val = 0;
|
|
|
|
int axis = -1;
|
|
|
|
bool is_neg = false;
|
|
|
|
bool is_pos = false;
|
2015-11-29 18:18:25 +01:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
|
2014-08-30 03:46:57 +02:00
|
|
|
|
|
|
|
if (!qnx || joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-01-07 21:34:39 +00:00
|
|
|
qnx_input_device_t* controller = NULL;
|
|
|
|
controller = (qnx_input_device_t*)&qnx->devices[port_num];
|
|
|
|
|
2014-08-30 03:46:57 +02:00
|
|
|
switch (axis)
|
|
|
|
{
|
2014-09-09 18:15:17 +02:00
|
|
|
case 0:
|
2017-01-07 21:34:39 +00:00
|
|
|
val = controller->analog0[0];
|
2014-09-09 18:15:17 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2017-01-07 21:34:39 +00:00
|
|
|
val = controller->analog0[1];
|
2014-09-09 18:15:17 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2017-01-07 21:34:39 +00:00
|
|
|
val = controller->analog1[0];
|
2014-09-09 18:15:17 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2017-01-07 21:34:39 +00:00
|
|
|
val = controller->analog1[1];
|
2014-09-09 18:15:17 +02:00
|
|
|
break;
|
2014-08-30 03:46:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2017-01-07 21:34:39 +00:00
|
|
|
return (pad < MAX_USERS);
|
2014-08-30 03:46:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qnx_joypad_destroy(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-04-14 16:37:59 +02:00
|
|
|
input_device_driver_t qnx_joypad = {
|
2014-08-30 03:46:57 +02:00
|
|
|
qnx_joypad_init,
|
|
|
|
qnx_joypad_query_pad,
|
|
|
|
qnx_joypad_destroy,
|
|
|
|
qnx_joypad_button,
|
2017-01-07 21:34:39 +00:00
|
|
|
NULL,
|
2014-08-30 03:46:57 +02:00
|
|
|
qnx_joypad_axis,
|
|
|
|
qnx_joypad_poll,
|
|
|
|
NULL,
|
|
|
|
qnx_joypad_name,
|
|
|
|
"qnx",
|
|
|
|
};
|