diff --git a/extmod/modtrezorui/modtrezorui-touch.h b/extmod/modtrezorui/modtrezorui-touch.h index eaa0fc38e..ce2652906 100644 --- a/extmod/modtrezorui/modtrezorui-touch.h +++ b/extmod/modtrezorui/modtrezorui-touch.h @@ -11,25 +11,23 @@ mp_obj_t touch_start_callback = mp_const_none; mp_obj_t touch_move_callback = mp_const_none; mp_obj_t touch_end_callback = mp_const_none; -/* -static void touch_start(mp_int_t x, mp_int_t y) { +void touch_start(mp_int_t x, mp_int_t y) { if (touch_start_callback != mp_const_none) { mp_call_function_2(touch_start_callback, MP_OBJ_NEW_SMALL_INT(x), MP_OBJ_NEW_SMALL_INT(y)); } } -static void touch_move(mp_int_t x, mp_int_t y) { +void touch_move(mp_int_t x, mp_int_t y) { if (touch_move_callback != mp_const_none) { mp_call_function_2(touch_move_callback, MP_OBJ_NEW_SMALL_INT(x), MP_OBJ_NEW_SMALL_INT(y)); } } -static void touch_end(mp_int_t x, mp_int_t y) { +void touch_end(mp_int_t x, mp_int_t y) { if (touch_end_callback != mp_const_none) { mp_call_function_2(touch_end_callback, MP_OBJ_NEW_SMALL_INT(x), MP_OBJ_NEW_SMALL_INT(y)); } } -*/ // class Touch(object): typedef struct _mp_obj_Touch_t { diff --git a/extmod/modtrezorui/modtrezorui-unix.h b/extmod/modtrezorui/modtrezorui-unix.h index ba813ab5a..53d15e37b 100644 --- a/extmod/modtrezorui/modtrezorui-unix.h +++ b/extmod/modtrezorui/modtrezorui-unix.h @@ -6,11 +6,11 @@ */ #include +#include static SDL_Renderer *RENDERER = 0; static SDL_Surface *SCREEN = 0; static SDL_Texture *TEXTURE = 0; -static SDL_Thread *THREAD = 0; static int DATAODD = 0; static int POSX, POSY, SX, SY, EX, EY = 0; static int ROTATION = 0; @@ -34,11 +34,15 @@ static void DATAfunc(uint8_t x) { } } -static int HandleEvents(void *ptr) +void touch_start(mp_int_t x, mp_int_t y); +void touch_move(mp_int_t x, mp_int_t y); +void touch_end(mp_int_t x, mp_int_t y); + +void upy_idle_func(void) { SDL_Event event; int x, y; - while (SDL_WaitEvent(&event) >= 0) { + while (SDL_PollEvent(&event) > 0) { switch (event.type) { case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEMOTION: @@ -48,21 +52,24 @@ static int HandleEvents(void *ptr) if (x < 0 || y < 0 || x >= RESX || y >= RESY) continue; switch (event.type) { case SDL_MOUSEBUTTONDOWN: - // touch_start(x, y); + touch_start(x, y); break; case SDL_MOUSEMOTION: if (event.motion.state) { - // touch_move(x, y); + touch_move(x, y); } break; case SDL_MOUSEBUTTONUP: - // touch_end(x, y); + touch_end(x, y); break; } break; + case SDL_QUIT: + exit(3); + break; } } - return 0; + return; } static void display_init(void) @@ -84,7 +91,6 @@ static void display_init(void) SDL_RenderClear(RENDERER); SCREEN = SDL_CreateRGBSurface(0, RESX, RESY, 16, 0xF800, 0x07E0, 0x001F, 0x0000); TEXTURE = SDL_CreateTexture(RENDERER, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, RESX, RESY); - THREAD = SDL_CreateThread(HandleEvents, "EventThread", NULL); } static void display_set_window(uint16_t x, uint16_t y, uint16_t w, uint16_t h) { diff --git a/vendor/micropython b/vendor/micropython index 4e2fda01b..57b4be8a5 160000 --- a/vendor/micropython +++ b/vendor/micropython @@ -1 +1 @@ -Subproject commit 4e2fda01bf6612823057886c98284ada320c8b22 +Subproject commit 57b4be8a5c73dda20746d53a66a98c4b64498be4