mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
core: rotate touch coordinates by default
This commit is contained in:
parent
a4c0645622
commit
416226648c
@ -19,6 +19,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "display.h"
|
||||
#include "embed/extmod/trezorobj.h"
|
||||
|
||||
#define TOUCH_IFACE (255)
|
||||
@ -61,11 +62,32 @@ STATIC mp_obj_t mod_trezorio_poll(mp_obj_t ifaces, mp_obj_t list_ref,
|
||||
const uint32_t evt = touch_read();
|
||||
if (evt) {
|
||||
mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL));
|
||||
tuple->items[0] =
|
||||
MP_OBJ_NEW_SMALL_INT((evt >> 24) & 0xFFU); // event type
|
||||
tuple->items[1] =
|
||||
MP_OBJ_NEW_SMALL_INT((evt >> 12) & 0xFFFU); // x position
|
||||
tuple->items[2] = MP_OBJ_NEW_SMALL_INT(evt & 0xFFFU); // y position
|
||||
const uint32_t etype = (evt >> 24) & 0xFFU; // event type
|
||||
const uint32_t ex = (evt >> 12) & 0xFFFU; // x position
|
||||
const uint32_t ey = evt & 0xFFFU; // y position
|
||||
uint32_t exr; // rotated x position
|
||||
uint32_t eyr; // rotated y position
|
||||
switch (display_orientation(-1)) {
|
||||
case 90:
|
||||
exr = ey;
|
||||
eyr = DISPLAY_RESX - ex;
|
||||
break;
|
||||
case 180:
|
||||
exr = DISPLAY_RESX - ex;
|
||||
eyr = DISPLAY_RESY - ey;
|
||||
break;
|
||||
case 270:
|
||||
exr = DISPLAY_RESY - ey;
|
||||
eyr = ex;
|
||||
break;
|
||||
default:
|
||||
exr = ex;
|
||||
eyr = ey;
|
||||
break;
|
||||
}
|
||||
tuple->items[0] = MP_OBJ_NEW_SMALL_INT(etype);
|
||||
tuple->items[1] = MP_OBJ_NEW_SMALL_INT(exr);
|
||||
tuple->items[2] = MP_OBJ_NEW_SMALL_INT(eyr);
|
||||
ret->items[0] = MP_OBJ_NEW_SMALL_INT(i);
|
||||
ret->items[1] = MP_OBJ_FROM_PTR(tuple);
|
||||
return mp_const_true;
|
||||
|
Loading…
Reference in New Issue
Block a user