summaryrefslogtreecommitdiff
path: root/apps/action.c
diff options
context:
space:
mode:
authorTomer Shalev <shalev.tomer@gmail.com>2009-10-05 17:53:45 +0000
committerTomer Shalev <shalev.tomer@gmail.com>2009-10-05 17:53:45 +0000
commita39be4b3073ef32a3e33bdbf88f0c1474c7b1931 (patch)
tree1f933f70ab0fc45a1aa8b1e95fb24969bd7d5b20 /apps/action.c
parentf7bd7252e14a151217f1a9b7eee6200eb23586a8 (diff)
downloadrockbox-a39be4b3073ef32a3e33bdbf88f0c1474c7b1931.tar.gz
rockbox-a39be4b3073ef32a3e33bdbf88f0c1474c7b1931.zip
Fix red: Invert buttons in RTL mode
- Revert renaming of button_set_flip() - Moved rtl flipping logic to apps/actions.c as a static function - Joined rtl_button_flip_needed() and button_flip_horizontally() git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22962 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/action.c')
-rw-r--r--apps/action.c55
1 files changed, 39 insertions, 16 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;
59static bool screen_has_lock = false; 59static bool screen_has_lock = false;
60#endif /* HAVE_SOFTWARE_KEYLOCK */ 60#endif /* HAVE_SOFTWARE_KEYLOCK */
61 61
62#if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
63/*
64 * checks whether the given language and context combination require that the
65 * button is horizontally inverted to support RTL language
66 *
67 */
68static bool rtl_button_flip_needed(int context)
69{
70 return lang_is_rtl() && ((context == CONTEXT_STD) ||
71 (context & CONTEXT_TREE) || (context & CONTEXT_MAINMENU) ||
72 (context & CONTEXT_TREE));
73}
74#endif
75
76/* 62/*
77 * do_button_check is the worker function for get_default_action. 63 * do_button_check is the worker function for get_default_action.
78 * returns ACTION_UNKNOWN or the requested return value from the list. 64 * 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,
100 return ret; 86 return ret;
101} 87}
102 88
89#if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
90/*
91 * button is horizontally inverted to support RTL language if the given language
92 * and context combination require that
93 */
94static int button_flip_horizontally(int context, int button)
95{
96 int newbutton;
97
98 if (!(lang_is_rtl() && ((context == CONTEXT_STD) ||
99 (context & CONTEXT_TREE) || (context & CONTEXT_MAINMENU) ||
100 (context & CONTEXT_TREE))))
101 {
102 return button;
103 }
104
105 newbutton = button &
106 ~(BUTTON_LEFT | BUTTON_RIGHT
107#if defined(BUTTON_SCROLL_BACK) && defined(BUTTON_SCROLL_FWD)
108 | BUTTON_SCROLL_BACK | BUTTON_SCROLL_FWD
109#endif
110 );
111
112 if (button & BUTTON_LEFT)
113 newbutton |= BUTTON_RIGHT;
114 if (button & BUTTON_RIGHT)
115 newbutton |= BUTTON_LEFT;
116#if defined(BUTTON_SCROLL_BACK) && defined(BUTTON_SCROLL_FWD)
117 if (button & BUTTON_SCROLL_BACK)
118 newbutton |= BUTTON_SCROLL_FWD;
119 if (button & BUTTON_SCROLL_FWD)
120 newbutton |= BUTTON_SCROLL_BACK;
121#endif
122
123 return newbutton;
124}
125#endif
126
103static inline int get_next_context(const struct button_mapping *items, int i) 127static inline int get_next_context(const struct button_mapping *items, int i)
104{ 128{
105 while (items[i].button_code != BUTTON_NONE) 129 while (items[i].button_code != BUTTON_NONE)
@@ -219,8 +243,7 @@ static int get_action_worker(int context, int timeout,
219#endif /* HAS_BUTTON_HOLD */ 243#endif /* HAS_BUTTON_HOLD */
220 244
221#if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER) 245#if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
222 if (rtl_button_flip_needed(context)) 246 button = button_flip_horizontally(context, button);
223 button = button_flip_horizontally(button);
224#endif 247#endif
225 248
226 /* logf("%x,%x",last_button,button); */ 249 /* logf("%x,%x",last_button,button); */