blob: fd0ef740288baa82e952e7bb1f3ecbd450117938 [file] [log] [blame]
Koushik Dutta0df56f42011-11-16 16:00:35 -08001#include <linux/input.h>
2
3#include "recovery_ui.h"
4#include "common.h"
5#include "extendedcommands.h"
6
7
8int 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
20int 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 }
CEnnis914f781762012-01-14 23:51:58 -050039 if (!get_allow_toggle_display() && ui_menu_level > 0) {
Koushik Dutta0df56f42011-11-16 16:00:35 -080040 return GO_BACK;
CEnnis914f781762012-01-14 23:51:58 -050041 }
Koushik Dutta0df56f42011-11-16 16:00:35 -080042 break;
43 case KEY_LEFTBRACE:
44 case KEY_ENTER:
45 case BTN_MOUSE:
46 case KEY_CAMERA:
47 case KEY_F21:
48 case KEY_SEND:
49 return SELECT_ITEM;
50
51 case KEY_END:
52 case KEY_BACKSPACE:
53 case KEY_SEARCH:
54 if (ui_get_showing_back_button()) {
55 return SELECT_ITEM;
56 }
CEnnis914f781762012-01-14 23:51:58 -050057 if (!get_allow_toggle_display() && ui_menu_level > 0) {
Koushik Dutta0df56f42011-11-16 16:00:35 -080058 return GO_BACK;
CEnnis914f781762012-01-14 23:51:58 -050059 }
Koushik Dutta0df56f42011-11-16 16:00:35 -080060 case KEY_BACK:
CEnnis914f781762012-01-14 23:51:58 -050061 if (ui_menu_level > 0) {
62 return GO_BACK;
63 }
Koushik Dutta0df56f42011-11-16 16:00:35 -080064 }
65 }
66
67 return NO_ACTION;
68}