Merge pull request #158 from CatalystG/qnx_input

PlayBook/BB10 Input Handling
This commit is contained in:
Squarepusher 2013-03-19 16:58:51 -07:00
commit 9e2768309b
8 changed files with 288 additions and 37 deletions

View File

@ -73,6 +73,7 @@ enum
INPUT_XINPUT,
INPUT_LINUXRAW,
INPUT_IOS,
INPUT_QNX,
INPUT_NULL
};
@ -160,6 +161,8 @@ enum
#define INPUT_DEFAULT_DRIVER INPUT_X
#elif defined(IOS)
#define INPUT_DEFAULT_DRIVER INPUT_IOS
#elif defined(__BLACKBERRY_QNX__)
#define INPUT_DEFAULT_DRIVER INPUT_QNX
#else
#define INPUT_DEFAULT_DRIVER INPUT_NULL
#endif

View File

@ -155,6 +155,9 @@ static const input_driver_t *input_drivers[] = {
#ifdef IOS
&input_ios,
#endif
#ifdef __BLACKBERRY_QNX__
&input_qnx,
#endif
#ifdef HAVE_NULLINPUT
&input_null,
#endif

View File

@ -262,10 +262,6 @@ static void gfx_ctx_check_window(bool *quit,
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
{
(void)frame_count;
//Request and process all available BPS events
bps_event_t *event = NULL;
bps_get_event(&event, 0);
*quit = false;
@ -278,28 +274,6 @@ static void gfx_ctx_check_window(bool *quit,
*resize = true;
}
if (event)
{
int domain = bps_event_get_domain(event);
if (domain == screen_get_domain())
{
screen_event_t screen_event = screen_event_get_event(event);
int screen_val;
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val);
switch (screen_val) {
case SCREEN_EVENT_MTOUCH_TOUCH:
case SCREEN_EVENT_MTOUCH_MOVE:
case SCREEN_EVENT_MTOUCH_RELEASE:
break;
}
}
else if ((domain == navigator_get_domain()) && (NAVIGATOR_EXIT == bps_event_get_code(event)))
g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
}
// Check if we are exiting.
if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY))
*quit = true;

View File

@ -241,6 +241,8 @@ INPUT
#elif defined(ANDROID)
#include "../android/native/jni/input_autodetect.c"
#include "../android/native/jni/input_android.c"
#elif defined(__BLACKBERRY_QNX__)
#include "../playbook/src/qnx_input.c"
#endif
#if defined(HAVE_NULLINPUT)

View File

@ -26,8 +26,9 @@
<option id="com.qnx.qcc.option.compiler.includePath.1389175009" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="../../"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.209097800" name="Enhanced Security (-fstack-protector-all)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.209097800" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.1775248205" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
<listOptionValue builtIn="false" value="PERF_TEST"/>
@ -56,6 +57,7 @@
</option>
<option id="com.qnx.qcc.option.compiler.qccoptions.227922712" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList">
<listOptionValue builtIn="false" value="-frecord-gcc-switches"/>
<listOptionValue builtIn="false" value="-marm"/>
<listOptionValue builtIn="false" value="-mcpu=cortex-a9"/>
<listOptionValue builtIn="false" value="-mfpu=neon"/>
</option>
@ -113,7 +115,7 @@
</tool>
</fileInfo>
<sourceEntries>
<entry excluding="main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="qnx_input.c|main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
@ -228,7 +230,7 @@
</tool>
</fileInfo>
<sourceEntries>
<entry excluding="main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="qnx_input.c|main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
@ -346,7 +348,7 @@
</tool>
</fileInfo>
<sourceEntries>
<entry excluding="main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="qnx_input.c|main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
@ -420,7 +422,7 @@
</tool>
<tool id="com.qnx.qcc.tool.linker.1942866882" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
<option id="com.qnx.qcc.option.linker.debug.790242117" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.coverage.73478781" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs -p)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.coverage.73478781" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.libraries.1198094350" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
<listOptionValue builtIn="false" value="bps"/>
<listOptionValue builtIn="false" value="OpenAL"/>
@ -464,7 +466,7 @@
</tool>
</fileInfo>
<sourceEntries>
<entry excluding="main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="qnx_input.c|main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
@ -579,7 +581,7 @@
</tool>
</fileInfo>
<sourceEntries>
<entry excluding="main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="qnx_input.c|main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
@ -696,7 +698,7 @@
</tool>
</fileInfo>
<sourceEntries>
<entry excluding="main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="qnx_input.c|main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
@ -769,7 +771,7 @@
</tool>
<tool id="com.qnx.qcc.tool.linker.551801963" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
<option id="com.qnx.qcc.option.linker.debug.1904146116" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.coverage.1717304216" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs -p)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.coverage.1717304216" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.linker.libraries.1222510627" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
<listOptionValue builtIn="false" value="bps"/>
<listOptionValue builtIn="false" value="OpenAL"/>
@ -813,7 +815,7 @@
</tool>
</fileInfo>
<sourceEntries>
<entry excluding="main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="qnx_input.c|main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>

View File

@ -41,6 +41,8 @@
<!-- <authorId>ABC1234YjsnUk235h</authorId> -->
<initialWindow>
<aspectRatio>landscape</aspectRatio>
<autoOrients>false</autoOrients>
<systemChrome>none</systemChrome>
<transparent>false</transparent>
</initialWindow>
@ -48,8 +50,9 @@
<!-- The category where the application appears. Either core.games or core.media. -->
<category>core.games</category>
<asset path="icon.png">icon.png</asset>
<asset path="retroarch.cfg">retroarch.cfg</asset>
<asset path="test.so">lib/test.so</asset>
<asset path="../retroarch.cfg">retroarch.cfg</asset>
<asset path="../media/overlays">overlays</asset>
<!-- <asset path="LICENSE">LICENSE</asset> -->
<!-- <asset path="NOTICE">NOTICE</asset> -->

262
playbook/src/qnx_input.c Normal file
View File

@ -0,0 +1,262 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../general.h"
#include "../../driver.h"
#include <screen/screen.h>
#define MAX_TOUCH 16
struct touches
{
int16_t x, y;
int16_t full_x, full_y;
int contact_id;
};
static struct touches touch[MAX_TOUCH];
static unsigned touch_count;
//Internal helper functions
static void process_touch_event(screen_event_t event, int type){
int contact_id;
int pos[2];
int i;
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:
touch[touch_count].contact_id = contact_id;
input_translate_coord_viewport(pos[0], pos[1],
&touch[touch_count].x, &touch[touch_count].y,
&touch[touch_count].full_x, &touch[touch_count].full_y);
touch_count++;
//printf("New Touch: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout);
break;
case SCREEN_EVENT_MTOUCH_RELEASE:
//Invalidate the finger
touch_count--;
touch[touch_count].contact_id = -1;
input_translate_coord_viewport(pos[0], pos[1],
&touch[touch_count].x, &touch[touch_count].y,
&touch[touch_count].full_x, &touch[touch_count].full_y);
//printf("Release: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout);
break;
case SCREEN_EVENT_MTOUCH_MOVE:
//Find the finger we're tracking and update
for(i=0; i<touch_count; ++i){
if(touch[i].contact_id == contact_id){
input_translate_coord_viewport(pos[0], pos[1],
&touch[i].x, &touch[i].y,
&touch[i].full_x, &touch[i].full_y);
//printf("Move: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout);
}
}
break;
}
}
static void handle_screen_event(bps_event_t *event)
{
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:
process_touch_event(screen_event, type);
break;
case SCREEN_EVENT_KEYBOARD:
break;
#ifdef HAVE_BB10
case SCREEN_EVENT_GAMEPAD:
case SCREEN_EVENT_JOYSTICK:
break;
case SCREEN_EVENT_DEVICE:
{
// A device was attached or removed.
screen_device_t device;
int attached;
int type;
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);
}
int i;
if (attached && (type == SCREEN_EVENT_GAMEPAD ||
type == SCREEN_EVENT_JOYSTICK)) {
//Load controller
} else {
//Remove controller
}
break;
}
#endif
}
}
static void handle_navigator_event(bps_event_t *event) {
navigator_window_state_t state;
bps_event_t *event_pause = NULL;
int rc;
switch (bps_event_get_code(event)) {
case NAVIGATOR_SWIPE_DOWN:
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){
g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
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;
for(i=0; i<MAX_TOUCH; ++i){
touch[i].contact_id = -1;
}
return (void*)-1;
}
static void qnx_input_poll(void *data)
{
(void)data;
//Request and process all available BPS events
int rc, domain;
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()) {
handle_navigator_event(event);
} else if (domain == screen_get_domain()) {
handle_screen_event(event);
}
} else {
break;
}
}
}
}
static int16_t qnx_input_state(void *data, const struct retro_keybind **retro_keybinds, unsigned port, unsigned device, unsigned index, unsigned id)
{
(void)data;
(void)retro_keybinds;
(void)port;
(void)device;
(void)index;
(void)id;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return false;
case RARCH_DEVICE_POINTER_SCREEN:
{
switch (id)
{
case RETRO_DEVICE_ID_POINTER_X: return touch[index].full_x;
case RETRO_DEVICE_ID_POINTER_Y: return touch[index].full_y;
case RETRO_DEVICE_ID_POINTER_PRESSED: return (touch[index].contact_id != -1);
}
return 0;
}
default:
return 0;
}
return 0;
}
static bool qnx_input_key_pressed(void *data, int key)
{
return ((g_extern.lifecycle_state | driver.overlay_state) & (1ULL << key));
}
static void qnx_input_free_input(void *data)
{
(void)data;
}
static void qnx_set_keybinds(void *data, unsigned device,
unsigned port, unsigned id, unsigned keybind_action)
{
(void)data;
(void)device;
(void)port;
(void)id;
(void)keybind_action;
}
const input_driver_t input_qnx = {
qnx_input_init,
qnx_input_poll,
qnx_input_state,
qnx_input_key_pressed,
qnx_input_free_input,
qnx_set_keybinds,
"qnx_input",
};

View File

@ -132,6 +132,8 @@ const char *config_get_default_input(void)
return "linuxraw";
case INPUT_IOS:
return "ios_input";
case INPUT_QNX:
return "qnx_input";
case INPUT_NULL:
return "null";
default: