Skip to content

Commit 1cf37a5

Browse files
Use different touch contexts for App & UX
1 parent 62a929e commit 1cf37a5

File tree

14 files changed

+170
-142
lines changed

14 files changed

+170
-142
lines changed

include/nbgl_stubs.h

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
#pragma once
22

33
// auto-generated by shared_export.py
4-
#define _NR_nbgl_refresh 0x90
5-
#define _NR_nbgl_refreshSpecial 0x91
6-
#define _NR_nbgl_refreshSpecialWithPostRefresh 0x92
7-
#define _NR_nbgl_refreshIsNeeded 0x93
8-
#define _NR_nbgl_refreshReset 0x94
9-
#define _NR_nbgl_objInit 0x95
10-
#define _NR_nbgl_objDraw 0x96
11-
#define _NR_nbgl_objAllowDrawing 0x97
12-
#define _NR_nbgl_objGetRAMBuffer 0x98
13-
#define _NR_nbgl_screenContainsObjType 0x99
14-
#define _NR_nbgl_screenSet 0x9a
15-
#define _NR_nbgl_screenPush 0x9b
16-
#define _NR_nbgl_screenRedraw 0x9c
17-
#define _NR_nbgl_screenPop 0x9d
18-
#define _NR_nbgl_screenGetElements 0x9e
19-
#define _NR_nbgl_screenGetCurrentStackSize 0x9f
20-
#define _NR_nbgl_screenGetUxStackSize 0xa0
21-
#define _NR_nbgl_screenGetAt 0xa1
22-
#define _NR_nbgl_screenGetTop 0xa2
23-
#define _NR_nbgl_screenUpdateTicker 0xa3
24-
#define _NR_nbgl_screenUpdateBackgroundColor 0xa4
25-
#define _NR_nbgl_screenReset 0xa5
26-
#define _NR_nbgl_screenHandler 0xa6
27-
#define _NR_nbgl_objPoolGet 0xa7
28-
#define _NR_nbgl_objPoolGetArray 0xa8
29-
#define _NR_nbgl_containerPoolGet 0xa9
30-
#define _NR_nbgl_getCharWidth 0xaa
31-
#define _NR_nbgl_getFont 0xab
32-
#define _NR_nbgl_getFontHeight 0xac
33-
#define _NR_nbgl_getFontLineHeight 0xad
34-
#define _NR_nbgl_getSingleLineTextWidth 0xae
35-
#define _NR_nbgl_getSingleLineTextWidthInLen 0xaf
36-
#define _NR_nbgl_getTextHeight 0xb0
37-
#define _NR_nbgl_getTextHeightInWidth 0xb1
38-
#define _NR_nbgl_getTextNbLinesInWidth 0xb2
39-
#define _NR_nbgl_getTextNbPagesInWidth 0xb3
40-
#define _NR_nbgl_getTextWidth 0xb4
41-
#define _NR_nbgl_getTextMaxLenInNbLines 0xb5
42-
#define _NR_nbgl_textReduceOnNbLines 0xb6
43-
#define _NR_nbgl_textWrapOnNbLines 0xb7
44-
#define _NR_nbgl_refreshUnicodeFont 0xb8
45-
#define _NR_nbgl_touchHandler 0xb9
46-
#define _NR_nbgl_touchGetTouchDuration 0xba
47-
#define _NR_nbgl_touchGetTouchedPosition 0xbb
48-
#define _NR_nbgl_buttonsHandler 0xbc
49-
#define _NR_nbgl_buttonsReset 0xbd
50-
#define _NR_nbgl_keyboardCallback 0xbe
51-
#define _NR_nbgl_keypadCallback 0xbf
52-
#define _NR_nbgl_drawText 0xc0
53-
#define _NR_pic_shared 0xc1
54-
#define _NR_pic_init 0xc2
4+
#define _NR_nbgl_refresh 0x91
5+
#define _NR_nbgl_refreshSpecial 0x92
6+
#define _NR_nbgl_refreshSpecialWithPostRefresh 0x93
7+
#define _NR_nbgl_refreshIsNeeded 0x94
8+
#define _NR_nbgl_refreshReset 0x95
9+
#define _NR_nbgl_objInit 0x96
10+
#define _NR_nbgl_objDraw 0x97
11+
#define _NR_nbgl_objAllowDrawing 0x98
12+
#define _NR_nbgl_objGetRAMBuffer 0x99
13+
#define _NR_nbgl_screenContainsObjType 0x9a
14+
#define _NR_nbgl_screenSet 0x9b
15+
#define _NR_nbgl_screenPush 0x9c
16+
#define _NR_nbgl_screenRedraw 0x9d
17+
#define _NR_nbgl_screenPop 0x9e
18+
#define _NR_nbgl_screenGetElements 0x9f
19+
#define _NR_nbgl_screenGetCurrentStackSize 0xa0
20+
#define _NR_nbgl_screenGetUxStackSize 0xa1
21+
#define _NR_nbgl_screenGetAt 0xa2
22+
#define _NR_nbgl_screenGetTop 0xa3
23+
#define _NR_nbgl_screenUpdateTicker 0xa4
24+
#define _NR_nbgl_screenUpdateBackgroundColor 0xa5
25+
#define _NR_nbgl_screenReset 0xa6
26+
#define _NR_nbgl_screenHandler 0xa7
27+
#define _NR_nbgl_objPoolGet 0xa8
28+
#define _NR_nbgl_objPoolGetArray 0xa9
29+
#define _NR_nbgl_containerPoolGet 0xaa
30+
#define _NR_nbgl_getCharWidth 0xab
31+
#define _NR_nbgl_getFont 0xac
32+
#define _NR_nbgl_getFontHeight 0xad
33+
#define _NR_nbgl_getFontLineHeight 0xae
34+
#define _NR_nbgl_getSingleLineTextWidth 0xaf
35+
#define _NR_nbgl_getSingleLineTextWidthInLen 0xb0
36+
#define _NR_nbgl_getTextHeight 0xb1
37+
#define _NR_nbgl_getTextHeightInWidth 0xb2
38+
#define _NR_nbgl_getTextNbLinesInWidth 0xb3
39+
#define _NR_nbgl_getTextNbPagesInWidth 0xb4
40+
#define _NR_nbgl_getTextWidth 0xb5
41+
#define _NR_nbgl_getTextMaxLenInNbLines 0xb6
42+
#define _NR_nbgl_textReduceOnNbLines 0xb7
43+
#define _NR_nbgl_textWrapOnNbLines 0xb8
44+
#define _NR_nbgl_refreshUnicodeFont 0xb9
45+
#define _NR_nbgl_touchHandler 0xba
46+
#define _NR_nbgl_touchGetTouchDuration 0xbb
47+
#define _NR_nbgl_touchGetTouchedPosition 0xbc
48+
#define _NR_nbgl_buttonsHandler 0xbd
49+
#define _NR_nbgl_buttonsReset 0xbe
50+
#define _NR_nbgl_keyboardCallback 0xbf
51+
#define _NR_nbgl_keypadCallback 0xc0
52+
#define _NR_nbgl_drawText 0xc1
53+
#define _NR_pic_shared 0xc2
54+
#define _NR_pic_init 0xc3

include/syscalls.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@
303303
#define SYSCALL_nbgl_side_draw_horizontal_line_ID 0x03fa0006
304304
#define SYSCALL_nbgl_side_draw_img_ID 0x04fa0007
305305
#define SYSCALL_nbgl_side_refresh_area_ID 0x02fa0008
306-
#define SYSCALL_nbgl_get_font_ID 0x01fa000c
307306
#define SYSCALL_nbgl_screen_reinit_ID 0x00fa000d
308307
#define SYSCALL_nbgl_front_draw_img_rle_ID 0x05fa0010
309308
#define SYSCALL_nbgl_front_control_area_masking_ID 0x03fa0012

lib_nbgl/include/nbgl_obj.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ void nbgl_objInit(void);
578578
void nbgl_objDraw(nbgl_obj_t *obj);
579579
void nbgl_objAllowDrawing(bool enable);
580580
uint8_t *nbgl_objGetRAMBuffer(void);
581+
bool nbgl_objIsUx(nbgl_obj_t *obj);
581582

582583
void nbgl_objPoolRelease(uint8_t layer);
583584
nbgl_obj_t *nbgl_objPoolGet(nbgl_obj_type_t type, uint8_t layer);

lib_nbgl/include/nbgl_touch.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,19 @@ extern "C" {
2323
// duration of a short touch on touch panel (in ms)
2424
#define SHORT_TOUCH_DURATION 0
2525
// duration of a long touch on touch panel (in ms)
26-
#define LONG_TOUCH_DURATION 1500
26+
#define LONG_TOUCH_DURATION 3000
2727
/**********************
2828
* TYPEDEFS
2929
**********************/
3030

3131
/**********************
3232
* GLOBAL PROTOTYPES
3333
**********************/
34-
void nbgl_touchHandler(nbgl_touchStatePosition_t *touchEvent, uint32_t currentTimeMs);
35-
bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj,
36-
nbgl_touchStatePosition_t **firstPos,
37-
nbgl_touchStatePosition_t **lastPos);
34+
void nbgl_touchInit(bool fromUx);
35+
void nbgl_touchHandler(bool fromUx, nbgl_touchStatePosition_t *touchEvent, uint32_t currentTimeMs);
36+
bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj,
37+
nbgl_touchStatePosition_t **firstPos,
38+
nbgl_touchStatePosition_t **lastPos);
3839
uint32_t nbgl_touchGetTouchDuration(nbgl_obj_t *obj);
3940
nbgl_obj_t *nbgl_touchGetObjectFromId(nbgl_obj_t *obj, uint8_t id);
4041

lib_nbgl/src/nbgl_fonts.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ static const LANGUAGE_PACK *language_pack;
6666
#include "nbgl_font_open_sans_light_16.inc"
6767
#endif // SCREEN_SIZE_WALLET
6868

69-
const nbgl_font_t *const C_nbgl_fonts[] = {
69+
__attribute__((section("._nbgl_fonts_"))) const nbgl_font_t *const C_nbgl_fonts[] = {
7070

7171
#include "nbgl_font_rom_struct.inc"
7272

7373
};
74-
const unsigned int C_nbgl_fonts_count = sizeof(C_nbgl_fonts) / sizeof(C_nbgl_fonts[0]);
74+
__attribute__((section("._nbgl_fonts_"))) const unsigned int C_nbgl_fonts_count
75+
= sizeof(C_nbgl_fonts) / sizeof(C_nbgl_fonts[0]);
7576

7677
#if (defined(HAVE_BOLOS) && !defined(BOLOS_OS_UPGRADER_APP))
7778
#if !defined(HAVE_LANGUAGE_PACK)

lib_nbgl/src/nbgl_obj.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "nbgl_front.h"
1515
#include "nbgl_debug.h"
1616
#include "nbgl_screen.h"
17+
#include "nbgl_touch.h"
1718
#include "os_print.h"
1819
#include "os_helpers.h"
1920
#include "os_pic.h"
@@ -1629,12 +1630,17 @@ void nbgl_refreshReset(void)
16291630

16301631
/**
16311632
* @brief This functions inits all internal of nbgl objects layer
1633+
* @note it is supposed to be called only from App
16321634
*
16331635
*/
16341636
void nbgl_objInit(void)
16351637
{
16361638
// init area to the smallest size
16371639
nbgl_refreshReset();
1640+
objDrawingDisabled = false;
1641+
#ifdef HAVE_SE_TOUCH
1642+
nbgl_touchInit(false);
1643+
#endif
16381644
}
16391645

16401646
/**
@@ -1650,9 +1656,30 @@ void nbgl_objAllowDrawing(bool enable)
16501656
/**
16511657
* @brief This function is used to get the all purpose RAM buffer
16521658
*
1653-
* @param enable if true, enables drawing/refresh, otherwise disables
1659+
* @return a pointer to the all purpose RAM buffer
16541660
*/
16551661
uint8_t *nbgl_objGetRAMBuffer(void)
16561662
{
16571663
return ramBuffer;
16581664
}
1665+
1666+
/**
1667+
* @brief This function returns true if the object belongs to a UxScreen
1668+
*
1669+
* @return true if the object belongs to a UxScreen
1670+
*/
1671+
bool nbgl_objIsUx(nbgl_obj_t *obj)
1672+
{
1673+
nbgl_obj_t *parent = obj;
1674+
// search screen in parenthood
1675+
while (parent->parent != NULL) {
1676+
parent = parent->parent;
1677+
}
1678+
if (parent->type == SCREEN) {
1679+
return (((nbgl_screen_t *) parent)->isUxScreen);
1680+
}
1681+
else {
1682+
// should never happen
1683+
return true;
1684+
}
1685+
}

lib_nbgl/src/nbgl_screen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ int nbgl_screenPush(nbgl_obj_t ***elements,
368368
nbgl_touchStatePosition_t touchStatePosition = {.state = RELEASED, .x = 0, .y = 0};
369369
// make a fake touch release for the current top-of-stack to avoid issue
370370
// (for example in long-touch press)
371-
nbgl_touchHandler(&touchStatePosition, 0);
371+
nbgl_touchHandler(topOfStack->isUxScreen, &touchStatePosition, 0);
372372
#endif // HAVE_SE_TOUCH
373373
// new top of stack
374374
topOfStack = &screenStack[screenIndex];

0 commit comments

Comments
 (0)