Enforce pointer index tracking for touch lifecycle

- Fixes glitch where GLTouchMenu would capture a joystick event if the movement came into its portion of the screen
    - Prepares the way for allowing both keyboard and joystick access to same screen real-estate
This commit is contained in:
Aaron Culliney 2016-01-30 11:22:50 -08:00
parent c29daf006e
commit 8f03d0ca6f
5 changed files with 35 additions and 16 deletions

View File

@ -16,6 +16,8 @@
#include "common.h"
#define TRACKING_NONE (-1)
typedef enum glnode_render_order_t {
RENDER_BOTTOM=0, // e.g., the //e framebuffer node itself
RENDER_LOW =1, // e.g., the touchjoy and touchkbd

View File

@ -16,7 +16,6 @@
#endif
#define MODEL_DEPTH -1/32.f
#define TRACKING_NONE (-1)
#define AXIS_TEMPLATE_COLS 3
#define AXIS_TEMPLATE_ROWS 3

View File

@ -414,7 +414,7 @@ static inline int64_t _tap_key_at_point(float x, float y) {
_rerender_selected(kbd.selectedCol, kbd.selectedRow);
// return the key+scancode+handled
int64_t flags = (handled ? 0x1LL : 0x0LL);
int64_t flags = (handled ? TOUCH_FLAGS_HANDLED : 0x0LL);
key = key & 0xff;
scancode = scancode & 0xff;
@ -587,32 +587,44 @@ static int64_t gltouchkbd_onTouchEvent(interface_touch_event_t action, int point
float x = x_coords[pointer_idx];
float y = y_coords[pointer_idx];
int64_t flags = TOUCH_FLAGS_KBD | TOUCH_FLAGS_HANDLED;
int64_t flags = TOUCH_FLAGS_KBD;
clock_gettime(CLOCK_MONOTONIC, &kbd.timingBegin);
static int trackingIndex = TRACKING_NONE;
switch (action) {
case TOUCH_DOWN:
case TOUCH_POINTER_DOWN:
if (/*isOnKeyboardModel:*/true) {// TODO FIXME : nonactionable areas could defer to joystick ...
trackingIndex = pointer_idx;
flags |= TOUCH_FLAGS_HANDLED;
}
break;
case TOUCH_MOVE:
flags |= ((pointer_idx == trackingIndex) ? TOUCH_FLAGS_HANDLED : 0);
break;
case TOUCH_UP:
case TOUCH_POINTER_UP:
{
int64_t handledAndData = _tap_key_at_point(x, y);
flags |= ((handledAndData & 0x01) ? TOUCH_FLAGS_KEY_TAP : 0x0LL);
flags |= (handledAndData & TOUCH_FLAGS_ASCII_AND_SCANCODE_MASK);
if (trackingIndex == pointer_idx) {
int64_t handledAndData = _tap_key_at_point(x, y);
flags |= ((handledAndData & TOUCH_FLAGS_HANDLED) ? (TOUCH_FLAGS_HANDLED|TOUCH_FLAGS_KEY_TAP) : 0x0LL);
flags |= (handledAndData & TOUCH_FLAGS_ASCII_AND_SCANCODE_MASK);
trackingIndex = TRACKING_NONE;
}
}
break;
case TOUCH_CANCEL:
trackingIndex = TRACKING_NONE;
LOG("---KBD TOUCH CANCEL");
return 0x0LL;
default:
trackingIndex = TRACKING_NONE;
LOG("!!!KBD UNKNOWN TOUCH EVENT : %d", action);
return 0x0LL;
}

View File

@ -236,7 +236,7 @@ static inline int64_t _tap_menu_item(float x, float y) {
uint8_t selectedItem = topMenuTemplate[row][col];
int64_t flags = TOUCH_FLAGS_KEY_TAP;
int64_t flags = TOUCH_FLAGS_KEY_TAP | TOUCH_FLAGS_HANDLED;
switch (selectedItem) {
case MOUSETEXT_LEFT:
@ -470,35 +470,45 @@ static int64_t gltouchmenu_onTouchEvent(interface_touch_event_t action, int poin
float x = x_coords[pointer_idx];
float y = y_coords[pointer_idx];
bool handled = (_is_point_on_left_menu(x, y) || _is_point_on_right_menu(x, y));
int flags = TOUCH_FLAGS_MENU;
static int trackingIndex = TRACKING_NONE;
switch (action) {
case TOUCH_DOWN:
case TOUCH_POINTER_DOWN:
_sprout_menu(x, y);
if (_is_point_on_left_menu(x, y) || _is_point_on_right_menu(x, y)) {
trackingIndex = pointer_idx;
_sprout_menu(x, y);
flags |= TOUCH_FLAGS_HANDLED;
}
break;
case TOUCH_MOVE:
flags |= ((pointer_idx == trackingIndex) ? TOUCH_FLAGS_HANDLED : 0);
break;
case TOUCH_UP:
case TOUCH_POINTER_UP:
flags |= _tap_menu_item(x, y);
if (trackingIndex == pointer_idx) {
flags |= _tap_menu_item(x, y);
trackingIndex = TRACKING_NONE;
}
break;
case TOUCH_CANCEL:
trackingIndex = TRACKING_NONE;
LOG("---MENU TOUCH CANCEL");
return 0x0;
default:
trackingIndex = TRACKING_NONE;
LOG("!!!MENU UNKNOWN TOUCH EVENT : %d", action);
return 0x0;
}
if (handled) {
if (flags & TOUCH_FLAGS_HANDLED) {
clock_gettime(CLOCK_MONOTONIC, &menu.timingBegin);
flags |= TOUCH_FLAGS_HANDLED;
}
return flags;

View File

@ -456,10 +456,6 @@ static void gldriver_reshape(int w, int h) {
windowHeight = h;
#endif
#if MOBILE_DEVICE
int viewportHeightPrevious = viewportHeight;
#endif
int w2 = ((float)h * (SCANWIDTH/(float)SCANHEIGHT));
int h2 = ((float)w / (SCANWIDTH/(float)SCANHEIGHT));