mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-29 16:28:11 +00:00
feat(ui): runtime joystick rotation independent of display rotation
Add NodePrefs::joystick_rotation (0-3 steps CW), persisted in DataStore alongside display_rotation. rotateJoystickKey() now takes a runtime rot parameter instead of compile-time JOYSTICK_ROTATION macro. UITask::loop() reads joystick_rotation from NodePrefs each frame. Settings screen exposes "Joystick" rotation item on any build with UI_HAS_JOYSTICK. JOYSTICK_ROTATION macro still works as compile-time default for legacy/non-prefs builds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,36 @@
|
||||
#define KEY_PREV 0xF2
|
||||
#define KEY_CONTEXT_MENU 0xF3
|
||||
|
||||
#ifndef JOYSTICK_ROTATION
|
||||
#define JOYSTICK_ROTATION 0
|
||||
#endif
|
||||
|
||||
// Rotate directional key by rot steps clockwise (0–3).
|
||||
// Pass NodePrefs::joystick_rotation at runtime; JOYSTICK_ROTATION macro is the compile-time default.
|
||||
static inline char rotateJoystickKey(char key, uint8_t rot) {
|
||||
switch (rot & 3) {
|
||||
case 1:
|
||||
if ((uint8_t)key == KEY_UP) return KEY_RIGHT;
|
||||
if ((uint8_t)key == KEY_RIGHT) return KEY_DOWN;
|
||||
if ((uint8_t)key == KEY_DOWN) return KEY_LEFT;
|
||||
if ((uint8_t)key == KEY_LEFT) return KEY_UP;
|
||||
break;
|
||||
case 2:
|
||||
if ((uint8_t)key == KEY_UP) return KEY_DOWN;
|
||||
if ((uint8_t)key == KEY_DOWN) return KEY_UP;
|
||||
if ((uint8_t)key == KEY_LEFT) return KEY_RIGHT;
|
||||
if ((uint8_t)key == KEY_RIGHT) return KEY_LEFT;
|
||||
break;
|
||||
case 3:
|
||||
if ((uint8_t)key == KEY_UP) return KEY_LEFT;
|
||||
if ((uint8_t)key == KEY_LEFT) return KEY_DOWN;
|
||||
if ((uint8_t)key == KEY_DOWN) return KEY_RIGHT;
|
||||
if ((uint8_t)key == KEY_RIGHT) return KEY_UP;
|
||||
break;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
class UIScreen {
|
||||
protected:
|
||||
UIScreen() { }
|
||||
|
||||
Reference in New Issue
Block a user