2013-03-20 00:21:45 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2013-2014 - CatalystG
|
2013-03-20 00:21:45 +00: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/>.
|
|
|
|
*/
|
|
|
|
|
2015-12-26 06:54:17 +00:00
|
|
|
#include <boolean.h>
|
|
|
|
#include <string/stdstring.h>
|
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
#include <screen/screen.h>
|
2013-03-23 16:21:30 +00:00
|
|
|
#include <bps/event.h>
|
|
|
|
#include <bps/navigator.h>
|
2013-04-08 16:06:42 +00:00
|
|
|
#include <sys/keycodes.h>
|
2015-06-19 01:45:23 +00:00
|
|
|
|
2016-09-11 11:21:56 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
2019-07-19 10:55:38 +00:00
|
|
|
#include "../../config.def.h"
|
|
|
|
|
2017-01-10 16:59:48 +00:00
|
|
|
|
2019-06-17 13:10:22 +00:00
|
|
|
#include "../../retroarch.h"
|
2016-12-24 13:56:09 +00:00
|
|
|
#include "../../tasks/tasks_internal.h"
|
2013-03-20 00:21:45 +00:00
|
|
|
|
2017-01-07 21:34:39 +00:00
|
|
|
#include "../../command.h"
|
|
|
|
|
2013-06-21 00:41:46 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-03-20 00:21:45 +00:00
|
|
|
#define MAX_TOUCH 16
|
2013-06-21 00:41:46 +00:00
|
|
|
#else
|
|
|
|
#define MAX_TOUCH 4
|
|
|
|
#endif
|
2013-03-20 00:21:45 +00:00
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2014-06-14 18:30:47 +00:00
|
|
|
#ifdef HAVE_BB10
|
2015-04-02 22:57:41 +00:00
|
|
|
screen_device_t handle;
|
2014-06-14 18:30:47 +00:00
|
|
|
#endif
|
2015-04-02 22:57:41 +00:00
|
|
|
int type;
|
|
|
|
int analogCount;
|
|
|
|
int buttonCount;
|
|
|
|
char id[64];
|
|
|
|
char vid[64];
|
|
|
|
char pid[64];
|
|
|
|
|
|
|
|
int device;
|
|
|
|
int port;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
/* Current state. */
|
|
|
|
int buttons;
|
|
|
|
int analog0[3];
|
|
|
|
int analog1[3];
|
|
|
|
} qnx_input_device_t;
|
2014-06-14 18:30:47 +00:00
|
|
|
|
2014-06-14 21:07:58 +00:00
|
|
|
struct input_pointer
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
|
|
|
int16_t x, y;
|
|
|
|
int16_t full_x, full_y;
|
|
|
|
int contact_id;
|
2013-06-21 00:41:46 +00:00
|
|
|
int map;
|
2013-03-20 00:21:45 +00:00
|
|
|
};
|
|
|
|
|
2019-07-19 10:55:38 +00:00
|
|
|
#define QNX_MAX_KEYS (65535 + 7) / 8
|
|
|
|
#define TRACKPAD_CPI 500
|
|
|
|
#define TRACKPAD_THRESHOLD TRACKPAD_CPI / 2
|
|
|
|
|
2014-05-17 14:48:52 +00:00
|
|
|
typedef struct qnx_input
|
|
|
|
{
|
2014-06-10 19:04:00 +00:00
|
|
|
unsigned pads_connected;
|
2014-05-17 14:48:52 +00:00
|
|
|
|
2014-09-09 16:15:17 +00:00
|
|
|
/*
|
2016-12-24 13:56:09 +00:00
|
|
|
* The first pointer_count indices of touch_map will be a valid,
|
2014-09-09 16:15:17 +00:00
|
|
|
* active index in pointer array.
|
2014-06-14 21:07:58 +00:00
|
|
|
* Saves us from searching through pointer array when polling state.
|
2014-05-17 14:48:52 +00:00
|
|
|
*/
|
2017-01-07 21:34:39 +00:00
|
|
|
struct input_pointer pointer[MAX_TOUCH];
|
|
|
|
unsigned pointer_count;
|
|
|
|
int touch_map[MAX_TOUCH];
|
|
|
|
|
2019-07-19 10:55:38 +00:00
|
|
|
qnx_input_device_t devices[DEFAULT_MAX_PADS];
|
2015-04-14 14:37:59 +00:00
|
|
|
const input_device_driver_t *joypad;
|
2017-01-07 21:34:39 +00:00
|
|
|
|
|
|
|
uint8_t keyboard_state[QNX_MAX_KEYS];
|
|
|
|
|
2019-07-19 10:55:38 +00:00
|
|
|
uint64_t pad_state[DEFAULT_MAX_PADS];
|
2017-01-07 21:34:39 +00:00
|
|
|
|
|
|
|
int trackpad_acc[2];
|
2014-05-17 14:48:52 +00:00
|
|
|
} qnx_input_t;
|
2013-03-20 00:21:45 +00:00
|
|
|
|
2015-04-02 23:39:13 +00:00
|
|
|
extern screen_context_t screen_ctx;
|
|
|
|
|
2020-06-10 02:00:40 +00:00
|
|
|
static void qnx_init_controller(
|
|
|
|
qnx_input_t *qnx, qnx_input_device_t* controller)
|
2015-04-02 22:57:41 +00:00
|
|
|
{
|
|
|
|
if (!qnx)
|
|
|
|
return;
|
2014-09-09 16:15:17 +00:00
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
/* Initialize controller values. */
|
|
|
|
#ifdef HAVE_BB10
|
|
|
|
controller->handle = 0;
|
|
|
|
#endif
|
|
|
|
controller->type = 0;
|
|
|
|
controller->analogCount = 0;
|
|
|
|
controller->buttonCount = 0;
|
|
|
|
controller->buttons = 0;
|
|
|
|
controller->analog0[0] = 0;
|
|
|
|
controller->analog0[1] = 0;
|
|
|
|
controller->analog0[2] = 0;
|
|
|
|
controller->analog1[0] = 0;
|
|
|
|
controller->analog1[1] = 0;
|
|
|
|
controller->analog1[2] = 0;
|
|
|
|
controller->port = -1;
|
|
|
|
controller->device = -1;
|
|
|
|
controller->index = -1;
|
|
|
|
|
|
|
|
memset(controller->id, 0, sizeof(controller->id));
|
|
|
|
}
|
2013-04-08 16:06:42 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_BB10
|
2017-01-07 21:34:39 +00:00
|
|
|
bool prevMenu;
|
2015-04-02 23:39:13 +00:00
|
|
|
static void qnx_process_gamepad_event(
|
|
|
|
qnx_input_t *qnx,
|
2014-09-09 16:15:17 +00:00
|
|
|
screen_event_t screen_event, int type)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2014-05-17 14:48:52 +00:00
|
|
|
int i;
|
2013-04-07 16:14:28 +00:00
|
|
|
screen_device_t device;
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_input_device_t* controller = NULL;
|
2015-03-20 21:32:09 +00:00
|
|
|
|
2014-05-17 20:16:25 +00:00
|
|
|
(void)type;
|
|
|
|
|
2014-09-09 16:15:17 +00:00
|
|
|
screen_get_event_property_pv(screen_event,
|
|
|
|
SCREEN_PROPERTY_DEVICE, (void**)&device);
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2019-07-19 10:55:38 +00:00
|
|
|
for (i = 0; i < DEFAULT_MAX_PADS; ++i)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2014-06-14 21:07:58 +00:00
|
|
|
if (device == qnx->devices[i].handle)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2015-04-02 22:57:41 +00:00
|
|
|
controller = (qnx_input_device_t*)&qnx->devices[i];
|
2013-04-07 16:14:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!controller)
|
|
|
|
return;
|
|
|
|
|
2014-09-09 16:15:17 +00:00
|
|
|
/* Store the controller's new state. */
|
|
|
|
screen_get_event_property_iv(screen_event,
|
|
|
|
SCREEN_PROPERTY_BUTTONS, &controller->buttons);
|
2013-04-07 16:14:28 +00:00
|
|
|
|
|
|
|
if (controller->analogCount > 0)
|
2017-01-07 21:34:39 +00:00
|
|
|
{
|
2014-09-09 16:15:17 +00:00
|
|
|
screen_get_event_property_iv(screen_event,
|
|
|
|
SCREEN_PROPERTY_ANALOG0, controller->analog0);
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2017-01-07 21:34:39 +00:00
|
|
|
controller->analog0[0] *= 256;
|
|
|
|
controller->analog0[1] *= 256;
|
|
|
|
|
|
|
|
if (controller->analogCount == 2)
|
|
|
|
{
|
|
|
|
screen_get_event_property_iv(screen_event,
|
|
|
|
SCREEN_PROPERTY_ANALOG1, controller->analog1);
|
|
|
|
|
|
|
|
controller->analog1[0] *= 256;
|
|
|
|
controller->analog1[1] *= 256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qnx_process_joystick_event(qnx_input_t *qnx, screen_event_t screen_event, int type)
|
|
|
|
{
|
|
|
|
int displacement[2];
|
|
|
|
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_DISPLACEMENT, displacement);
|
|
|
|
|
|
|
|
if(displacement != 0)
|
|
|
|
{
|
|
|
|
qnx->trackpad_acc[0] += displacement[0];
|
|
|
|
if(abs(qnx->trackpad_acc[0]) > TRACKPAD_THRESHOLD)
|
|
|
|
{
|
|
|
|
if(qnx->trackpad_acc < 0)
|
|
|
|
{
|
|
|
|
input_keyboard_event(true, RETROK_LEFT, 0, 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
input_keyboard_event(false, RETROK_LEFT, 0, 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
}
|
|
|
|
else if(qnx->trackpad_acc > 0)
|
|
|
|
{
|
|
|
|
input_keyboard_event(true, RETROK_RIGHT, 0, 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
input_keyboard_event(false, RETROK_RIGHT, 0, 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
}
|
|
|
|
|
|
|
|
qnx->trackpad_acc[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
qnx->trackpad_acc[1] += displacement[1];
|
|
|
|
if(abs(qnx->trackpad_acc[1]) > TRACKPAD_THRESHOLD)
|
|
|
|
{
|
|
|
|
if(qnx->trackpad_acc < 0)
|
|
|
|
{
|
|
|
|
input_keyboard_event(true, RETROK_UP, 0, 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
input_keyboard_event(false, RETROK_UP, 0, 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
}
|
|
|
|
else if(qnx->trackpad_acc > 0)
|
|
|
|
{
|
|
|
|
input_keyboard_event(true, RETROK_DOWN, 0, 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
input_keyboard_event(false, RETROK_DOWN, 0, 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
}
|
|
|
|
|
|
|
|
qnx->trackpad_acc[1] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int buttons = 0;
|
|
|
|
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS, &buttons);
|
|
|
|
input_keyboard_event(buttons != 0, RETROK_RETURN, 0, 0, RETRO_DEVICE_KEYBOARD);
|
2013-04-07 16:14:28 +00:00
|
|
|
}
|
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
static void qnx_input_autodetect_gamepad(qnx_input_t *qnx,
|
2017-01-07 21:34:39 +00:00
|
|
|
qnx_input_device_t* controller)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2016-12-16 11:33:56 +00:00
|
|
|
char name_buf[256];
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
if (!qnx)
|
|
|
|
return;
|
2014-05-17 20:16:25 +00:00
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
name_buf[0] = '\0';
|
2017-01-07 21:34:39 +00:00
|
|
|
if(controller && controller->type == SCREEN_EVENT_GAMEPAD)
|
2015-04-02 22:57:41 +00:00
|
|
|
{
|
2017-01-07 21:34:39 +00:00
|
|
|
if(strstr(controller->id, "0-054C-05C4-1.0"))
|
|
|
|
strlcpy(name_buf, "DS4 Controller", sizeof(name_buf));
|
|
|
|
else
|
|
|
|
strlcpy(name_buf, "QNX Gamepad", sizeof(name_buf));
|
2015-04-02 22:57:41 +00:00
|
|
|
}
|
|
|
|
|
2015-12-26 06:54:17 +00:00
|
|
|
if (!string_is_empty(name_buf))
|
2015-04-02 22:57:41 +00:00
|
|
|
{
|
2017-01-07 21:34:39 +00:00
|
|
|
controller->port = qnx->pads_connected;
|
|
|
|
|
2016-12-31 06:43:34 +00:00
|
|
|
input_autoconfigure_connect(
|
|
|
|
name_buf,
|
|
|
|
NULL,
|
|
|
|
qnx->joypad->ident,
|
2017-01-07 21:34:39 +00:00
|
|
|
controller->port,
|
2016-12-31 06:43:34 +00:00
|
|
|
*controller->vid,
|
|
|
|
*controller->pid);
|
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx->pads_connected++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qnx_handle_device(qnx_input_t *qnx,
|
|
|
|
qnx_input_device_t* controller)
|
|
|
|
{
|
2014-06-10 19:04:00 +00:00
|
|
|
if (!qnx)
|
|
|
|
return;
|
|
|
|
|
2014-09-09 16:15:17 +00:00
|
|
|
/* Query libscreen for information about this device. */
|
|
|
|
screen_get_device_property_iv(controller->handle,
|
|
|
|
SCREEN_PROPERTY_TYPE, &controller->type);
|
|
|
|
screen_get_device_property_cv(controller->handle,
|
|
|
|
SCREEN_PROPERTY_ID_STRING, sizeof(controller->id), controller->id);
|
|
|
|
screen_get_device_property_cv(controller->handle,
|
2017-01-07 21:34:39 +00:00
|
|
|
SCREEN_PROPERTY_VENDOR, sizeof(controller->vid), controller->vid);
|
2014-09-09 16:15:17 +00:00
|
|
|
screen_get_device_property_cv(controller->handle,
|
2017-01-07 21:34:39 +00:00
|
|
|
SCREEN_PROPERTY_PRODUCT, sizeof(controller->pid), controller->pid);
|
2014-09-09 16:15:17 +00:00
|
|
|
|
2017-01-07 21:34:39 +00:00
|
|
|
if (controller->type == SCREEN_EVENT_GAMEPAD)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2014-09-09 16:15:17 +00:00
|
|
|
screen_get_device_property_iv(controller->handle,
|
|
|
|
SCREEN_PROPERTY_BUTTON_COUNT, &controller->buttonCount);
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2014-09-09 16:15:17 +00:00
|
|
|
/* Check for the existence of analog sticks. */
|
|
|
|
if (!screen_get_device_property_iv(controller->handle,
|
|
|
|
SCREEN_PROPERTY_ANALOG0, controller->analog0))
|
2013-04-08 14:21:43 +00:00
|
|
|
++controller->analogCount;
|
|
|
|
|
2014-09-09 16:15:17 +00:00
|
|
|
if (!screen_get_device_property_iv(controller->handle,
|
|
|
|
SCREEN_PROPERTY_ANALOG1, controller->analog1))
|
2013-04-08 14:21:43 +00:00
|
|
|
++controller->analogCount;
|
2013-04-07 16:14:28 +00:00
|
|
|
}
|
|
|
|
|
2016-12-24 13:56:09 +00:00
|
|
|
/* Screen service will map supported controllers,
|
2014-09-09 16:15:17 +00:00
|
|
|
* we still might need to adjust. */
|
2017-01-07 21:34:39 +00:00
|
|
|
qnx_input_autodetect_gamepad(qnx, controller);
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2020-06-11 03:37:40 +00:00
|
|
|
#ifdef DEBUG
|
2013-04-07 16:14:28 +00:00
|
|
|
if (controller->type == SCREEN_EVENT_GAMEPAD)
|
|
|
|
RARCH_LOG("Gamepad Device Connected:\n");
|
2013-04-08 14:21:43 +00:00
|
|
|
else if (controller->type == SCREEN_EVENT_JOYSTICK)
|
2013-04-07 16:14:28 +00:00
|
|
|
RARCH_LOG("Joystick Device Connected:\n");
|
2013-04-08 14:21:43 +00:00
|
|
|
else if (controller->type == SCREEN_EVENT_KEYBOARD)
|
|
|
|
RARCH_LOG("Keyboard Device Connected:\n");
|
2013-04-07 16:14:28 +00:00
|
|
|
|
|
|
|
RARCH_LOG("\tID: %s\n", controller->id);
|
2014-09-30 14:50:28 +00:00
|
|
|
RARCH_LOG("\tVendor ID: %s\n", controller->vid);
|
|
|
|
RARCH_LOG("\tProduct ID: %s\n", controller->pid);
|
2013-04-07 16:14:28 +00:00
|
|
|
RARCH_LOG("\tButton Count: %d\n", controller->buttonCount);
|
|
|
|
RARCH_LOG("\tAnalog Count: %d\n", controller->analogCount);
|
2020-06-11 03:37:40 +00:00
|
|
|
#endif
|
2013-04-07 16:14:28 +00:00
|
|
|
}
|
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
/* Find currently connected gamepads. */
|
2020-04-01 09:36:02 +00:00
|
|
|
static int qnx_discover_controllers(qnx_input_t *qnx)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2014-09-09 16:15:17 +00:00
|
|
|
/* Get an array of all available devices. */
|
2020-04-01 09:36:02 +00:00
|
|
|
int deviceCount = 0;
|
|
|
|
int ret;
|
2014-05-17 20:16:25 +00:00
|
|
|
unsigned i;
|
|
|
|
|
2020-04-01 09:36:02 +00:00
|
|
|
ret = screen_get_context_property_iv(screen_ctx,
|
2014-09-09 16:15:17 +00:00
|
|
|
SCREEN_PROPERTY_DEVICE_COUNT, &deviceCount);
|
2020-04-01 09:36:02 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
RARCH_ERR("Error querying SCREEN_PROPERTY_DEVICE_COUNT: [%d] %s\n",
|
|
|
|
errno, strerror(errno));
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-09 16:15:17 +00:00
|
|
|
screen_device_t* devices_found = (screen_device_t*)
|
|
|
|
calloc(deviceCount, sizeof(screen_device_t));
|
2020-04-01 09:36:02 +00:00
|
|
|
if (!devices_found) {
|
|
|
|
RARCH_ERR("Error allocating devices_found, deviceCount=%d\n",
|
|
|
|
deviceCount);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = screen_get_context_property_pv(screen_ctx,
|
2014-09-09 16:15:17 +00:00
|
|
|
SCREEN_PROPERTY_DEVICES, (void**)devices_found);
|
2020-04-01 09:36:02 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
RARCH_ERR("Error querying SCREEN_PROPERTY_DEVICES: [%d] %s\n",
|
|
|
|
errno, strerror(errno));
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2014-09-09 16:15:17 +00:00
|
|
|
/* Scan the list for gamepad and joystick devices. */
|
2014-06-10 19:04:00 +00:00
|
|
|
for(i = 0; i < qnx->pads_connected; ++i)
|
2017-01-07 21:34:39 +00:00
|
|
|
{
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_init_controller(qnx, &qnx->devices[i]);
|
2017-01-07 21:34:39 +00:00
|
|
|
}
|
2013-05-10 00:46:23 +00:00
|
|
|
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx->pads_connected = 0;
|
2013-05-10 00:46:23 +00:00
|
|
|
|
2013-04-07 16:14:28 +00:00
|
|
|
for (i = 0; i < deviceCount; i++)
|
|
|
|
{
|
|
|
|
int type;
|
2014-09-09 16:15:17 +00:00
|
|
|
screen_get_device_property_iv(
|
|
|
|
devices_found[i], SCREEN_PROPERTY_TYPE, &type);
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2017-01-07 21:34:39 +00:00
|
|
|
if (type == SCREEN_EVENT_GAMEPAD ||
|
|
|
|
type == SCREEN_EVENT_JOYSTICK ||
|
|
|
|
type == SCREEN_EVENT_KEYBOARD)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2014-06-14 21:07:58 +00:00
|
|
|
qnx->devices[qnx->pads_connected].handle = devices_found[i];
|
|
|
|
qnx->devices[qnx->pads_connected].index = qnx->pads_connected;
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_handle_device(qnx, &qnx->devices[qnx->pads_connected]);
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2019-07-19 10:55:38 +00:00
|
|
|
if (qnx->pads_connected == DEFAULT_MAX_PADS)
|
2013-04-07 16:14:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(devices_found);
|
2020-04-01 09:36:02 +00:00
|
|
|
|
|
|
|
return true;
|
2013-04-07 16:14:28 +00:00
|
|
|
}
|
2013-04-08 16:06:42 +00:00
|
|
|
#endif
|
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
static void qnx_process_keyboard_event(
|
|
|
|
qnx_input_t *qnx,
|
2014-09-30 14:50:28 +00:00
|
|
|
screen_event_t event, int type)
|
2013-04-08 14:21:43 +00:00
|
|
|
{
|
2017-01-07 21:34:39 +00:00
|
|
|
// Get key properties from screen event
|
|
|
|
int flags = 0;
|
|
|
|
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags);
|
|
|
|
|
|
|
|
int cap = 0;
|
|
|
|
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap);
|
|
|
|
|
|
|
|
int mod = 0;
|
|
|
|
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &mod);
|
|
|
|
|
|
|
|
// Calculate state
|
|
|
|
unsigned keycode = input_keymaps_translate_keysym_to_rk(cap);
|
|
|
|
bool keydown = flags & KEY_DOWN;
|
|
|
|
bool keyrepeat = flags & KEY_REPEAT;
|
|
|
|
|
|
|
|
// Fire keyboard event
|
|
|
|
if(!keyrepeat)
|
|
|
|
{
|
|
|
|
input_keyboard_event(keydown, keycode, 0, mod, RETRO_DEVICE_KEYBOARD);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply keyboard state
|
|
|
|
if(keydown && !keyrepeat)
|
|
|
|
{
|
|
|
|
BIT_SET(qnx->keyboard_state, cap);
|
|
|
|
}
|
|
|
|
else if(!keydown && !keyrepeat)
|
|
|
|
{
|
|
|
|
BIT_CLEAR(qnx->keyboard_state, cap);
|
|
|
|
}
|
2013-04-08 14:21:43 +00:00
|
|
|
}
|
2013-04-08 16:06:42 +00:00
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
static void qnx_process_touch_event(
|
|
|
|
qnx_input_t *qnx, screen_event_t event, int type)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2014-05-17 20:16:25 +00:00
|
|
|
int contact_id, pos[2];
|
|
|
|
unsigned i, j;
|
2013-03-20 00:21:45 +00:00
|
|
|
|
2014-09-09 16:15:17 +00:00
|
|
|
screen_get_event_property_iv(event,
|
|
|
|
SCREEN_PROPERTY_TOUCH_ID, (int*)&contact_id);
|
|
|
|
screen_get_event_property_iv(event,
|
|
|
|
SCREEN_PROPERTY_SOURCE_POSITION, pos);
|
2013-03-20 00:21:45 +00:00
|
|
|
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case SCREEN_EVENT_MTOUCH_TOUCH:
|
2014-09-09 16:15:17 +00:00
|
|
|
/* Find a free touch struct. */
|
2014-05-17 14:48:52 +00:00
|
|
|
for(i = 0; i < MAX_TOUCH; ++i)
|
2013-06-21 00:41:46 +00:00
|
|
|
{
|
2014-06-14 21:07:58 +00:00
|
|
|
if(qnx->pointer[i].contact_id == -1)
|
2013-06-21 00:41:46 +00:00
|
|
|
{
|
2017-04-15 17:43:52 +00:00
|
|
|
struct video_viewport vp;
|
2016-12-05 04:18:36 +00:00
|
|
|
|
2017-04-15 17:43:52 +00:00
|
|
|
vp.x = 0;
|
|
|
|
vp.y = 0;
|
|
|
|
vp.width = 0;
|
|
|
|
vp.height = 0;
|
|
|
|
vp.full_width = 0;
|
|
|
|
vp.full_height = 0;
|
|
|
|
|
|
|
|
qnx->pointer[i].contact_id = contact_id;
|
2016-12-05 04:18:36 +00:00
|
|
|
|
2016-12-07 07:07:11 +00:00
|
|
|
video_driver_translate_coord_viewport_wrap(
|
|
|
|
&vp,
|
2016-12-05 04:18:36 +00:00
|
|
|
pos[0], pos[1],
|
2015-04-02 22:57:41 +00:00
|
|
|
&qnx->pointer[i].x, &qnx->pointer[i].y,
|
|
|
|
&qnx->pointer[i].full_x, &qnx->pointer[i].full_y);
|
2014-09-09 16:15:17 +00:00
|
|
|
|
|
|
|
/* Add this pointer to the map to signal it's valid. */
|
2014-06-14 21:07:58 +00:00
|
|
|
qnx->pointer[i].map = qnx->pointer_count;
|
|
|
|
qnx->touch_map[qnx->pointer_count] = i;
|
|
|
|
qnx->pointer_count++;
|
2013-06-21 00:41:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-09-09 16:15:17 +00:00
|
|
|
#if 0
|
2017-01-07 21:34:39 +00:00
|
|
|
RARCH_LOG("New Touch: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);
|
|
|
|
RARCH_LOG("Map: %d %d %d %d %d %d\n", qnx->touch_map[0], qnx->touch_map[1],
|
2016-12-24 13:56:09 +00:00
|
|
|
qnx->touch_map[2], qnx->touch_map[3], qnx->touch_map[4],
|
2014-09-09 16:15:17 +00:00
|
|
|
qnx->touch_map[5]);
|
|
|
|
#endif
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
2014-09-09 16:15:17 +00:00
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
case SCREEN_EVENT_MTOUCH_RELEASE:
|
2014-05-17 14:48:52 +00:00
|
|
|
for(i = 0; i < MAX_TOUCH; ++i)
|
2013-06-21 00:41:46 +00:00
|
|
|
{
|
2014-06-14 21:07:58 +00:00
|
|
|
if(qnx->pointer[i].contact_id == contact_id)
|
2013-06-21 00:41:46 +00:00
|
|
|
{
|
2014-09-09 16:15:17 +00:00
|
|
|
/* Invalidate the finger. */
|
2014-06-14 21:07:58 +00:00
|
|
|
qnx->pointer[i].contact_id = -1;
|
2013-06-21 00:41:46 +00:00
|
|
|
|
2016-12-24 13:56:09 +00:00
|
|
|
/* Remove pointer from map and shift
|
2014-09-09 16:15:17 +00:00
|
|
|
* remaining valid ones to the front. */
|
2014-06-14 21:07:58 +00:00
|
|
|
qnx->touch_map[qnx->pointer[i].map] = -1;
|
|
|
|
for(j = qnx->pointer[i].map; j < qnx->pointer_count; ++j)
|
2013-06-21 00:41:46 +00:00
|
|
|
{
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx->touch_map[j] = qnx->touch_map[j+1];
|
|
|
|
qnx->pointer[qnx->touch_map[j+1]].map = j;
|
|
|
|
qnx->touch_map[j+1] = -1;
|
2013-06-21 00:41:46 +00:00
|
|
|
}
|
2014-06-14 21:07:58 +00:00
|
|
|
qnx->pointer_count--;
|
2013-06-21 00:41:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-09-09 16:15:17 +00:00
|
|
|
#if 0
|
2017-01-07 21:34:39 +00:00
|
|
|
RARCH_LOG("Release: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);
|
|
|
|
RARCH_LOG("Map: %d %d %d %d %d %d\n", qnx->touch_map[0], qnx->touch_map[1],
|
2016-12-24 13:56:09 +00:00
|
|
|
qnx->touch_map[2], qnx->touch_map[3], qnx->touch_map[4],
|
2014-09-09 16:15:17 +00:00
|
|
|
qnx->touch_map[5]);
|
|
|
|
#endif
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
2014-09-09 16:15:17 +00:00
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
case SCREEN_EVENT_MTOUCH_MOVE:
|
2014-09-09 16:15:17 +00:00
|
|
|
/* Find the finger we're tracking and update. */
|
2014-06-14 21:07:58 +00:00
|
|
|
for(i = 0; i < qnx->pointer_count; ++i)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2014-06-14 21:07:58 +00:00
|
|
|
if(qnx->pointer[i].contact_id == contact_id)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2017-04-15 17:43:52 +00:00
|
|
|
struct video_viewport vp;
|
|
|
|
|
|
|
|
vp.x = 0;
|
|
|
|
vp.y = 0;
|
|
|
|
vp.width = 0;
|
|
|
|
vp.height = 0;
|
|
|
|
vp.full_width = 0;
|
|
|
|
vp.full_height = 0;
|
|
|
|
|
2016-05-19 18:14:58 +00:00
|
|
|
#if 0
|
2016-05-19 18:02:39 +00:00
|
|
|
gl_t *gl = (gl_t*)video_driver_get_ptr(false);
|
2014-06-29 22:12:33 +00:00
|
|
|
|
2016-12-24 13:56:09 +00:00
|
|
|
/*During a move, we can go ~30 pixel into the
|
|
|
|
* bezel which gives negative numbers or
|
2014-09-09 16:15:17 +00:00
|
|
|
* numbers larger than the screen resolution.
|
|
|
|
*
|
|
|
|
* Normalize. */
|
2013-06-19 00:37:28 +00:00
|
|
|
if(pos[0] < 0)
|
|
|
|
pos[0] = 0;
|
2014-06-29 22:12:33 +00:00
|
|
|
if(pos[0] > gl->full_x)
|
|
|
|
pos[0] = gl->full_x;
|
2013-06-19 00:37:28 +00:00
|
|
|
|
|
|
|
if(pos[1] < 0)
|
|
|
|
pos[1] = 0;
|
2014-06-29 22:12:33 +00:00
|
|
|
if(pos[1] > gl->full_y)
|
|
|
|
pos[1] = gl->full_y;
|
2016-05-19 18:14:58 +00:00
|
|
|
#endif
|
2013-06-19 00:37:28 +00:00
|
|
|
|
2016-12-07 07:07:11 +00:00
|
|
|
video_driver_translate_coord_viewport_wrap(&vp,
|
2016-12-05 04:18:36 +00:00
|
|
|
pos[0], pos[1],
|
2014-06-14 21:07:58 +00:00
|
|
|
&qnx->pointer[i].x, &qnx->pointer[i].y,
|
|
|
|
&qnx->pointer[i].full_x, &qnx->pointer[i].full_y);
|
2014-09-09 16:15:17 +00:00
|
|
|
#if 0
|
2017-01-07 21:34:39 +00:00
|
|
|
RARCH_LOG("Move: x:%d, y:%d, id:%d\n", pos[0], pos[1],
|
2014-09-09 16:15:17 +00:00
|
|
|
contact_id);
|
|
|
|
#endif
|
2013-06-21 00:41:46 +00:00
|
|
|
break;
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
static void qnx_handle_screen_event(qnx_input_t *qnx, bps_event_t *event)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
|
|
|
int type;
|
|
|
|
screen_event_t screen_event = screen_event_get_event(event);
|
2015-04-02 22:57:41 +00:00
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &type);
|
|
|
|
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case SCREEN_EVENT_MTOUCH_TOUCH:
|
|
|
|
case SCREEN_EVENT_MTOUCH_RELEASE:
|
|
|
|
case SCREEN_EVENT_MTOUCH_MOVE:
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_process_touch_event(qnx, screen_event, type);
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
|
|
|
case SCREEN_EVENT_KEYBOARD:
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_process_keyboard_event(qnx, screen_event, type);
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
2013-04-08 16:06:42 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-03-20 00:21:45 +00:00
|
|
|
case SCREEN_EVENT_GAMEPAD:
|
2015-04-02 23:39:13 +00:00
|
|
|
qnx_process_gamepad_event(qnx, screen_event, type);
|
2017-01-07 21:34:39 +00:00
|
|
|
break;
|
|
|
|
case SCREEN_EVENT_JOYSTICK:
|
|
|
|
qnx_process_joystick_event(qnx, screen_event, type);
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
|
|
|
case SCREEN_EVENT_DEVICE:
|
|
|
|
{
|
2014-09-09 16:15:17 +00:00
|
|
|
/* A device was attached or removed. */
|
2013-03-20 00:21:45 +00:00
|
|
|
screen_device_t device;
|
2014-05-17 14:48:52 +00:00
|
|
|
int attached, type, i;
|
2013-03-20 00:21:45 +00:00
|
|
|
|
|
|
|
screen_get_event_property_pv(screen_event,
|
|
|
|
SCREEN_PROPERTY_DEVICE, (void**)&device);
|
|
|
|
screen_get_event_property_iv(screen_event,
|
|
|
|
SCREEN_PROPERTY_ATTACHED, &attached);
|
|
|
|
|
|
|
|
if (attached)
|
|
|
|
screen_get_device_property_iv(device,
|
|
|
|
SCREEN_PROPERTY_TYPE, &type);
|
|
|
|
|
2016-12-24 13:56:09 +00:00
|
|
|
if (attached &&
|
2015-04-02 22:57:41 +00:00
|
|
|
(
|
|
|
|
type == SCREEN_EVENT_GAMEPAD ||
|
|
|
|
type == SCREEN_EVENT_JOYSTICK ||
|
|
|
|
type == SCREEN_EVENT_KEYBOARD)
|
2014-09-09 16:15:17 +00:00
|
|
|
)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2019-07-19 10:55:38 +00:00
|
|
|
for (i = 0; i < DEFAULT_MAX_PADS; ++i)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2014-06-14 21:07:58 +00:00
|
|
|
if (!qnx->devices[i].handle)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2014-06-14 21:07:58 +00:00
|
|
|
qnx->devices[i].handle = device;
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_handle_device(qnx, &qnx->devices[i]);
|
2013-04-07 16:14:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-07-19 10:55:38 +00:00
|
|
|
for (i = 0; i < DEFAULT_MAX_PADS; ++i)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2014-06-14 21:07:58 +00:00
|
|
|
if (device == qnx->devices[i].handle)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2014-09-09 16:15:17 +00:00
|
|
|
RARCH_LOG("Device %s: Disconnected.\n",
|
|
|
|
qnx->devices[i].id);
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_init_controller(qnx, &qnx->devices[i]);
|
2013-04-07 16:14:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-07 16:14:28 +00:00
|
|
|
break;
|
2013-03-20 00:21:45 +00:00
|
|
|
#endif
|
2013-04-07 16:14:28 +00:00
|
|
|
default:
|
|
|
|
break;
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-02 22:57:41 +00:00
|
|
|
static void qnx_handle_navigator_event(
|
|
|
|
qnx_input_t *qnx, bps_event_t *event)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
|
|
|
bps_event_t *event_pause = NULL;
|
|
|
|
|
|
|
|
switch (bps_event_get_code(event))
|
|
|
|
{
|
2017-01-07 21:34:39 +00:00
|
|
|
case NAVIGATOR_SYSKEY_PRESS:
|
2017-01-17 18:02:41 +00:00
|
|
|
switch(navigator_event_get_syskey_key(event))
|
|
|
|
{
|
|
|
|
case NAVIGATOR_SYSKEY_BACK:
|
|
|
|
input_keyboard_event(true, RETROK_BACKSPACE, 0, 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
input_keyboard_event(false, RETROK_BACKSPACE, 0, 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
break;
|
|
|
|
case NAVIGATOR_SYSKEY_SEND:
|
|
|
|
case NAVIGATOR_SYSKEY_END:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2017-01-07 21:34:39 +00:00
|
|
|
}
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
2017-01-07 21:34:39 +00:00
|
|
|
case NAVIGATOR_SWIPE_DOWN:
|
|
|
|
command_event(CMD_EVENT_MENU_TOGGLE, NULL);
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
|
|
|
case NAVIGATOR_WINDOW_STATE:
|
2017-01-07 21:34:39 +00:00
|
|
|
switch(navigator_event_get_window_state(event))
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
|
|
|
case NAVIGATOR_WINDOW_THUMBNAIL:
|
2017-01-07 21:34:39 +00:00
|
|
|
case NAVIGATOR_WINDOW_INVISIBLE:
|
2020-02-01 03:19:22 +00:00
|
|
|
for (;;)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2017-01-17 18:02:41 +00:00
|
|
|
unsigned event_code;
|
|
|
|
|
2014-09-09 16:15:17 +00:00
|
|
|
/* Block until we get a resume or exit event. */
|
2017-01-07 21:34:39 +00:00
|
|
|
bps_get_event(&event_pause, -1);
|
2017-01-17 18:02:41 +00:00
|
|
|
event_code = bps_event_get_code(event_pause);
|
2013-03-20 00:21:45 +00:00
|
|
|
|
2017-01-07 21:34:39 +00:00
|
|
|
if(event_code == NAVIGATOR_WINDOW_STATE)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2017-01-07 21:34:39 +00:00
|
|
|
if(navigator_event_get_window_state(event_pause) == NAVIGATOR_WINDOW_FULLSCREEN)
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-01-07 21:34:39 +00:00
|
|
|
else if(event_code == NAVIGATOR_EXIT)
|
|
|
|
goto shutdown;
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NAVIGATOR_WINDOW_FULLSCREEN:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2017-01-07 21:34:39 +00:00
|
|
|
case NAVIGATOR_EXIT:
|
|
|
|
goto shutdown;
|
2013-03-20 00:21:45 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-01-07 21:34:39 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
shutdown:
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_SHUTDOWN, NULL);
|
2017-01-07 21:34:39 +00:00
|
|
|
return;
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 16:59:48 +00:00
|
|
|
static void *qnx_input_init(const char *joypad_driver)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
|
|
|
int i;
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)calloc(1, sizeof(*qnx));
|
|
|
|
|
2014-05-17 14:48:52 +00:00
|
|
|
if (!qnx)
|
|
|
|
return NULL;
|
2013-05-10 00:46:23 +00:00
|
|
|
|
2017-01-07 21:34:39 +00:00
|
|
|
input_keymaps_init_keyboard_lut(rarch_key_map_qnx);
|
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
for (i = 0; i < MAX_TOUCH; ++i)
|
2013-06-21 00:41:46 +00:00
|
|
|
{
|
2014-06-14 21:07:58 +00:00
|
|
|
qnx->pointer[i].contact_id = -1;
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx->touch_map[i] = -1;
|
2013-06-21 00:41:46 +00:00
|
|
|
}
|
2013-03-20 00:21:45 +00:00
|
|
|
|
2017-01-10 16:59:48 +00:00
|
|
|
qnx->joypad = input_joypad_init_driver(joypad_driver, qnx);
|
2014-06-14 21:07:58 +00:00
|
|
|
|
2019-07-19 10:55:38 +00:00
|
|
|
for (i = 0; i < DEFAULT_MAX_PADS; ++i)
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_init_controller(qnx, &qnx->devices[i]);
|
2014-06-14 21:07:58 +00:00
|
|
|
|
2013-04-08 16:06:42 +00:00
|
|
|
#ifdef HAVE_BB10
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_discover_controllers(qnx);
|
2013-04-08 16:06:42 +00:00
|
|
|
#else
|
2014-09-09 16:15:17 +00:00
|
|
|
/* Initialize Playbook keyboard. */
|
|
|
|
strlcpy(qnx->devices[0].id, "0A5C-8502",
|
|
|
|
sizeof(qnx->devices[0].id));
|
2017-01-07 21:34:39 +00:00
|
|
|
qnx_input_autodetect_gamepad(qnx, &qnx->devices[0]);
|
2014-06-10 19:08:09 +00:00
|
|
|
qnx->pads_connected = 1;
|
2013-04-07 16:14:28 +00:00
|
|
|
#endif
|
|
|
|
|
2014-05-17 14:48:52 +00:00
|
|
|
return qnx;
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qnx_input_poll(void *data)
|
|
|
|
{
|
2015-04-02 22:57:41 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
2015-03-21 04:42:49 +00:00
|
|
|
|
|
|
|
/* Request and process all available BPS events. */
|
2020-02-01 03:19:22 +00:00
|
|
|
for (;;)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
|
|
|
bps_event_t *event = NULL;
|
2020-06-10 02:00:40 +00:00
|
|
|
int rc = bps_get_event(&event, 0);
|
2015-04-02 22:57:41 +00:00
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
if(rc == BPS_SUCCESS)
|
|
|
|
{
|
2015-04-02 22:57:41 +00:00
|
|
|
int domain;
|
|
|
|
|
|
|
|
if (!event)
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
2015-04-02 22:57:41 +00:00
|
|
|
|
|
|
|
domain = bps_event_get_domain(event);
|
|
|
|
if (domain == navigator_get_domain())
|
|
|
|
qnx_handle_navigator_event(qnx, event);
|
|
|
|
else if (domain == screen_get_domain())
|
|
|
|
qnx_handle_screen_event(qnx, event);
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-06 03:17:25 +00:00
|
|
|
static bool qnx_keyboard_pressed(qnx_input_t *qnx, unsigned id)
|
2014-09-30 14:50:28 +00:00
|
|
|
{
|
2017-06-06 03:17:25 +00:00
|
|
|
unsigned bit = rarch_keysym_lut[(enum retro_key)id];
|
2017-01-07 21:34:39 +00:00
|
|
|
return id < RETROK_LAST && BIT_GET(qnx->keyboard_state, bit);
|
2014-09-30 14:50:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int16_t qnx_pointer_input_state(qnx_input_t *qnx,
|
2017-01-07 21:34:39 +00:00
|
|
|
unsigned idx, unsigned id, bool screen)
|
2014-09-30 14:50:28 +00:00
|
|
|
{
|
2017-01-07 21:34:39 +00:00
|
|
|
int16_t x;
|
|
|
|
int16_t y;
|
|
|
|
|
|
|
|
if(screen)
|
|
|
|
{
|
|
|
|
x = qnx->pointer[idx].full_x;
|
|
|
|
y = qnx->pointer[idx].full_y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = qnx->pointer[idx].x;
|
|
|
|
y = qnx->pointer[idx].y;
|
|
|
|
}
|
|
|
|
|
2014-09-30 14:50:28 +00:00
|
|
|
switch (id)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_ID_POINTER_X:
|
2017-01-07 21:34:39 +00:00
|
|
|
return x;
|
2014-09-30 14:50:28 +00:00
|
|
|
case RETRO_DEVICE_ID_POINTER_Y:
|
2017-01-07 21:34:39 +00:00
|
|
|
return y;
|
2014-09-30 14:50:28 +00:00
|
|
|
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
2017-01-07 21:34:39 +00:00
|
|
|
return (idx < qnx->pointer_count)
|
|
|
|
&& (x != -0x8000)
|
|
|
|
&& (y != -0x8000);
|
2014-09-30 14:50:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-09 16:15:17 +00:00
|
|
|
static int16_t qnx_input_state(void *data,
|
2020-02-27 06:33:14 +00:00
|
|
|
rarch_joypad_info_t *joypad_info,
|
2016-05-19 18:02:39 +00:00
|
|
|
const struct retro_keybind **binds,
|
2014-10-20 18:31:00 +00:00
|
|
|
unsigned port, unsigned device, unsigned idx, unsigned id)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2019-06-23 04:09:45 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
2013-03-20 00:21:45 +00:00
|
|
|
|
|
|
|
switch (device)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_JOYPAD:
|
2019-06-23 04:09:45 +00:00
|
|
|
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
|
|
|
{
|
|
|
|
unsigned i;
|
2019-07-21 23:20:00 +00:00
|
|
|
int16_t ret = 0;
|
2020-07-13 23:39:07 +00:00
|
|
|
|
|
|
|
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
2020-06-13 00:13:32 +00:00
|
|
|
{
|
2020-07-13 23:39:07 +00:00
|
|
|
if (binds[port][i].valid)
|
2020-06-13 00:13:32 +00:00
|
|
|
{
|
2020-07-13 23:39:07 +00:00
|
|
|
if (button_is_pressed(
|
|
|
|
qnx->joypad,
|
|
|
|
joypad_info, binds[port], port, i))
|
|
|
|
ret |= (1 << i);
|
2020-06-13 00:13:32 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-13 23:39:07 +00:00
|
|
|
|
|
|
|
if (!input_qnx.keyboard_mapping_blocked)
|
2019-06-23 04:09:45 +00:00
|
|
|
{
|
2020-06-13 00:13:32 +00:00
|
|
|
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
2019-07-21 23:20:00 +00:00
|
|
|
{
|
2020-06-13 00:13:32 +00:00
|
|
|
if (binds[port][i].valid)
|
|
|
|
{
|
2020-07-13 23:39:07 +00:00
|
|
|
if (qnx_keyboard_pressed(qnx, key))
|
2020-06-13 00:13:32 +00:00
|
|
|
ret |= (1 << i);
|
|
|
|
}
|
2019-07-21 23:20:00 +00:00
|
|
|
}
|
2019-06-23 04:09:45 +00:00
|
|
|
}
|
2019-07-21 23:20:00 +00:00
|
|
|
|
|
|
|
return ret;
|
2019-06-23 04:09:45 +00:00
|
|
|
}
|
|
|
|
else
|
2020-06-12 16:28:07 +00:00
|
|
|
{
|
|
|
|
if (id < RARCH_BIND_LIST_END)
|
|
|
|
{
|
|
|
|
if (binds[port][id].valid)
|
|
|
|
{
|
2020-06-13 00:13:32 +00:00
|
|
|
if (button_is_pressed(qnx->joypad,
|
2020-06-12 16:28:07 +00:00
|
|
|
joypad_info, binds[port], port, id))
|
|
|
|
return 1;
|
2020-06-13 00:13:32 +00:00
|
|
|
else if (
|
|
|
|
((id == RARCH_GAME_FOCUS_TOGGLE) ||
|
|
|
|
!input_qnx.keyboard_mapping_blocked) &&
|
|
|
|
qnx_keyboard_pressed(qnx, key)
|
|
|
|
)
|
|
|
|
return 1;
|
2020-06-12 16:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-21 23:20:00 +00:00
|
|
|
break;
|
2020-04-01 14:18:05 +00:00
|
|
|
case RETRO_DEVICE_ANALOG:
|
2020-06-23 16:31:40 +00:00
|
|
|
break;
|
2017-01-07 21:34:39 +00:00
|
|
|
case RETRO_DEVICE_KEYBOARD:
|
2017-01-10 16:05:04 +00:00
|
|
|
return qnx_keyboard_pressed(qnx, id);
|
2013-06-11 22:59:41 +00:00
|
|
|
case RETRO_DEVICE_POINTER:
|
2017-01-07 21:34:39 +00:00
|
|
|
case RARCH_DEVICE_POINTER_SCREEN:
|
|
|
|
return qnx_pointer_input_state(qnx, idx, id, device == RARCH_DEVICE_POINTER_SCREEN);
|
|
|
|
default:
|
2020-06-10 02:00:40 +00:00
|
|
|
break;
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qnx_input_free_input(void *data)
|
|
|
|
{
|
2015-07-12 06:39:34 +00:00
|
|
|
if (data)
|
|
|
|
free(data);
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
|
2013-11-02 20:16:57 +00:00
|
|
|
static uint64_t qnx_input_get_capabilities(void *data)
|
|
|
|
{
|
2017-01-07 21:34:39 +00:00
|
|
|
(void)data;
|
2014-05-17 20:16:25 +00:00
|
|
|
|
2017-01-07 21:34:39 +00:00
|
|
|
return
|
|
|
|
(1 << RETRO_DEVICE_JOYPAD) |
|
|
|
|
(1 << RETRO_DEVICE_POINTER) |
|
2013-11-02 20:16:57 +00:00
|
|
|
#ifdef HAVE_BB10
|
2017-01-07 21:34:39 +00:00
|
|
|
(1 << RETRO_DEVICE_ANALOG) |
|
2013-11-02 20:16:57 +00:00
|
|
|
#endif
|
2017-01-07 21:34:39 +00:00
|
|
|
(1 << RETRO_DEVICE_KEYBOARD);
|
2013-11-02 20:16:57 +00:00
|
|
|
}
|
|
|
|
|
2015-04-14 14:37:59 +00:00
|
|
|
static const input_device_driver_t *qnx_input_get_joypad_driver(void *data)
|
2014-04-17 18:47:11 +00:00
|
|
|
{
|
2014-06-14 21:07:58 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
|
|
|
return qnx->joypad;
|
2014-04-17 18:47:11 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 05:06:20 +00:00
|
|
|
input_driver_t input_qnx = {
|
2013-03-20 00:21:45 +00:00
|
|
|
qnx_input_init,
|
|
|
|
qnx_input_poll,
|
|
|
|
qnx_input_state,
|
|
|
|
qnx_input_free_input,
|
2014-06-14 21:07:58 +00:00
|
|
|
NULL,
|
2013-11-02 23:27:58 +00:00
|
|
|
NULL,
|
2013-11-02 20:16:57 +00:00
|
|
|
qnx_input_get_capabilities,
|
2013-03-20 00:21:45 +00:00
|
|
|
"qnx_input",
|
2015-05-19 17:33:58 +00:00
|
|
|
NULL,
|
2017-01-07 21:34:39 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-06-14 21:07:58 +00:00
|
|
|
qnx_input_get_joypad_driver,
|
2015-11-16 01:39:38 +00:00
|
|
|
NULL,
|
2019-07-27 00:21:24 +00:00
|
|
|
false
|
2014-06-14 21:07:58 +00:00
|
|
|
};
|