This source file includes following definitions.
- mykbd_task_proceed
- mykbd_task_proceed_2
- mykbd_task
- wrap_kbd_p1_f
- my_kbd_read_keys
1 #include "lolevel.h"
2 #include "platform.h"
3 #include "conf.h"
4 #include "core.h"
5 #include "keyboard.h"
6 #include "kbd_common.h"
7
8 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
9 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
10 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
11
12 KeyMap keymap[] = {
13
14
15
16 {1, KEY_UP , 0x00000020 },
17 {1, KEY_DOWN , 0x00000040 },
18 {1, KEY_LEFT , 0x00000080 },
19 {1, KEY_RIGHT , 0x00000100 },
20 {1, KEY_SET , 0x00000200 },
21 {1, KEY_SHOOT_FULL, 0x00000006 },
22 {1, KEY_SHOOT_FULL_ONLY, 0x00000004 },
23 {1, KEY_SHOOT_HALF, 0x00000002 },
24 {1, KEY_ZOOM_IN , 0x00000008 },
25 {1, KEY_ZOOM_OUT , 0x00000010 },
26 {1, KEY_MENU , 0x00000400 },
27 {1, KEY_DISPLAY , 0x00000800 },
28 {1, KEY_PRINT , 0x00002000 },
29 {0, 0, 0 }
30 };
31
32 #define NEW_SS (0x2000)
33
34 static char kbd_stack[NEW_SS];
35
36 long __attribute__((naked)) wrap_kbd_p1_f();
37 void __attribute__((naked,noinline)) mykbd_task_proceed_2();
38 extern void h_kbd_p2_f();
39
40
41 static void __attribute__((noinline)) mykbd_task_proceed()
42 {
43 asm volatile(
44 "STMFD SP!, {R4,LR}\n"
45 "B mykbd_task_proceed_2\n"
46 );
47 }
48
49
50
51
52 void __attribute__((noinline)) mykbd_task_proceed_2()
53 {
54 asm volatile(
55 "loc_FF828CCC:\n"
56 "MOV R0, #0xA\n"
57 "BL _SleepTask\n"
58 "BL wrap_kbd_p1_f\n"
59 "CMP R0, #1\n"
60 "BNE loc_FF828CCC\n"
61 "B h_kbd_p2_f\n"
62 );
63 }
64
65
66 void __attribute__((naked,noinline))
67 mykbd_task(long ua, long ub, long uc, long ud, long ue, long uf)
68 {
69 (void)ua; (void)ub; (void)uc; (void)ud; (void)ue; (void)uf;
70
71
72
73
74
75
76
77
78
79
80 register int i;
81 register long *newstack;
82
83 newstack = (void*)kbd_stack;
84
85 for (i=0;i<NEW_SS/4;i++)
86 newstack[i]=0xdededede;
87
88 asm volatile (
89 "MOV SP, %0"
90 :: "r"(((char*)newstack)+NEW_SS)
91 : "memory"
92 );
93
94 mykbd_task_proceed();
95
96
97
98
99 _ExitTask();
100 }
101
102
103
104 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
105 {
106
107 kbd_prev_state[1] = kbd_new_state[1];
108
109
110 asm volatile(
111 "STMFD SP!, {R4-R10,LR}\n"
112 "LDR R4, =physw_status-0x10\n"
113 "SUB SP, SP, #0x18\n"
114 "BL _kbd_p1_1\n"
115 "BL _kbd_p1_2\n"
116 "MOV R0, #0x32\n"
117 "BL _kbd_p1_3\n"
118 "MOV R0, R4\n"
119 "BL _platformsub_kbd_fetch_data_my\n"
120 "B _kbd_p1_f_cont\n"
121
122 );
123 return 0;
124 }
125
126
127 long my_kbd_read_keys(long x)
128 {
129 kbd_new_state[1]=x & 0xFFFF;
130 if (kbd_process() == 0) return x; else return (kbd_new_state[1]&~KEYS_MASK1) | (kbd_mod_state[1] & KEYS_MASK1);
131 }