blob: 09bf19cec5518d78bd27ba0fb52dbd90785526a2 [file] [log] [blame]
Doug Zongkerddd6a282009-06-09 12:22:33 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <linux/input.h>
18
19#include "recovery_ui.h"
20#include "common.h"
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080021#include "extendedcommands.h"
Doug Zongkerddd6a282009-06-09 12:22:33 -070022
Koushik K. Dutta261dde92010-02-25 16:51:45 -080023char* MENU_HEADERS[] = { NULL };
Doug Zongkerddd6a282009-06-09 12:22:33 -070024
25char* MENU_ITEMS[] = { "reboot system now",
26 "apply sdcard:update.zip",
27 "wipe data/factory reset",
28 "wipe cache partition",
Koushik K. Duttae9234872010-02-12 00:43:24 -080029 "install zip from sdcard",
Koushik K. Dutta5899ac92010-03-19 13:34:36 -070030 "nandroid",
31 "partitions menu",
32 "advanced",
Doug Zongkerddd6a282009-06-09 12:22:33 -070033 NULL };
34
Doug Zongker23412e62009-07-23 10:16:07 -070035int device_toggle_display(volatile char* key_pressed, int key_code) {
Koushik K. Dutta0d4ff2f2010-02-08 15:05:21 -080036 int alt = key_pressed[KEY_LEFTALT] || key_pressed[KEY_RIGHTALT];
37 if (alt && key_code == KEY_L)
38 return 1;
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080039 // allow toggling of the display if the correct key is pressed, and the display toggle is allowed or the display is currently off
Koushik Dutta1bf4f692010-07-14 18:37:33 -070040 if (ui_get_showing_back_button()) {
41 return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END);
42 }
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080043 return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_POWER || key_code == KEY_END);
Doug Zongkerddd6a282009-06-09 12:22:33 -070044}
45
Doug Zongker23412e62009-07-23 10:16:07 -070046int device_reboot_now(volatile char* key_pressed, int key_code) {
Doug Zongkercbb91292009-06-11 14:54:41 -070047 return 0;
Doug Zongkerddd6a282009-06-09 12:22:33 -070048}
49
50int device_handle_key(int key_code, int visible) {
Doug Zongkercbb91292009-06-11 14:54:41 -070051 if (visible) {
52 switch (key_code) {
Koushik Dutta5aaa8232010-07-20 16:23:18 -070053 case KEY_CAPSLOCK:
Doug Zongkercbb91292009-06-11 14:54:41 -070054 case KEY_DOWN:
55 case KEY_VOLUMEDOWN:
56 return HIGHLIGHT_DOWN;
Doug Zongkerddd6a282009-06-09 12:22:33 -070057
Koushik Dutta5aaa8232010-07-20 16:23:18 -070058 case KEY_LEFTSHIFT:
Doug Zongkercbb91292009-06-11 14:54:41 -070059 case KEY_UP:
60 case KEY_VOLUMEUP:
61 return HIGHLIGHT_UP;
Doug Zongkerddd6a282009-06-09 12:22:33 -070062
Koushik Duttaf4e3a672010-06-09 12:19:41 -070063 case KEY_POWER:
Koushik Dutta1bf4f692010-07-14 18:37:33 -070064 if (ui_get_showing_back_button()) {
65 return SELECT_ITEM;
66 }
67 if (!get_allow_toggle_display())
68 return GO_BACK;
69 break;
Koushik Dutta5aaa8232010-07-20 16:23:18 -070070 case KEY_LEFTBRACE:
Doug Zongkercbb91292009-06-11 14:54:41 -070071 case KEY_ENTER:
Koushik K. Dutta89d385c2010-02-04 14:17:32 -080072 case BTN_MOUSE:
Koushik K. Duttab9546a82010-03-14 22:42:30 -070073 case KEY_CENTER:
74 case KEY_CAMERA:
Koushik K. Duttaa5f64e62010-04-05 15:44:57 -070075 case KEY_F21:
76 case KEY_SEND:
Doug Zongkercbb91292009-06-11 14:54:41 -070077 return SELECT_ITEM;
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080078
Koushik K. Duttae9234872010-02-12 00:43:24 -080079 case KEY_END:
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080080 case KEY_BACKSPACE:
Koushik K. Duttac0970932010-03-25 23:19:19 -070081 case KEY_BACK:
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080082 if (!get_allow_toggle_display())
83 return GO_BACK;
Doug Zongkercbb91292009-06-11 14:54:41 -070084 }
Doug Zongkerddd6a282009-06-09 12:22:33 -070085 }
Doug Zongkerddd6a282009-06-09 12:22:33 -070086
Doug Zongkercbb91292009-06-11 14:54:41 -070087 return NO_ACTION;
Doug Zongkerddd6a282009-06-09 12:22:33 -070088}
89
Doug Zongkercbb91292009-06-11 14:54:41 -070090int device_perform_action(int which) {
91 return which;
Doug Zongkerddd6a282009-06-09 12:22:33 -070092}
Doug Zongkerb128f542009-06-18 15:07:14 -070093
94int device_wipe_data() {
95 return 0;
96}