Koushik Dutta | 0df56f4 | 2011-11-16 16:00:35 -0800 | [diff] [blame^] | 1 | #include <linux/input.h> |
| 2 | |
| 3 | #include "recovery_ui.h" |
| 4 | #include "common.h" |
| 5 | #include "extendedcommands.h" |
| 6 | |
| 7 | |
| 8 | int device_toggle_display(volatile char* key_pressed, int key_code) { |
| 9 | int alt = key_pressed[KEY_LEFTALT] || key_pressed[KEY_RIGHTALT]; |
| 10 | if (alt && key_code == KEY_L) |
| 11 | return 1; |
| 12 | // allow toggling of the display if the correct key is pressed, and the display toggle is allowed or the display is currently off |
| 13 | if (ui_get_showing_back_button()) { |
| 14 | return 0; |
| 15 | //return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END); |
| 16 | } |
| 17 | return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_POWER || key_code == KEY_END); |
| 18 | } |
| 19 | |
| 20 | int device_handle_key(int key_code, int visible) { |
| 21 | if (visible) { |
| 22 | switch (key_code) { |
| 23 | case KEY_CAPSLOCK: |
| 24 | case KEY_DOWN: |
| 25 | case KEY_VOLUMEDOWN: |
| 26 | case KEY_MENU: |
| 27 | return HIGHLIGHT_DOWN; |
| 28 | |
| 29 | case KEY_LEFTSHIFT: |
| 30 | case KEY_UP: |
| 31 | case KEY_VOLUMEUP: |
| 32 | case KEY_HOME: |
| 33 | return HIGHLIGHT_UP; |
| 34 | |
| 35 | case KEY_POWER: |
| 36 | if (ui_get_showing_back_button()) { |
| 37 | return SELECT_ITEM; |
| 38 | } |
| 39 | if (!get_allow_toggle_display()) |
| 40 | return GO_BACK; |
| 41 | break; |
| 42 | case KEY_LEFTBRACE: |
| 43 | case KEY_ENTER: |
| 44 | case BTN_MOUSE: |
| 45 | case KEY_CAMERA: |
| 46 | case KEY_F21: |
| 47 | case KEY_SEND: |
| 48 | return SELECT_ITEM; |
| 49 | |
| 50 | case KEY_END: |
| 51 | case KEY_BACKSPACE: |
| 52 | case KEY_SEARCH: |
| 53 | if (ui_get_showing_back_button()) { |
| 54 | return SELECT_ITEM; |
| 55 | } |
| 56 | if (!get_allow_toggle_display()) |
| 57 | return GO_BACK; |
| 58 | case KEY_BACK: |
| 59 | return GO_BACK; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | return NO_ACTION; |
| 64 | } |