diff options
author | Tomer Shalev <shalev.tomer@gmail.com> | 2009-10-05 17:17:30 +0000 |
---|---|---|
committer | Tomer Shalev <shalev.tomer@gmail.com> | 2009-10-05 17:17:30 +0000 |
commit | f7bd7252e14a151217f1a9b7eee6200eb23586a8 (patch) | |
tree | 2a676f3f9dc9248bfb8a9c6b1a39b4197471708c | |
parent | e04acd8c3e8cbcec4eab0ffe046ec0935a15ab85 (diff) | |
download | rockbox-f7bd7252e14a151217f1a9b7eee6200eb23586a8.tar.gz rockbox-f7bd7252e14a151217f1a9b7eee6200eb23586a8.zip |
Invert buttons in RTL mode
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22961 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/action.c | 22 | ||||
-rw-r--r-- | apps/menus/display_menu.c | 2 | ||||
-rw-r--r-- | apps/settings.c | 2 | ||||
-rw-r--r-- | firmware/drivers/button.c | 38 | ||||
-rw-r--r-- | firmware/export/button.h | 5 | ||||
-rw-r--r-- | uisimulator/common/stubs.c | 2 |
6 files changed, 63 insertions, 8 deletions
diff --git a/apps/action.c b/apps/action.c index ee84706b09..cde57441e7 100644 --- a/apps/action.c +++ b/apps/action.c | |||
@@ -34,6 +34,9 @@ | |||
34 | #include "settings.h" | 34 | #include "settings.h" |
35 | #include "pcmbuf.h" | 35 | #include "pcmbuf.h" |
36 | #include "misc.h" | 36 | #include "misc.h" |
37 | #if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER) | ||
38 | #include "language.h" | ||
39 | #endif | ||
37 | 40 | ||
38 | static int last_button = BUTTON_NONE|BUTTON_REL; /* allow the ipod wheel to | 41 | static int last_button = BUTTON_NONE|BUTTON_REL; /* allow the ipod wheel to |
39 | work on startup */ | 42 | work on startup */ |
@@ -56,6 +59,20 @@ static int unlock_combo = BUTTON_NONE; | |||
56 | static bool screen_has_lock = false; | 59 | static bool screen_has_lock = false; |
57 | #endif /* HAVE_SOFTWARE_KEYLOCK */ | 60 | #endif /* HAVE_SOFTWARE_KEYLOCK */ |
58 | 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 | */ | ||
68 | static 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 | |||
59 | /* | 76 | /* |
60 | * do_button_check is the worker function for get_default_action. | 77 | * do_button_check is the worker function for get_default_action. |
61 | * returns ACTION_UNKNOWN or the requested return value from the list. | 78 | * returns ACTION_UNKNOWN or the requested return value from the list. |
@@ -201,6 +218,11 @@ static int get_action_worker(int context, int timeout, | |||
201 | context &= ~ALLOW_SOFTLOCK; | 218 | context &= ~ALLOW_SOFTLOCK; |
202 | #endif /* HAS_BUTTON_HOLD */ | 219 | #endif /* HAS_BUTTON_HOLD */ |
203 | 220 | ||
221 | #if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER) | ||
222 | if (rtl_button_flip_needed(context)) | ||
223 | button = button_flip_horizontally(button); | ||
224 | #endif | ||
225 | |||
204 | /* logf("%x,%x",last_button,button); */ | 226 | /* logf("%x,%x",last_button,button); */ |
205 | while (1) | 227 | while (1) |
206 | { | 228 | { |
diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c index 5559ecebe7..afbb19c60d 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) | |||
67 | switch (action) | 67 | switch (action) |
68 | { | 68 | { |
69 | case ACTION_EXIT_MENUITEM: | 69 | case ACTION_EXIT_MENUITEM: |
70 | button_set_flip(global_settings.flip_display); | 70 | button_set_flip_vertically(global_settings.flip_display); |
71 | lcd_set_flip(global_settings.flip_display); | 71 | lcd_set_flip(global_settings.flip_display); |
72 | lcd_update(); | 72 | lcd_update(); |
73 | #ifdef HAVE_REMOTE_LCD | 73 | #ifdef HAVE_REMOTE_LCD |
diff --git a/apps/settings.c b/apps/settings.c index ce1ee07054..ac80d12492 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -846,7 +846,7 @@ void settings_apply(bool read_disk) | |||
846 | #endif | 846 | #endif |
847 | #ifdef HAVE_LCD_FLIP | 847 | #ifdef HAVE_LCD_FLIP |
848 | lcd_set_flip(global_settings.flip_display); | 848 | lcd_set_flip(global_settings.flip_display); |
849 | button_set_flip(global_settings.flip_display); | 849 | button_set_flip_vertically(global_settings.flip_display); |
850 | #endif | 850 | #endif |
851 | lcd_update(); /* refresh after flipping the screen */ | 851 | lcd_update(); /* refresh after flipping the screen */ |
852 | settings_apply_pm_range(); | 852 | settings_apply_pm_range(); |
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 71cd4726cc..7f37087783 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -437,7 +437,7 @@ void button_close(void) | |||
437 | /* | 437 | /* |
438 | * helper function to swap LEFT/RIGHT, UP/DOWN (if present), and F1/F3 (Recorder) | 438 | * helper function to swap LEFT/RIGHT, UP/DOWN (if present), and F1/F3 (Recorder) |
439 | */ | 439 | */ |
440 | static int button_flip(int button) | 440 | static int button_flip_vertically(int button) |
441 | { | 441 | { |
442 | int newbutton; | 442 | int newbutton; |
443 | 443 | ||
@@ -507,19 +507,49 @@ static int button_flip(int button) | |||
507 | * set the flip attribute | 507 | * set the flip attribute |
508 | * better only call this when the queue is empty | 508 | * better only call this when the queue is empty |
509 | */ | 509 | */ |
510 | void button_set_flip(bool flip) | 510 | void button_set_flip_vertically(bool flip) |
511 | { | 511 | { |
512 | if (flip != flipped) /* not the current setting */ | 512 | if (flip != flipped) /* not the current setting */ |
513 | { | 513 | { |
514 | /* avoid race condition with the button_tick() */ | 514 | /* avoid race condition with the button_tick() */ |
515 | int oldlevel = disable_irq_save(); | 515 | int oldlevel = disable_irq_save(); |
516 | lastbtn = button_flip(lastbtn); | 516 | lastbtn = button_flip_vertically(lastbtn); |
517 | flipped = flip; | 517 | flipped = flip; |
518 | restore_irq(oldlevel); | 518 | restore_irq(oldlevel); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | #endif /* HAVE_LCD_FLIP */ | 521 | #endif /* HAVE_LCD_FLIP */ |
522 | 522 | ||
523 | #if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER) | ||
524 | /* | ||
525 | * helper function to swap LEFT/RIGHT sides (for RTL mode) | ||
526 | */ | ||
527 | int button_flip_horizontally(int button) | ||
528 | { | ||
529 | int newbutton; | ||
530 | |||
531 | newbutton = button & | ||
532 | ~(BUTTON_LEFT | BUTTON_RIGHT | ||
533 | #if defined(BUTTON_SCROLL_BACK) && defined(BUTTON_SCROLL_FWD) | ||
534 | | BUTTON_SCROLL_BACK | BUTTON_SCROLL_FWD | ||
535 | #endif | ||
536 | ); | ||
537 | |||
538 | if (button & BUTTON_LEFT) | ||
539 | newbutton |= BUTTON_RIGHT; | ||
540 | if (button & BUTTON_RIGHT) | ||
541 | newbutton |= BUTTON_LEFT; | ||
542 | #if defined(BUTTON_SCROLL_BACK) && defined(BUTTON_SCROLL_FWD) | ||
543 | if (button & BUTTON_SCROLL_BACK) | ||
544 | newbutton |= BUTTON_SCROLL_FWD; | ||
545 | if (button & BUTTON_SCROLL_FWD) | ||
546 | newbutton |= BUTTON_SCROLL_BACK; | ||
547 | #endif | ||
548 | |||
549 | return newbutton; | ||
550 | } | ||
551 | #endif | ||
552 | |||
523 | #ifdef HAVE_BACKLIGHT | 553 | #ifdef HAVE_BACKLIGHT |
524 | void set_backlight_filter_keypress(bool value) | 554 | void set_backlight_filter_keypress(bool value) |
525 | { | 555 | { |
@@ -550,7 +580,7 @@ static int button_read(void) | |||
550 | 580 | ||
551 | #ifdef HAVE_LCD_FLIP | 581 | #ifdef HAVE_LCD_FLIP |
552 | if (btn && flipped) | 582 | if (btn && flipped) |
553 | btn = button_flip(btn); /* swap upside down */ | 583 | btn = button_flip_vertically(btn); /* swap upside down */ |
554 | #endif /* HAVE_LCD_FLIP */ | 584 | #endif /* HAVE_LCD_FLIP */ |
555 | 585 | ||
556 | #ifdef HAVE_TOUCHSCREEN | 586 | #ifdef HAVE_TOUCHSCREEN |
diff --git a/firmware/export/button.h b/firmware/export/button.h index 3aac1af9d6..2e75c573df 100644 --- a/firmware/export/button.h +++ b/firmware/export/button.h | |||
@@ -42,7 +42,10 @@ int button_status_wdata(int *pdata); | |||
42 | #endif | 42 | #endif |
43 | void button_clear_queue(void); | 43 | void button_clear_queue(void); |
44 | #ifdef HAVE_LCD_BITMAP | 44 | #ifdef HAVE_LCD_BITMAP |
45 | void button_set_flip(bool flip); /* turn 180 degrees */ | 45 | void button_set_flip_vertically(bool flip); /* turn 180 degrees */ |
46 | #ifndef BOOTLOADER | ||
47 | int button_flip_horizontally(int button); /* for RTL mode */ | ||
48 | #endif | ||
46 | #endif | 49 | #endif |
47 | #ifdef HAVE_BACKLIGHT | 50 | #ifdef HAVE_BACKLIGHT |
48 | void set_backlight_filter_keypress(bool value); | 51 | void set_backlight_filter_keypress(bool value); |
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 2218c497f8..cd9e7b8ad9 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c | |||
@@ -312,7 +312,7 @@ void cpu_sleep(bool enabled) | |||
312 | (void)enabled; | 312 | (void)enabled; |
313 | } | 313 | } |
314 | 314 | ||
315 | void button_set_flip(bool yesno) | 315 | void button_set_flip_vertically(bool yesno) |
316 | { | 316 | { |
317 | (void)yesno; | 317 | (void)yesno; |
318 | } | 318 | } |