mirror of
https://github.com/libretro/RetroArch
synced 2025-04-17 11:43:00 +00:00
Add proper input handling for PlayBook/BB10
This commit is contained in:
parent
be9a8e63f4
commit
1c32975717
@ -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;
|
||||
|
@ -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>
|
||||
|
@ -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> -->
|
||||
|
@ -15,15 +15,188 @@
|
||||
|
||||
#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)
|
||||
@ -35,15 +208,31 @@ static int16_t qnx_input_state(void *data, const struct retro_keybind **retro_ke
|
||||
(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)
|
||||
{
|
||||
(void)data;
|
||||
(void)key;
|
||||
|
||||
return false;
|
||||
return ((g_extern.lifecycle_state | driver.overlay_state) & (1ULL << key));
|
||||
}
|
||||
|
||||
static void qnx_input_free_input(void *data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user