mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
fixup! feat(core): add power button to button driver
This commit is contained in:
parent
dc6688351c
commit
69e683789d
@ -8,6 +8,9 @@
|
||||
|
||||
#define ORIENTATION_NS 1
|
||||
|
||||
#define BTN_LEFT_KEY SDLK_LEFT
|
||||
#define BTN_RIGHT_KEY SDLK_RIGHT
|
||||
|
||||
#define BACKGROUND_FILE "T2B1/background_T2B1.h"
|
||||
#define BACKGROUND_NAME background_T2B1_png
|
||||
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
#define ORIENTATION_NS 1
|
||||
|
||||
#define BTN_LEFT_KEY SDLK_LEFT
|
||||
#define BTN_RIGHT_KEY SDLK_RIGHT
|
||||
|
||||
#define BACKGROUND_FILE "T2B1/background_T2B1.h"
|
||||
#define BACKGROUND_NAME background_T2B1_png
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#define TOUCH_OFFSET_X 80
|
||||
#define TOUCH_OFFSET_Y 102
|
||||
|
||||
#define BTN_POWER_KEY SDLK_LEFT
|
||||
|
||||
#define ORIENTATION_NS 1
|
||||
|
||||
// #define BACKGROUND_FILE "T3W1/background_T3W1.h"
|
||||
|
@ -24,11 +24,48 @@
|
||||
|
||||
#include "button.h"
|
||||
|
||||
static char last_left = 0, last_right = 0;
|
||||
#ifdef BTN_LEFT_KEY
|
||||
static bool last_left = 0;
|
||||
#endif
|
||||
|
||||
char button_state_left(void) { return last_left; }
|
||||
#ifdef BTN_RIGHT_KEY
|
||||
static bool last_right = 0;
|
||||
#endif
|
||||
|
||||
char button_state_right(void) { return last_right; }
|
||||
#ifdef BTN_POWER_KEY
|
||||
static bool last_power = 0;
|
||||
#endif
|
||||
|
||||
#ifdef BTN_LEFT_KEY
|
||||
bool button_state_left(void) { return last_left; }
|
||||
#endif
|
||||
|
||||
#ifdef BTN_RIGHT_KEY
|
||||
bool button_state_right(void) { return last_right; }
|
||||
#endif
|
||||
|
||||
#ifdef BTN_POWER_KEY
|
||||
bool button_state_power(void) { return last_power; }
|
||||
#endif
|
||||
|
||||
bool button_state(button_t button) {
|
||||
switch (button) {
|
||||
#ifdef BTN_LEFT_KEY
|
||||
case BTN_LEFT:
|
||||
return button_state_left();
|
||||
#endif
|
||||
#ifdef BTN_RIGHT_KEY
|
||||
case BTN_RIGHT:
|
||||
return button_state_right();
|
||||
#endif
|
||||
#ifdef BTN_POWER_KEY
|
||||
case BTN_POWER:
|
||||
return button_state_power();
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t button_read(void) {
|
||||
SDL_Event event;
|
||||
@ -39,12 +76,23 @@ uint32_t button_read(void) {
|
||||
break;
|
||||
}
|
||||
switch (event.key.keysym.sym) {
|
||||
case SDLK_LEFT:
|
||||
#ifdef BTN_LEFT_KEY
|
||||
case BTN_LEFT_KEY:
|
||||
last_left = 1;
|
||||
return BTN_EVT_DOWN | BTN_LEFT;
|
||||
case SDLK_RIGHT:
|
||||
#endif
|
||||
#ifdef BTN_RIGHT_KEY
|
||||
case BTN_RIGHT_KEY:
|
||||
last_right = 1;
|
||||
return BTN_EVT_DOWN | BTN_RIGHT;
|
||||
#endif
|
||||
#ifdef BTN_POWER_KEY
|
||||
case BTN_POWER_KEY:
|
||||
last_power = 1;
|
||||
return BTN_EVT_DOWN | BTN_POWER;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SDL_KEYUP:
|
||||
@ -52,14 +100,27 @@ uint32_t button_read(void) {
|
||||
break;
|
||||
}
|
||||
switch (event.key.keysym.sym) {
|
||||
case SDLK_LEFT:
|
||||
#ifdef BTN_LEFT_KEY
|
||||
case BTN_LEFT_KEY:
|
||||
last_left = 0;
|
||||
return BTN_EVT_UP | BTN_LEFT;
|
||||
case SDLK_RIGHT:
|
||||
#endif
|
||||
#ifdef BTN_RIGHT_KEY
|
||||
case BTN_RIGHT_KEY:
|
||||
last_right = 0;
|
||||
return BTN_EVT_UP | BTN_RIGHT;
|
||||
#endif
|
||||
#ifdef BTN_POWER_KEY
|
||||
case BTN_POWER_KEY:
|
||||
last_power = 0;
|
||||
return BTN_EVT_UP | BTN_POWER;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user