6 #include "app_config.h"
18 #include "os_io_seproxyhal.h"
35 static uint32_t lastPressedTime = 0;
36 static uint32_t lastCurrentTime = 0;
62 if ((obj->touchMask & (1 << eventType)) != 0) {
76 if (screen->touchCallback != NULL) {
101 if ((event->
x < obj->area.x0) || (event->
x >= (obj->area.x0 + obj->area.width))
102 || (event->
y < obj->area.y0) || (event->
y >= (obj->area.y0 + obj->area.height))) {
108 if (container->children != NULL) {
110 for (i = 0; i < container->nbChildren; i++) {
112 if (current != NULL) {
113 current = getTouchedObject(current, event);
114 if (current != NULL) {
122 if (obj->touchMask != 0) {
147 if ((pos->
x < obj->area.x0) || (pos->
x >= (obj->area.x0 + obj->area.width))
148 || (pos->
y < obj->area.y0) || (pos->
y >= (obj->area.y0 + obj->area.height))) {
154 for (
uint8_t i = 0; i < container->nbChildren; i++) {
156 if (current != NULL) {
157 nbgl_obj_t *child = getSwipableObjectAtPos(current, pos, detectedSwipe);
164 if (obj->touchMask & (1 << detectedSwipe)) {
193 nbgl_obj_t *first_obj = getSwipableObjectAtPos(obj, first, detectedSwipe);
195 if (first_obj == NULL) {
199 nbgl_obj_t *last_obj = getSwipableObjectAtPos(obj, last, detectedSwipe);
202 if (first_obj == last_obj) {
211 #ifndef HAVE_HW_TOUCH_SWIPE
212 #define SWIPE_THRESHOLD_X 10
213 #define SWIPE_THRESHOLD_Y 20
225 #ifdef HAVE_HW_TOUCH_SWIPE
233 return SWIPE_GESTURES[last->swipe];
251 return detected_swipe;
271 lastCurrentTime = currentTime;
276 lastState = touchStatePosition->
state;
290 if (foundObj == NULL) {
293 && (lastPressedObj != NULL)) {
301 lastPressedObj = NULL;
308 nbgl_touchType_t swipe = nbgl_detectSwipe(touchStatePosition, &firstTouchedPosition);
309 bool consumed =
false;
317 applytouchStatePosition(swipedObj, swipe);
321 if (!consumed && (lastPressedObj != NULL)
331 applytouchStatePosition(lastPressedObj,
TOUCHED);
335 lastPressedObj = NULL;
338 if ((lastState ==
PRESSED) && (lastPressedObj != NULL)) {
339 if (foundObj != lastPressedObj) {
345 lastPressedObj = NULL;
349 applytouchStatePosition(foundObj,
TOUCHING);
354 lastPressedObj = foundObj;
355 lastPressedTime = currentTime;
357 applytouchStatePosition(foundObj,
TOUCHING);
361 lastState = touchStatePosition->
state;
369 if (obj == lastPressedObj) {
370 *firstPos = &firstTouchedPosition;
371 *lastPos = &lastTouchedPosition;
379 if (obj == lastPressedObj) {
380 return (lastCurrentTime - lastPressedTime);
401 if (container->children != NULL) {
403 for (i = 0; i < container->nbChildren; i++) {
405 if (current != NULL) {
407 if (current != NULL) {
415 if ((obj->touchMask != 0) && (obj->touchId ==
id)) {
#define LOG_DEBUG(__logger,...)
API to draw all basic graphic objects.
void(* nbgl_touchCallback_t)(void *obj, nbgl_touchType_t eventType)
prototype of function to be called when a touch event is received by an object
void nbgl_keyboardTouchCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
function to be called when the keyboard object is touched
void nbgl_keypadTouchCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
function to be called when the keypad object is touched
struct PACKED__ nbgl_container_s nbgl_container_t
struct to represent a container (CONTAINER type)
struct PACKED__ nbgl_obj_s nbgl_obj_t
Common structure for all graphical objects.
nbgl_obj_t * nbgl_screenGetTop(void)
Returns the screen on top layer, as a generic object.
bool nbgl_screenContainsObj(nbgl_obj_t *obj)
return true if the given obj can be found in refObj or any of its children
struct PACKED__ nbgl_screen_s nbgl_screen_t
struct to represent a screen (SCREEN type)
#define SWIPE_THRESHOLD_Y
#define SWIPE_THRESHOLD_X
bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj, nbgl_touchStatePosition_t **firstPos, nbgl_touchStatePosition_t **lastPos)
nbgl_obj_t * nbgl_touchGetObjectFromId(nbgl_obj_t *obj, uint8_t id)
parse all the children of the given object, recursively, until an object with the given touch if is f...
uint32_t nbgl_touchGetTouchDuration(nbgl_obj_t *obj)
void nbgl_touchHandler(nbgl_touchStatePosition_t *touchStatePosition, uint32_t currentTime)
Function to be called periodically to check touchscreen state and coordinates.
#define SHORT_TOUCH_DURATION
#define LONG_TOUCH_DURATION
nbgl_touchType_t
The different types of Touchscreen events.
@ TOUCHING
corresponding to an object that is currently touched
@ CONTAINER
Empty container.
nbgl_touchState_t
the 2 possible states of a finger on the Touchscreen
@ PRESSED
the finger is currently pressing the screen
@ RELEASED
the finger has been released from the screen
The low level Touchscreen event, coming from driver.
int16_t y
vertical position of the touch (or for a RELEASED the last touched point)
int16_t x
horizontal position of the touch (or for a RELEASED the last touched point)
nbgl_touchState_t state
state of the touch event, e.g PRESSED or RELEASED