summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/action.c55
-rw-r--r--apps/menus/display_menu.c2
-rw-r--r--apps/settings.c2
-rw-r--r--firmware/drivers/button.c38
-rw-r--r--firmware/export/button.h5
-rw-r--r--uisimulator/common/stubs.c2
6 files changed, 47 insertions, 57 deletions
diff --git a/apps/action.c b/apps/action.c
index cde57441e7..055171174b 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -59,20 +59,6 @@ static int unlock_combo = BUTTON_NONE;
static bool screen_has_lock = false;
#endif /* HAVE_SOFTWARE_KEYLOCK */
-#if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
-/*
- * checks whether the given language and context combination require that the
- * button is horizontally inverted to support RTL language
- *
- */
-static bool rtl_button_flip_needed(int context)
-{
- return lang_is_rtl() && ((context == CONTEXT_STD) ||
- (context & CONTEXT_TREE) || (context & CONTEXT_MAINMENU) ||
- (context & CONTEXT_TREE));
-}
-#endif
-
/*
* do_button_check is the worker function for get_default_action.
* returns ACTION_UNKNOWN or the requested return value from the list.
@@ -100,6 +86,44 @@ static inline int do_button_check(const struct button_mapping *items,
return ret;
}
+#if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
+/*
+ * button is horizontally inverted to support RTL language if the given language
+ * and context combination require that
+ */
+static int button_flip_horizontally(int context, int button)
+{
+ int newbutton;
+
+ if (!(lang_is_rtl() && ((context == CONTEXT_STD) ||
+ (context & CONTEXT_TREE) || (context & CONTEXT_MAINMENU) ||
+ (context & CONTEXT_TREE))))
+ {
+ return button;
+ }
+
+ newbutton = button &
+ ~(BUTTON_LEFT | BUTTON_RIGHT
+#if defined(BUTTON_SCROLL_BACK) && defined(BUTTON_SCROLL_FWD)
+ | BUTTON_SCROLL_BACK | BUTTON_SCROLL_FWD
+#endif
+ );
+
+ if (button & BUTTON_LEFT)
+ newbutton |= BUTTON_RIGHT;
+ if (button & BUTTON_RIGHT)
+ newbutton |= BUTTON_LEFT;
+#if defined(BUTTON_SCROLL_BACK) && defined(BUTTON_SCROLL_FWD)
+ if (button & BUTTON_SCROLL_BACK)
+ newbutton |= BUTTON_SCROLL_FWD;
+ if (button & BUTTON_SCROLL_FWD)
+ newbutton |= BUTTON_SCROLL_BACK;
+#endif
+
+ return newbutton;
+}
+#endif
+
static inline int get_next_context(const struct button_mapping *items, int i)
{
while (items[i].button_code != BUTTON_NONE)
@@ -219,8 +243,7 @@ static int get_action_worker(int context, int timeout,
#endif /* HAS_BUTTON_HOLD */
#if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
- if (rtl_button_flip_needed(context))
- button = button_flip_horizontally(button);
+ button = button_flip_horizontally(context, button);
#endif
/* logf("%x,%x",last_button,button); */
diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c
index afbb19c60d..5559ecebe7 100644
--- a/apps/menus/display_menu.c
+++ b/apps/menus/display_menu.c
@@ -67,7 +67,7 @@ static int flipdisplay_callback(int action,const struct menu_item_ex *this_item)
switch (action)
{
case ACTION_EXIT_MENUITEM:
- button_set_flip_vertically(global_settings.flip_display);
+ button_set_flip(global_settings.flip_display);
lcd_set_flip(global_settings.flip_display);
lcd_update();
#ifdef HAVE_REMOTE_LCD
diff --git a/apps/settings.c b/apps/settings.c
index ac80d12492..ce1ee07054 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -846,7 +846,7 @@ void settings_apply(bool read_disk)
#endif
#ifdef HAVE_LCD_FLIP
lcd_set_flip(global_settings.flip_display);
- button_set_flip_vertically(global_settings.flip_display);
+ button_set_flip(global_settings.flip_display);
#endif
lcd_update(); /* refresh after flipping the screen */
settings_apply_pm_range();
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 7f37087783..71cd4726cc 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -437,7 +437,7 @@ void button_close(void)
/*
* helper function to swap LEFT/RIGHT, UP/DOWN (if present), and F1/F3 (Recorder)
*/
-static int button_flip_vertically(int button)
+static int button_flip(int button)
{
int newbutton;
@@ -507,49 +507,19 @@ static int button_flip_vertically(int button)
* set the flip attribute
* better only call this when the queue is empty
*/
-void button_set_flip_vertically(bool flip)
+void button_set_flip(bool flip)
{
if (flip != flipped) /* not the current setting */
{
/* avoid race condition with the button_tick() */
int oldlevel = disable_irq_save();
- lastbtn = button_flip_vertically(lastbtn);
+ lastbtn = button_flip(lastbtn);
flipped = flip;
restore_irq(oldlevel);
}
}
#endif /* HAVE_LCD_FLIP */
-#if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
-/*
- * helper function to swap LEFT/RIGHT sides (for RTL mode)
- */
-int button_flip_horizontally(int button)
-{
- int newbutton;
-
- newbutton = button &
- ~(BUTTON_LEFT | BUTTON_RIGHT
-#if defined(BUTTON_SCROLL_BACK) && defined(BUTTON_SCROLL_FWD)
- | BUTTON_SCROLL_BACK | BUTTON_SCROLL_FWD
-#endif
- );
-
- if (button & BUTTON_LEFT)
- newbutton |= BUTTON_RIGHT;
- if (button & BUTTON_RIGHT)
- newbutton |= BUTTON_LEFT;
-#if defined(BUTTON_SCROLL_BACK) && defined(BUTTON_SCROLL_FWD)
- if (button & BUTTON_SCROLL_BACK)
- newbutton |= BUTTON_SCROLL_FWD;
- if (button & BUTTON_SCROLL_FWD)
- newbutton |= BUTTON_SCROLL_BACK;
-#endif
-
- return newbutton;
-}
-#endif
-
#ifdef HAVE_BACKLIGHT
void set_backlight_filter_keypress(bool value)
{
@@ -580,7 +550,7 @@ static int button_read(void)
#ifdef HAVE_LCD_FLIP
if (btn && flipped)
- btn = button_flip_vertically(btn); /* swap upside down */
+ btn = button_flip(btn); /* swap upside down */
#endif /* HAVE_LCD_FLIP */
#ifdef HAVE_TOUCHSCREEN
diff --git a/firmware/export/button.h b/firmware/export/button.h
index 2e75c573df..3aac1af9d6 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -42,10 +42,7 @@ int button_status_wdata(int *pdata);
#endif
void button_clear_queue(void);
#ifdef HAVE_LCD_BITMAP
-void button_set_flip_vertically(bool flip); /* turn 180 degrees */
-#ifndef BOOTLOADER
-int button_flip_horizontally(int button); /* for RTL mode */
-#endif
+void button_set_flip(bool flip); /* turn 180 degrees */
#endif
#ifdef HAVE_BACKLIGHT
void set_backlight_filter_keypress(bool value);
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index cd9e7b8ad9..2218c497f8 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -312,7 +312,7 @@ void cpu_sleep(bool enabled)
(void)enabled;
}
-void button_set_flip_vertically(bool yesno)
+void button_set_flip(bool yesno)
{
(void)yesno;
}