This source file includes following definitions.
- get_usb_bit
- wrap_kbd_p1_f
- mykbd_task
- kbd_fetch_data
- my_kbd_read_keys
- enable_extra_button
- kbd_set_extra_button
- jogdial_control
- Get_JogDial
- get_jogdial_direction
1 #include "lolevel.h"
2 #include "platform.h"
3 #include "core.h"
4 #include "keyboard.h"
5 #include "conf.h"
6 #include "kbd_common.h"
7
8 KeyMap keymap[] = {
9
10
11
12 { 1, KEY_POWER ,0x00000001 },
13 { 1, KEY_ZOOM_OUT ,0x00002000 },
14 { 1, KEY_ZOOM_IN ,0x00004000 },
15 { 1, KEY_SHOOT_FULL ,0x00009000 },
16 { 1, KEY_SHOOT_FULL_ONLY ,0x00008000 },
17 { 1, KEY_SHOOT_HALF ,0x00001000 },
18 { 2, KEY_LEFT ,0x00000020 },
19 { 2, KEY_RIGHT ,0x00000040 },
20 { 2, KEY_DOWN ,0x00000080 },
21 { 2, KEY_UP ,0x00000200 },
22 { 2, KEY_SET ,0x00000400 },
23 { 2, KEY_MENU ,0x00000800 },
24 { 2, KEY_PLAYBACK ,0x00004000 },
25
26
27
28
29 { 0, 0 ,0x00000000 },
30 { 0, 0, 0 }
31 };
32
33
34 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
35 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
36 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
37
38 int keys_mask1=0x0000F000;
39 static int set_fake_key=0;
40
41 int get_usb_bit()
42 {
43 long usb_physw[3];
44 usb_physw[USB_IDX] = 0;
45 _kbd_read_keys_r2(usb_physw);
46 return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ;
47 }
48
49 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
50 {
51
52 asm volatile(
53 "STMFD SP!, {R1-R5,LR}\n"
54 "MOV R4, #0\n"
55 "BL my_kbd_read_keys\n"
56 "B _kbd_p1_f_cont\n"
57 );
58 return 0;
59 }
60
61 void __attribute__((noinline)) mykbd_task()
62 {
63 while (physw_run){
64 _SleepTask(10);
65
66 if (wrap_kbd_p1_f() == 1){
67 _kbd_p2_f();
68 }
69 }
70
71 _ExitTask();
72 }
73
74 extern void _GetKbdState(long*);
75 long get_jogdial_direction();
76 int jogdial_stopped=0;
77 void enable_extra_button(short);
78
79 void kbd_fetch_data(long *state) {
80 _GetKbdState(state);
81 _kbd_read_keys_r2(state);
82 }
83
84 void my_kbd_read_keys()
85 {
86 kbd_update_key_state();
87 kbd_update_physw_bits();
88
89 if (set_fake_key & 0x10000000) {
90 enable_extra_button((short)(set_fake_key & 0xffff));
91 set_fake_key=0;
92 }
93 }
94
95 void enable_extra_button(short key) {
96
97
98
99
100
101
102
103 if (key) {
104 keys_mask1=0x0000F001;
105 keymap[13].grp=1;
106 keymap[13].canonkey=0x00000001;
107 keymap[13].hackkey=key;
108 }
109 else {
110 keys_mask1=0x0000F000;
111 keymap[13].grp=0;
112 keymap[13].canonkey=0;
113 keymap[13].hackkey=0;
114 }
115 }
116
117 void kbd_set_extra_button(short key) {
118 set_fake_key=key|0x10000000;
119 }
120
121 void jogdial_control(int n) {
122 jogdial_stopped = n;
123 }
124
125 static int new_jogdial=0, old_jogdial=0;
126
127 int Get_JogDial(void){
128 return (*(int*)0xC0240104)>>16;
129 }
130
131 long get_jogdial_direction(void) {
132 old_jogdial=new_jogdial;
133 new_jogdial=Get_JogDial();
134 if (old_jogdial<new_jogdial) return JOGDIAL_RIGHT;
135 else if (old_jogdial>new_jogdial) return JOGDIAL_LEFT;
136 else return 0;
137 }