-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrecovery_keys.c
85 lines (63 loc) · 1.8 KB
/
recovery_keys.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <stdio.h>
#include <string.h>
#include <linux/input.h>
#include "recovery_ui.h"
#include "common.h"
#include "extendedcommands.h"
static int zatab_batch_number(void) {
char name[100];
FILE* fp = fopen("/sys/class/input/event3/device/name", "r");
if (fp == NULL)
return 0;
if (fgets(name, 99, fp) == NULL) {
fclose(fp);
return 0;
}
fclose(fp);
if (strncmp(name, "Goodix-TS-board-3", 17) == 0) /* first batch */
return 1;
/* this probably won't work until we get touch support */
if (strncmp(name, "gt80x", 5) == 0) /* second batch */
return 2;
/* undetected */
return 0;
}
int device_toggle_display(volatile char* key_pressed, int key_code) {
return 0;
}
int device_handle_key(int key_code, int visible) {
if (!visible)
return NO_ACTION;
switch (zatab_batch_number()) {
/* ZaTab batch 1 */
case 1: switch (key_code) {
case KEY_HOME: // VOL-
return HIGHLIGHT_DOWN;
case KEY_VOLUMEUP: // VOL+
return HIGHLIGHT_UP;
case KEY_POWER: // POWER
return SELECT_ITEM;
case KEY_ESC: // BACK
if (!ui_root_menu) {
return GO_BACK;
}
}
break;
/* ZaTab batch 2, default */
case 0:
case 2: switch (key_code) {
case KEY_SEARCH: // VOL-
return HIGHLIGHT_DOWN;
case KEY_MENU: // VOL+
return HIGHLIGHT_UP;
case KEY_POWER: // POWER
return SELECT_ITEM;
case KEY_HOME: // BACK
if (!ui_root_menu) {
return GO_BACK;
}
}
break;
}
return NO_ACTION;
}