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
|
|
|
|
* Copyright (C) 2011-2014 - Daniel De Matteis
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2013-05-10 22:49:48 +00:00
|
|
|
#include "../general.h"
|
|
|
|
#include "../driver.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>
|
2013-03-20 00:21:45 +00:00
|
|
|
|
2013-05-10 00:46:23 +00:00
|
|
|
#include "frontend_qnx.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
|
|
|
|
|
|
|
struct touches
|
|
|
|
{
|
|
|
|
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
|
|
|
};
|
|
|
|
|
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
|
|
|
struct touches touch[MAX_TOUCH];
|
|
|
|
unsigned touch_count;
|
|
|
|
|
|
|
|
int touch_map[MAX_TOUCH];
|
|
|
|
/*The first touch_count indices of touch_map will be a valid, active index in touch array.
|
|
|
|
* Saves us from searching through touch array when polling state.
|
|
|
|
*/
|
2014-06-10 19:04:00 +00:00
|
|
|
input_device_t *port_device[MAX_PADS];
|
2014-05-17 14:48:52 +00:00
|
|
|
} qnx_input_t;
|
2013-03-20 00:21:45 +00:00
|
|
|
|
2013-04-08 16:06:42 +00:00
|
|
|
input_device_t devices[MAX_PADS];
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2013-06-19 00:37:28 +00:00
|
|
|
static unsigned screen_width, screen_height;
|
|
|
|
|
2013-04-08 16:06:42 +00:00
|
|
|
|
2014-06-10 19:04:00 +00:00
|
|
|
static void qnx_input_autodetect_gamepad(void *data, input_device_t* controller);
|
|
|
|
static void initController(void *data, input_device_t* controller);
|
2013-04-08 16:06:42 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_BB10
|
2014-05-17 14:48:52 +00:00
|
|
|
static void process_gamepad_event(void *data, 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;
|
2014-05-17 14:48:52 +00:00
|
|
|
input_device_t* controller = NULL;
|
|
|
|
|
2014-05-17 20:16:25 +00:00
|
|
|
(void)data;
|
|
|
|
(void)type;
|
|
|
|
|
2013-04-07 16:14:28 +00:00
|
|
|
screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_DEVICE, (void**)&device);
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PADS; ++i)
|
|
|
|
{
|
|
|
|
if (device == devices[i].handle)
|
|
|
|
{
|
|
|
|
controller = &devices[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!controller)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Store the controller's new state.
|
|
|
|
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS, &controller->buttons);
|
|
|
|
|
|
|
|
if (controller->analogCount > 0)
|
|
|
|
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG0, controller->analog0);
|
|
|
|
|
|
|
|
if (controller->analogCount == 2)
|
|
|
|
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG1, controller->analog1);
|
2013-06-12 03:18:06 +00:00
|
|
|
|
|
|
|
//Only player 1
|
|
|
|
//TODO: Am I missing something? Is there a better way?
|
|
|
|
if((controller->port == 0) && (controller->buttons & g_settings.input.binds[0][RARCH_MENU_TOGGLE].joykey))
|
|
|
|
g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE);
|
2013-04-07 16:14:28 +00:00
|
|
|
}
|
|
|
|
|
2014-06-10 19:04:00 +00:00
|
|
|
static void loadController(void *data, input_device_t* controller)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
|
|
|
int device;
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2014-05-17 20:16:25 +00:00
|
|
|
(void)device;
|
|
|
|
|
2014-06-10 19:04:00 +00:00
|
|
|
if (!qnx)
|
|
|
|
return;
|
|
|
|
|
2013-04-07 16:14:28 +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, SCREEN_PROPERTY_VENDOR, sizeof(controller->id), controller->vendor);
|
|
|
|
screen_get_device_property_cv(controller->handle, SCREEN_PROPERTY_PRODUCT, sizeof(controller->id), controller->product);
|
|
|
|
|
2013-04-08 14:21:43 +00:00
|
|
|
if (controller->type == SCREEN_EVENT_GAMEPAD || controller->type == SCREEN_EVENT_JOYSTICK)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2013-04-08 14:21:43 +00:00
|
|
|
screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_BUTTON_COUNT, &controller->buttonCount);
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2013-04-08 14:21:43 +00:00
|
|
|
// Check for the existence of analog sticks.
|
|
|
|
if (!screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG0, controller->analog0))
|
|
|
|
++controller->analogCount;
|
|
|
|
|
|
|
|
if (!screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG1, controller->analog1))
|
|
|
|
++controller->analogCount;
|
2013-04-07 16:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Screen service will map supported controllers, we still might need to adjust.
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx_input_autodetect_gamepad(qnx, controller);
|
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);
|
|
|
|
RARCH_LOG("\tVendor: %s\n", controller->vendor);
|
|
|
|
RARCH_LOG("\tProduct: %s\n", controller->product);
|
|
|
|
RARCH_LOG("\tButton Count: %d\n", controller->buttonCount);
|
|
|
|
RARCH_LOG("\tAnalog Count: %d\n", controller->analogCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern screen_context_t screen_ctx;
|
2014-06-10 19:04:00 +00:00
|
|
|
|
|
|
|
static void discoverControllers(void *data)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
|
|
|
// Get an array of all available devices.
|
2014-05-17 20:16:25 +00:00
|
|
|
int deviceCount;
|
|
|
|
unsigned i;
|
2013-07-07 18:49:50 +00:00
|
|
|
screen_event_t *event;
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
2013-07-07 18:49:50 +00:00
|
|
|
|
2014-05-17 20:16:25 +00:00
|
|
|
(void)event;
|
|
|
|
|
2013-04-07 16:14:28 +00:00
|
|
|
screen_get_context_property_iv(screen_ctx, SCREEN_PROPERTY_DEVICE_COUNT, &deviceCount);
|
|
|
|
screen_device_t* devices_found = (screen_device_t*)calloc(deviceCount, sizeof(screen_device_t));
|
|
|
|
screen_get_context_property_pv(screen_ctx, SCREEN_PROPERTY_DEVICES, (void**)devices_found);
|
|
|
|
|
|
|
|
// Scan the list for gamepad and joystick devices.
|
2014-06-10 19:04:00 +00:00
|
|
|
for(i = 0; i < qnx->pads_connected; ++i)
|
|
|
|
initController(qnx, &devices[i]);
|
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;
|
|
|
|
screen_get_device_property_iv(devices_found[i], SCREEN_PROPERTY_TYPE, &type);
|
|
|
|
|
2013-04-08 14:21:43 +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-10 19:04:00 +00:00
|
|
|
devices[qnx->pads_connected].handle = devices_found[i];
|
|
|
|
devices[qnx->pads_connected].index = qnx->pads_connected;
|
|
|
|
loadController(qnx, &devices[qnx->pads_connected]);
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2014-06-10 19:04:00 +00:00
|
|
|
if (qnx->pads_connected == MAX_PADS)
|
2013-04-07 16:14:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(devices_found);
|
|
|
|
}
|
2013-04-08 16:06:42 +00:00
|
|
|
#endif
|
|
|
|
|
2014-06-10 19:04:00 +00:00
|
|
|
static void initController(void *data, input_device_t* controller)
|
2013-04-08 16:06:42 +00:00
|
|
|
{
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
|
|
|
if (!qnx)
|
|
|
|
return;
|
|
|
|
|
2013-04-08 16:06:42 +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] = controller->analog0[1] = controller->analog0[2] = 0;
|
|
|
|
controller->analog1[0] = controller->analog1[1] = controller->analog1[2] = 0;
|
2013-05-10 00:46:23 +00:00
|
|
|
controller->port = -1;
|
|
|
|
controller->device = -1;
|
2013-08-03 19:36:09 +00:00
|
|
|
controller->index = -1;
|
2013-04-08 16:06:42 +00:00
|
|
|
memset(controller->id, 0, sizeof(controller->id));
|
|
|
|
}
|
|
|
|
|
2014-06-10 19:04:00 +00:00
|
|
|
static void qnx_input_autodetect_gamepad(void *data, input_device_t* controller)
|
2013-04-08 16:06:42 +00:00
|
|
|
{
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
|
|
|
|
|
|
|
if (!qnx)
|
|
|
|
return;
|
|
|
|
|
2013-04-08 16:06:42 +00:00
|
|
|
//ID: A-BBBB-CCCC-D.D
|
|
|
|
//A is the device's index in the array returned by screen_get_context_property_pv()
|
|
|
|
//BBBB is the device's Vendor ID (in hexadecimal)
|
|
|
|
//CCCC is the device's Product ID (also in hexadecimal)
|
|
|
|
//D.D is the device's version number
|
2014-05-19 18:06:13 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-04-08 16:06:42 +00:00
|
|
|
if (strstr(controller->id, "057E-0306"))
|
2013-05-10 00:46:23 +00:00
|
|
|
{
|
|
|
|
controller->device = DEVICE_WIIMOTE;
|
|
|
|
strlcpy(controller->device_name, "Wiimote", sizeof(controller->device_name));
|
|
|
|
}
|
2014-05-19 18:06:13 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (strstr(controller->id, "0A5C-8502"))
|
2013-05-10 00:46:23 +00:00
|
|
|
{
|
|
|
|
controller->device = DEVICE_KEYBOARD;
|
|
|
|
strlcpy(controller->device_name, "BlackBerry BT Keyboard", sizeof(controller->device_name));
|
|
|
|
}
|
2014-05-19 18:06:13 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-05-07 22:52:02 +00:00
|
|
|
else if (strstr(controller->id, "qwerty:bb35"))
|
2013-05-10 00:46:23 +00:00
|
|
|
{
|
|
|
|
controller->device = DEVICE_KEYPAD;
|
|
|
|
strlcpy(controller->device_name, "BlackBerry Q10 Keypad", sizeof(controller->device_name));
|
|
|
|
}
|
2014-05-19 18:06:13 +00:00
|
|
|
#endif
|
2013-06-11 23:38:10 +00:00
|
|
|
else if (strstr(controller->id, "BB-VKB"))
|
|
|
|
{
|
2013-06-13 00:32:41 +00:00
|
|
|
controller->device = DEVICE_NONE;
|
|
|
|
strlcpy(controller->device_name, "None", sizeof(controller->device_name));
|
2013-06-11 23:38:10 +00:00
|
|
|
}
|
2014-05-19 18:06:13 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-05-10 00:46:23 +00:00
|
|
|
else if (controller->id[0])
|
|
|
|
{
|
|
|
|
controller->device = DEVICE_UNKNOWN;
|
|
|
|
strlcpy(controller->device_name, "Unknown", sizeof(controller->device_name));
|
|
|
|
}
|
2014-05-19 18:06:13 +00:00
|
|
|
#endif
|
2013-04-08 16:06:42 +00:00
|
|
|
else
|
2013-05-10 00:46:23 +00:00
|
|
|
{
|
|
|
|
controller->device = DEVICE_NONE;
|
|
|
|
strlcpy(controller->device_name, "None", sizeof(controller->device_name));
|
|
|
|
}
|
2013-04-07 16:14:28 +00:00
|
|
|
|
2013-08-03 19:36:09 +00:00
|
|
|
if (input_qnx.set_keybinds && (controller->device != DEVICE_NONE))
|
|
|
|
{
|
2014-06-10 19:04:00 +00:00
|
|
|
input_qnx.set_keybinds((void*)controller, controller->device, qnx->pads_connected, 0,
|
2013-04-08 16:06:42 +00:00
|
|
|
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx->pads_connected++;
|
2013-08-03 19:36:09 +00:00
|
|
|
}
|
2013-04-08 16:06:42 +00:00
|
|
|
}
|
2013-04-08 14:21:43 +00:00
|
|
|
|
2014-05-17 14:48:52 +00:00
|
|
|
static void process_keyboard_event(void *data, screen_event_t event, int type)
|
2013-04-08 14:21:43 +00:00
|
|
|
{
|
2013-04-08 16:06:42 +00:00
|
|
|
input_device_t* controller = NULL;
|
2014-05-17 14:48:52 +00:00
|
|
|
int i, b, sym, modifiers, flags, scan, cap;
|
|
|
|
|
2014-05-17 20:16:25 +00:00
|
|
|
(void)data;
|
|
|
|
(void)type;
|
|
|
|
|
2014-05-17 14:48:52 +00:00
|
|
|
i = 0;
|
|
|
|
sym = 0;
|
|
|
|
modifiers = 0;
|
|
|
|
flags = 0;
|
|
|
|
scan = 0;
|
|
|
|
cap = 0;
|
2013-04-08 16:06:42 +00:00
|
|
|
|
2013-04-08 14:21:43 +00:00
|
|
|
//Get Keyboard state
|
|
|
|
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym);
|
|
|
|
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers);
|
|
|
|
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags);
|
|
|
|
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan);
|
|
|
|
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap);
|
|
|
|
|
2013-04-08 16:06:42 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-04-08 14:21:43 +00:00
|
|
|
//Find device that pressed the key
|
|
|
|
screen_device_t device;
|
2014-05-17 14:48:52 +00:00
|
|
|
|
2013-04-08 14:21:43 +00:00
|
|
|
screen_get_event_property_pv(event, SCREEN_PROPERTY_DEVICE, (void**)&device);
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PADS; ++i)
|
|
|
|
{
|
|
|
|
if (device == devices[i].handle)
|
|
|
|
{
|
|
|
|
controller = &devices[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!controller)
|
|
|
|
return;
|
2013-04-08 16:06:42 +00:00
|
|
|
#else
|
|
|
|
controller = &devices[0];
|
|
|
|
#endif
|
2013-04-08 14:21:43 +00:00
|
|
|
|
2013-05-10 00:46:23 +00:00
|
|
|
if(controller->port == -1)
|
|
|
|
return;
|
|
|
|
|
2013-04-08 14:21:43 +00:00
|
|
|
for (b = 0; b < RARCH_FIRST_CUSTOM_BIND; ++b)
|
|
|
|
{
|
2013-05-10 00:46:23 +00:00
|
|
|
if ((unsigned int)g_settings.input.binds[controller->port][b].joykey == (unsigned int)(sym&0xFF))
|
2013-04-08 14:21:43 +00:00
|
|
|
{
|
|
|
|
if (flags & KEY_DOWN)
|
|
|
|
controller->buttons |= 1 << b;
|
|
|
|
else
|
|
|
|
controller->buttons &= ~(1<<b);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-06-12 03:18:06 +00:00
|
|
|
|
|
|
|
//TODO: Am I missing something? Is there a better way?
|
|
|
|
if((controller->port == 0) && ((unsigned int)g_settings.input.binds[0][RARCH_MENU_TOGGLE].joykey == (unsigned int)(sym&0xFF)))
|
2013-06-13 00:32:41 +00:00
|
|
|
if (flags & KEY_DOWN)
|
|
|
|
g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE);
|
2013-04-08 14:21:43 +00:00
|
|
|
}
|
2013-04-08 16:06:42 +00:00
|
|
|
|
2014-05-17 14:48:52 +00:00
|
|
|
static void process_touch_event(void *data, 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;
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
2013-03-20 00:21:45 +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);
|
|
|
|
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case SCREEN_EVENT_MTOUCH_TOUCH:
|
2013-06-21 00:41:46 +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-05-17 14:48:52 +00:00
|
|
|
if(qnx->touch[i].contact_id == -1)
|
2013-06-21 00:41:46 +00:00
|
|
|
{
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx->touch[i].contact_id = contact_id;
|
2013-06-21 00:41:46 +00:00
|
|
|
input_translate_coord_viewport(pos[0], pos[1],
|
2014-05-17 14:48:52 +00:00
|
|
|
&qnx->touch[i].x, &qnx->touch[i].y,
|
|
|
|
&qnx->touch[i].full_x, &qnx->touch[i].full_y);
|
2013-06-21 00:41:46 +00:00
|
|
|
//Add this touch to the map to signal it's valid
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx->touch[i].map = qnx->touch_count;
|
|
|
|
qnx->touch_map[qnx->touch_count] = i;
|
|
|
|
qnx->touch_count++;
|
2013-06-21 00:41:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-03-20 00:21:45 +00:00
|
|
|
//printf("New Touch: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout);
|
2014-05-17 14:48:52 +00:00
|
|
|
//printf("Map: %d %d %d %d %d %d\n", qnx->touch_map[0], qnx->touch_map[1], qnx->touch_map[2], qnx->touch_map[3], qnx->touch_map[4], qnx->touch_map[5]);fflush(stdout);
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
|
|
|
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-05-17 14:48:52 +00:00
|
|
|
if(qnx->touch[i].contact_id == contact_id)
|
2013-06-21 00:41:46 +00:00
|
|
|
{
|
|
|
|
//Invalidate the finger
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx->touch[i].contact_id = -1;
|
2013-06-21 00:41:46 +00:00
|
|
|
|
|
|
|
//Remove touch from map and shift remaining valid ones to the front
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx->touch_map[qnx->touch[i].map] = -1;
|
|
|
|
for(j = qnx->touch[i].map; j < qnx->touch_count; ++j)
|
2013-06-21 00:41:46 +00:00
|
|
|
{
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx->touch_map[j] = qnx->touch_map[j+1];
|
|
|
|
qnx->touch[qnx->touch_map[j+1]].map = j;
|
|
|
|
qnx->touch_map[j+1] = -1;
|
2013-06-21 00:41:46 +00:00
|
|
|
}
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx->touch_count--;
|
2013-06-21 00:41:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-03-20 00:21:45 +00:00
|
|
|
//printf("Release: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout);
|
2014-05-17 14:48:52 +00:00
|
|
|
//printf("Map: %d %d %d %d %d %d\n", qnx->touch_map[0], qnx->touch_map[1], qnx->touch_map[2], qnx->touch_map[3], qnx->touch_map[4], qnx->touch_map[5]);fflush(stdout);
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
|
|
|
case SCREEN_EVENT_MTOUCH_MOVE:
|
|
|
|
//Find the finger we're tracking and update
|
2014-05-17 14:48:52 +00:00
|
|
|
for(i = 0; i < qnx->touch_count; ++i)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2014-05-17 14:48:52 +00:00
|
|
|
if(qnx->touch[i].contact_id == contact_id)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2013-06-19 00:37:28 +00:00
|
|
|
//During a move, we can go ~30 pixel into the bezel which gives negative
|
|
|
|
//numbers or numbers larger than the screen res. Normalize.
|
|
|
|
if(pos[0] < 0)
|
|
|
|
pos[0] = 0;
|
|
|
|
if(pos[0] > screen_width)
|
|
|
|
pos[0] = screen_width;
|
|
|
|
|
|
|
|
if(pos[1] < 0)
|
|
|
|
pos[1] = 0;
|
|
|
|
if(pos[1] > screen_height)
|
|
|
|
pos[1] = screen_height;
|
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
input_translate_coord_viewport(pos[0], pos[1],
|
2014-05-17 14:48:52 +00:00
|
|
|
&qnx->touch[i].x, &qnx->touch[i].y,
|
|
|
|
&qnx->touch[i].full_x, &qnx->touch[i].full_y);
|
2013-03-20 00:21:45 +00:00
|
|
|
//printf("Move: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout);
|
2013-06-21 00:41:46 +00:00
|
|
|
break;
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-17 14:48:52 +00:00
|
|
|
static void handle_screen_event(void *data, bps_event_t *event)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
|
|
|
int type;
|
|
|
|
|
|
|
|
screen_event_t screen_event = screen_event_get_event(event);
|
|
|
|
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:
|
2014-05-17 14:48:52 +00:00
|
|
|
process_touch_event(data, screen_event, type);
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
|
|
|
case SCREEN_EVENT_KEYBOARD:
|
2014-05-17 14:48:52 +00:00
|
|
|
process_keyboard_event(data, 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:
|
|
|
|
case SCREEN_EVENT_JOYSTICK:
|
2014-05-17 14:48:52 +00:00
|
|
|
process_gamepad_event(data, screen_event, type);
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
|
|
|
case SCREEN_EVENT_DEVICE:
|
|
|
|
{
|
|
|
|
// A device was attached or removed.
|
|
|
|
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);
|
|
|
|
|
2013-04-08 14:21:43 +00:00
|
|
|
if (attached && (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK || type == SCREEN_EVENT_KEYBOARD))
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2013-04-07 16:14:28 +00:00
|
|
|
for (i = 0; i < MAX_PADS; ++i)
|
|
|
|
{
|
|
|
|
if (!devices[i].handle)
|
|
|
|
{
|
|
|
|
devices[i].handle = device;
|
2014-06-10 19:04:00 +00:00
|
|
|
loadController(data, &devices[i]);
|
2013-04-07 16:14:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-07 16:14:28 +00:00
|
|
|
for (i = 0; i < MAX_PADS; ++i)
|
|
|
|
{
|
|
|
|
if (device == devices[i].handle)
|
|
|
|
{
|
|
|
|
RARCH_LOG("Device %s: Disconnected.\n", devices[i].id);
|
2014-06-10 19:04:00 +00:00
|
|
|
initController(data, &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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-17 14:48:52 +00:00
|
|
|
static void handle_navigator_event(void *data, bps_event_t *event)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
|
|
|
navigator_window_state_t state;
|
|
|
|
bps_event_t *event_pause = NULL;
|
|
|
|
int rc;
|
|
|
|
|
2014-05-17 20:16:25 +00:00
|
|
|
(void)data;
|
|
|
|
(void)rc;
|
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
switch (bps_event_get_code(event))
|
|
|
|
{
|
|
|
|
case NAVIGATOR_SWIPE_DOWN:
|
2013-03-23 16:21:30 +00:00
|
|
|
g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE);
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
|
|
|
case NAVIGATOR_EXIT:
|
|
|
|
//Catch this in thumbnail loop
|
|
|
|
break;
|
|
|
|
case NAVIGATOR_WINDOW_STATE:
|
|
|
|
state = navigator_event_get_window_state(event);
|
|
|
|
|
|
|
|
switch(state)
|
|
|
|
{
|
|
|
|
case NAVIGATOR_WINDOW_THUMBNAIL:
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
//Block until we get a resume or exit event
|
|
|
|
rc = bps_get_event(&event_pause, -1);
|
|
|
|
|
|
|
|
if(bps_event_get_code(event_pause) == NAVIGATOR_WINDOW_STATE)
|
|
|
|
{
|
|
|
|
state = navigator_event_get_window_state(event_pause);
|
|
|
|
if(state == NAVIGATOR_WINDOW_FULLSCREEN)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (bps_event_get_code(event_pause) == NAVIGATOR_EXIT)
|
|
|
|
{
|
2014-06-02 07:52:30 +00:00
|
|
|
g_extern.system.shutdown = true;
|
2013-03-20 00:21:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NAVIGATOR_WINDOW_FULLSCREEN:
|
|
|
|
break;
|
|
|
|
case NAVIGATOR_WINDOW_INVISIBLE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//External Functions
|
|
|
|
static void *qnx_input_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)calloc(1, sizeof(*qnx));
|
|
|
|
if (!qnx)
|
|
|
|
return NULL;
|
2013-05-10 00:46:23 +00:00
|
|
|
|
2013-06-21 00:41:46 +00:00
|
|
|
//Get screen dimensions
|
|
|
|
if(gfx_ctx_bbqnx.get_video_size)
|
2014-05-17 12:36:15 +00:00
|
|
|
gfx_ctx_bbqnx.get_video_size(driver.video_data, &screen_width, &screen_height);
|
2013-06-21 00:41:46 +00:00
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
for (i = 0; i < MAX_TOUCH; ++i)
|
2013-06-21 00:41:46 +00:00
|
|
|
{
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx->touch[i].contact_id = -1;
|
|
|
|
qnx->touch_map[i] = -1;
|
2013-06-21 00:41:46 +00:00
|
|
|
}
|
2013-03-20 00:21:45 +00:00
|
|
|
|
2013-04-07 16:14:28 +00:00
|
|
|
for (i = 0; i < MAX_PADS; ++i)
|
2013-05-10 00:46:23 +00:00
|
|
|
{
|
2014-06-10 19:04:00 +00:00
|
|
|
initController(qnx, &devices[i]);
|
|
|
|
qnx->port_device[i] = 0;
|
2013-05-10 00:46:23 +00:00
|
|
|
}
|
2013-04-08 16:06:42 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-04-07 16:14:28 +00:00
|
|
|
//Find currently connected gamepads
|
2014-06-10 19:04:00 +00:00
|
|
|
discoverControllers(qnx);
|
2013-04-08 16:06:42 +00:00
|
|
|
#else
|
2014-06-10 19:08:09 +00:00
|
|
|
//Initialize Playbook keyboard
|
|
|
|
strlcpy(devices[0].id, "0A5C-8502", sizeof(devices[0].id));
|
|
|
|
qnx_input_autodetect_gamepad(qnx, &devices[0]);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
//Request and process all available BPS events
|
|
|
|
|
|
|
|
int rc, domain;
|
|
|
|
|
2013-03-23 16:21:30 +00:00
|
|
|
g_extern.lifecycle_state &= ~(1ULL << RARCH_MENU_TOGGLE);
|
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
bps_event_t *event = NULL;
|
|
|
|
rc = bps_get_event(&event, 0);
|
|
|
|
if(rc == BPS_SUCCESS)
|
|
|
|
{
|
|
|
|
if (event)
|
|
|
|
{
|
|
|
|
domain = bps_event_get_domain(event);
|
|
|
|
if (domain == navigator_get_domain())
|
2014-05-17 14:48:52 +00:00
|
|
|
handle_navigator_event(data, event);
|
2013-03-20 00:21:45 +00:00
|
|
|
else if (domain == screen_get_domain())
|
2014-05-17 14:48:52 +00:00
|
|
|
handle_screen_event(data, event);
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int16_t qnx_input_state(void *data, const struct retro_keybind **retro_keybinds, unsigned port, unsigned device, unsigned index, unsigned id)
|
|
|
|
{
|
2014-05-17 14:48:52 +00:00
|
|
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
2013-03-20 00:21:45 +00:00
|
|
|
|
|
|
|
switch (device)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_JOYPAD:
|
2014-06-10 19:04:00 +00:00
|
|
|
if(qnx->port_device[port])
|
2013-05-10 00:46:23 +00:00
|
|
|
{
|
2014-06-10 19:04:00 +00:00
|
|
|
if (qnx->port_device[port]->device == DEVICE_KEYBOARD
|
2014-05-19 18:06:13 +00:00
|
|
|
#ifdef HAVE_BB10
|
2014-06-10 19:04:00 +00:00
|
|
|
|| qnx->port_device[port]->device == DEVICE_KEYPAD
|
2014-05-19 18:06:13 +00:00
|
|
|
#endif
|
2014-06-10 19:04:00 +00:00
|
|
|
)
|
|
|
|
return ((qnx->port_device[port]->buttons & (1 << id)) && (port < qnx->pads_connected) );
|
|
|
|
return ((qnx->port_device[port]->buttons & retro_keybinds[port][id].joykey) && (port < qnx->pads_connected));
|
2013-05-10 00:46:23 +00:00
|
|
|
}
|
2013-06-20 00:33:21 +00:00
|
|
|
break;
|
2013-04-08 16:06:42 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-04-07 16:14:28 +00:00
|
|
|
case RETRO_DEVICE_ANALOG:
|
|
|
|
//Need to return [-0x8000, 0x7fff]
|
|
|
|
//Gamepad API gives us [-128, 127] with (0,0) center
|
|
|
|
//Untested
|
2014-06-10 19:04:00 +00:00
|
|
|
if(qnx->port_device[port])
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
2013-05-10 00:46:23 +00:00
|
|
|
switch ((index << 1) | id)
|
|
|
|
{
|
|
|
|
case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_X:
|
2014-06-10 19:04:00 +00:00
|
|
|
return qnx->port_device[port]->analog0[0] * 256;
|
2013-05-10 00:46:23 +00:00
|
|
|
case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_Y:
|
2014-06-10 19:04:00 +00:00
|
|
|
return qnx->port_device[port]->analog0[1] * 256;
|
2013-05-10 00:46:23 +00:00
|
|
|
case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_X:
|
2014-06-10 19:04:00 +00:00
|
|
|
return qnx->port_device[port]->analog1[0] * 256;
|
2013-05-10 00:46:23 +00:00
|
|
|
case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_Y:
|
2014-06-10 19:04:00 +00:00
|
|
|
return qnx->port_device[port]->analog1[1] * 256;
|
2013-05-10 00:46:23 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-04-07 16:14:28 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2013-03-20 00:21:45 +00:00
|
|
|
case RARCH_DEVICE_POINTER_SCREEN:
|
2013-06-11 22:59:41 +00:00
|
|
|
case RETRO_DEVICE_POINTER:
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2013-06-19 00:37:28 +00:00
|
|
|
const bool want_full = device == RARCH_DEVICE_POINTER_SCREEN;
|
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
switch (id)
|
|
|
|
{
|
2014-05-17 14:48:52 +00:00
|
|
|
case RETRO_DEVICE_ID_POINTER_X:
|
|
|
|
return want_full ? qnx->touch[qnx->touch_map[index]].full_x : qnx->touch[qnx->touch_map[index]].x;
|
|
|
|
case RETRO_DEVICE_ID_POINTER_Y:
|
|
|
|
return want_full ? qnx->touch[qnx->touch_map[index]].full_y : qnx->touch[qnx->touch_map[index]].y;
|
|
|
|
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
|
|
|
return (qnx->touch_map[index] != -1);
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
|
2013-06-21 00:41:46 +00:00
|
|
|
break;
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
default:
|
2013-06-21 00:41:46 +00:00
|
|
|
break;
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool qnx_input_key_pressed(void *data, int key)
|
|
|
|
{
|
2014-05-17 20:16:25 +00:00
|
|
|
(void)data;
|
2013-09-06 14:37:28 +00:00
|
|
|
return ((g_extern.lifecycle_state | driver.overlay_state.buttons ) & (1ULL << key));
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qnx_input_free_input(void *data)
|
|
|
|
{
|
2014-05-29 21:57:00 +00:00
|
|
|
free(data);
|
2013-03-20 00:21:45 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 16:14:28 +00:00
|
|
|
static void qnx_input_set_keybinds(void *data, unsigned device, unsigned port,
|
|
|
|
unsigned id, unsigned keybind_action)
|
2013-03-20 00:21:45 +00:00
|
|
|
{
|
2014-05-17 14:48:52 +00:00
|
|
|
int i;
|
2013-06-13 00:47:16 +00:00
|
|
|
input_device_t *controller = (input_device_t*)data;
|
2013-04-07 16:14:28 +00:00
|
|
|
#ifdef HAVE_BB10
|
|
|
|
uint64_t *key = &g_settings.input.binds[port][id].joykey;
|
|
|
|
uint64_t joykey = *key;
|
|
|
|
size_t arr_size = sizeof(platform_keys) / sizeof(platform_keys[0]);
|
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
(void)device;
|
2014-05-17 20:16:25 +00:00
|
|
|
(void)joykey;
|
|
|
|
(void)data;
|
2013-04-07 16:14:28 +00:00
|
|
|
|
|
|
|
if (keybind_action & (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BIND))
|
|
|
|
*key = g_settings.input.binds[port][id].def_joykey;
|
2013-04-08 16:06:42 +00:00
|
|
|
#endif
|
2013-04-07 16:14:28 +00:00
|
|
|
if (keybind_action & (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS))
|
|
|
|
{
|
|
|
|
switch (device)
|
|
|
|
{
|
2013-04-08 16:06:42 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-04-07 16:14:28 +00:00
|
|
|
case DEVICE_WIIMOTE:
|
2013-05-10 00:46:23 +00:00
|
|
|
//TODO:Have enum lookup for string
|
2013-04-07 16:14:28 +00:00
|
|
|
strlcpy(g_settings.input.device_names[port], "Wiimote",
|
2014-05-17 20:16:25 +00:00
|
|
|
sizeof(g_settings.input.device_names[port]));
|
2013-04-07 16:14:28 +00:00
|
|
|
g_settings.input.device[port] = device;
|
2013-04-21 13:54:58 +00:00
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_B].def_joykey = SCREEN_X_GAME_BUTTON;
|
2013-04-07 16:14:28 +00:00
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_Y].def_joykey = SCREEN_B_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_SELECT].def_joykey = SCREEN_MENU1_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_START].def_joykey = SCREEN_MENU2_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_UP].def_joykey = SCREEN_DPAD_UP_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_DOWN].def_joykey = SCREEN_DPAD_DOWN_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_LEFT].def_joykey = SCREEN_DPAD_LEFT_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_RIGHT].def_joykey = SCREEN_DPAD_RIGHT_GAME_BUTTON;
|
2013-04-21 13:54:58 +00:00
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_A].def_joykey = SCREEN_Y_GAME_BUTTON;
|
2013-04-07 16:14:28 +00:00
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_X].def_joykey = SCREEN_A_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L].def_joykey = SCREEN_L1_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R].def_joykey = SCREEN_R1_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L2].def_joykey = SCREEN_L2_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R2].def_joykey = SCREEN_R2_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L3].def_joykey = SCREEN_L3_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R3].def_joykey = SCREEN_R3_GAME_BUTTON;
|
2013-06-12 03:18:06 +00:00
|
|
|
g_settings.input.binds[port][RARCH_MENU_TOGGLE].def_joykey = SCREEN_MENU3_GAME_BUTTON;
|
2013-05-10 00:46:23 +00:00
|
|
|
controller->port = port;
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx->port_device[port] = controller;
|
2013-04-07 16:14:28 +00:00
|
|
|
break;
|
2013-05-07 22:52:02 +00:00
|
|
|
case DEVICE_KEYPAD:
|
|
|
|
strlcpy(g_settings.input.device_names[port], "BlackBerry Q10 Keypad",
|
2014-05-17 20:16:25 +00:00
|
|
|
sizeof(g_settings.input.device_names[port]));
|
2013-05-07 22:52:02 +00:00
|
|
|
g_settings.input.device[port] = device;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_B].def_joykey = KEYCODE_M & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_Y].def_joykey = KEYCODE_J & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_SELECT].def_joykey = KEYCODE_RIGHT_SHIFT & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_START].def_joykey = KEYCODE_RETURN & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_UP].def_joykey = KEYCODE_W & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_DOWN].def_joykey = KEYCODE_S & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_LEFT].def_joykey = KEYCODE_A & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_RIGHT].def_joykey = KEYCODE_D & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_A].def_joykey = KEYCODE_N & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_X].def_joykey = KEYCODE_K & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L].def_joykey = KEYCODE_U & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R].def_joykey = KEYCODE_I & 0xFF;
|
2013-07-07 18:49:50 +00:00
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L2].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R2].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L3].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R3].def_joykey = NO_BTN;
|
2013-06-12 03:18:06 +00:00
|
|
|
g_settings.input.binds[port][RARCH_MENU_TOGGLE].def_joykey = KEYCODE_P & 0xFF;
|
2013-05-10 00:46:23 +00:00
|
|
|
controller->port = port;
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx->port_device[port] = controller;
|
2013-05-07 22:52:02 +00:00
|
|
|
break;
|
2013-04-08 16:06:42 +00:00
|
|
|
#endif
|
2013-04-08 14:21:43 +00:00
|
|
|
case DEVICE_KEYBOARD:
|
|
|
|
strlcpy(g_settings.input.device_names[port], "BlackBerry BT Keyboard",
|
2014-05-17 20:16:25 +00:00
|
|
|
sizeof(g_settings.input.device_names[port]));
|
2013-04-08 14:21:43 +00:00
|
|
|
g_settings.input.device[port] = device;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_B].def_joykey = KEYCODE_Z & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_Y].def_joykey = KEYCODE_A & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_SELECT].def_joykey = KEYCODE_RIGHT_SHIFT & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_START].def_joykey = KEYCODE_RETURN & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_UP].def_joykey = KEYCODE_UP & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_DOWN].def_joykey = KEYCODE_DOWN & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_LEFT].def_joykey = KEYCODE_LEFT & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_RIGHT].def_joykey = KEYCODE_RIGHT & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_A].def_joykey = KEYCODE_X & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_X].def_joykey = KEYCODE_S & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L].def_joykey = KEYCODE_Q & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R].def_joykey = KEYCODE_W & 0xFF;
|
2013-07-07 18:49:50 +00:00
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L2].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R2].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L3].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R3].def_joykey = NO_BTN;
|
2013-06-12 03:18:06 +00:00
|
|
|
g_settings.input.binds[port][RARCH_MENU_TOGGLE].def_joykey = KEYCODE_TILDE;
|
2013-05-10 00:46:23 +00:00
|
|
|
controller->port = port;
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx->port_device[port] = controller;
|
2013-04-08 14:21:43 +00:00
|
|
|
break;
|
2013-07-06 15:49:30 +00:00
|
|
|
case DEVICE_IPEGA:
|
|
|
|
strlcpy(g_settings.input.device_names[port], "iPega PG-9017",
|
2014-05-17 20:16:25 +00:00
|
|
|
sizeof(g_settings.input.device_names[port]));
|
2013-07-06 15:49:30 +00:00
|
|
|
g_settings.input.device[port] = device;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_B].def_joykey = KEYCODE_J & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_Y].def_joykey = KEYCODE_M & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_SELECT].def_joykey = KEYCODE_R & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_START].def_joykey = KEYCODE_Y & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_UP].def_joykey = KEYCODE_UP & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_DOWN].def_joykey = KEYCODE_DOWN & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_LEFT].def_joykey = KEYCODE_LEFT & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_RIGHT].def_joykey = KEYCODE_RIGHT & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_A].def_joykey = KEYCODE_K & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_X].def_joykey = KEYCODE_I & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L].def_joykey = KEYCODE_Q & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R].def_joykey = KEYCODE_P & 0xFF;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L2].def_joykey = 0;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R2].def_joykey = 0;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L3].def_joykey = 0;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R3].def_joykey = 0;
|
|
|
|
g_settings.input.binds[port][RARCH_MENU_TOGGLE].def_joykey = 0;
|
|
|
|
controller->port = port;
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx->port_device[port] = controller;
|
2013-07-06 15:49:30 +00:00
|
|
|
break;
|
2013-04-08 16:06:42 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-04-07 16:14:28 +00:00
|
|
|
case DEVICE_UNKNOWN:
|
|
|
|
strlcpy(g_settings.input.device_names[port], "Unknown",
|
2014-05-17 20:16:25 +00:00
|
|
|
sizeof(g_settings.input.device_names[port]));
|
2013-04-07 16:14:28 +00:00
|
|
|
g_settings.input.device[port] = device;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_B].def_joykey = SCREEN_B_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_Y].def_joykey = SCREEN_Y_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_SELECT].def_joykey = SCREEN_MENU1_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_START].def_joykey = SCREEN_MENU2_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_UP].def_joykey = SCREEN_DPAD_UP_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_DOWN].def_joykey = SCREEN_DPAD_DOWN_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_LEFT].def_joykey = SCREEN_DPAD_LEFT_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_RIGHT].def_joykey = SCREEN_DPAD_RIGHT_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_A].def_joykey = SCREEN_A_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_X].def_joykey = SCREEN_X_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L].def_joykey = SCREEN_L1_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R].def_joykey = SCREEN_R1_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L2].def_joykey = SCREEN_L2_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R2].def_joykey = SCREEN_R2_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L3].def_joykey = SCREEN_L3_GAME_BUTTON;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R3].def_joykey = SCREEN_R3_GAME_BUTTON;
|
2013-07-07 18:49:50 +00:00
|
|
|
g_settings.input.binds[port][RARCH_MENU_TOGGLE].def_joykey = NO_BTN; //TODO: Find a good mappnig
|
2013-05-10 00:46:23 +00:00
|
|
|
controller->port = port;
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx->port_device[port] = controller;
|
2013-04-07 16:14:28 +00:00
|
|
|
break;
|
2014-05-17 20:16:25 +00:00
|
|
|
#endif
|
2013-04-07 16:14:28 +00:00
|
|
|
case DEVICE_NONE:
|
|
|
|
default:
|
|
|
|
strlcpy(g_settings.input.device_names[port], "None",
|
2014-05-17 20:16:25 +00:00
|
|
|
sizeof(g_settings.input.device_names[port]));
|
2013-04-07 16:14:28 +00:00
|
|
|
g_settings.input.device[port] = device;
|
2013-07-07 18:49:50 +00:00
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_B].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_Y].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_SELECT].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_START].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_UP].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_DOWN].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_LEFT].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_RIGHT].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_A].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_X].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L2].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R2].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L3].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R3].def_joykey = NO_BTN;
|
|
|
|
g_settings.input.binds[port][RARCH_MENU_TOGGLE].def_joykey = NO_BTN;
|
2013-05-10 00:46:23 +00:00
|
|
|
controller->port = -1;
|
2014-06-10 19:04:00 +00:00
|
|
|
qnx->port_device[port] = 0;
|
2013-04-07 16:14:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-05-17 14:48:52 +00:00
|
|
|
for (i = 0; i < RARCH_CUSTOM_BIND_LIST_END; i++)
|
2013-04-07 16:14:28 +00:00
|
|
|
{
|
|
|
|
g_settings.input.binds[port][i].id = i;
|
|
|
|
g_settings.input.binds[port][i].joykey = g_settings.input.binds[port][i].def_joykey;
|
|
|
|
}
|
2013-06-12 03:18:06 +00:00
|
|
|
|
|
|
|
g_settings.input.binds[port][RARCH_MENU_TOGGLE].id = RARCH_MENU_TOGGLE;
|
|
|
|
g_settings.input.binds[port][RARCH_MENU_TOGGLE].joykey = g_settings.input.binds[port][RARCH_MENU_TOGGLE].def_joykey;
|
2013-04-07 16:14:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 16:06:42 +00:00
|
|
|
#ifdef HAVE_BB10
|
2013-04-08 14:21:43 +00:00
|
|
|
//TODO: Handle keyboard mappings
|
2013-04-07 16:14:28 +00:00
|
|
|
if (keybind_action & (1ULL << KEYBINDS_ACTION_GET_BIND_LABEL))
|
|
|
|
{
|
|
|
|
struct platform_bind *ret = (struct platform_bind*)data;
|
|
|
|
|
|
|
|
if (ret->joykey == NO_BTN)
|
|
|
|
strlcpy(ret->desc, "No button", sizeof(ret->desc));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < arr_size; i++)
|
|
|
|
{
|
|
|
|
if (platform_keys[i].joykey == ret->joykey)
|
|
|
|
{
|
|
|
|
strlcpy(ret->desc, platform_keys[i].desc, sizeof(ret->desc));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strlcpy(ret->desc, "Unknown", sizeof(ret->desc));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
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)
|
|
|
|
{
|
|
|
|
uint64_t caps = 0;
|
|
|
|
|
2014-05-17 20:16:25 +00:00
|
|
|
(void)data;
|
|
|
|
|
2013-11-02 20:16:57 +00:00
|
|
|
caps |= (1 << RETRO_DEVICE_JOYPAD);
|
|
|
|
caps |= (1 << RETRO_DEVICE_POINTER);
|
|
|
|
#ifdef HAVE_BB10
|
|
|
|
caps |= (1 << RETRO_DEVICE_ANALOG);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
2014-04-17 18:47:11 +00:00
|
|
|
unsigned qnx_input_devices_size(void *data)
|
|
|
|
{
|
2014-05-17 20:16:25 +00:00
|
|
|
(void)data;
|
2014-04-17 18:47:11 +00:00
|
|
|
return DEVICE_LAST;
|
|
|
|
}
|
|
|
|
|
2013-03-20 00:21:45 +00:00
|
|
|
const input_driver_t input_qnx = {
|
|
|
|
qnx_input_init,
|
|
|
|
qnx_input_poll,
|
|
|
|
qnx_input_state,
|
|
|
|
qnx_input_key_pressed,
|
|
|
|
qnx_input_free_input,
|
2013-04-07 16:14:28 +00:00
|
|
|
qnx_input_set_keybinds,
|
2013-11-02 23:27:58 +00:00
|
|
|
NULL,
|
2014-01-20 13:52:53 +00:00
|
|
|
NULL,
|
2013-11-02 20:16:57 +00:00
|
|
|
qnx_input_get_capabilities,
|
2014-04-17 18:47:11 +00:00
|
|
|
qnx_input_devices_size,
|
2013-03-20 00:21:45 +00:00
|
|
|
"qnx_input",
|
2014-05-17 20:16:25 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2013-03-20 00:21:45 +00:00
|
|
|
};
|