This source file includes following definitions.
- get_usb_bit
- wrap_kbd_p1_f
- mykbd_task
- get_dial_hw_position
- get_jogdial_counter
- get_jogdial_direction
- handle_jogdial
- jogdial_control
- my_kbd_read_keys
- kbd_fetch_data
1 #include "lolevel.h"
2 #include "platform.h"
3 #include "keyboard.h"
4 #include "kbd_common.h"
5
6 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
7 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
8 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
9
10 extern void _GetKbdState(long*);
11 extern void _LogCameraEvent(int id, const char *fmt,...);
12
13
14
15 int get_usb_bit() {
16 long usb_physw[3];
17 usb_physw[USB_IDX] = 0;
18 _kbd_read_keys_r2(usb_physw);
19 return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ;
20 }
21
22
23
24
25
26
27
28
29 KeyMap keymap[] = {
30 { 0, KEY_SHOOT_FULL ,0x00040001 },
31 { 0, KEY_SHOOT_HALF ,0x00040000 },
32 { 0, KEY_SHOOT_FULL_ONLY ,0x00000001 },
33 { 0, KEY_VIDEO ,0x00000008 },
34 { 0, KEY_MENU ,0x00000010 },
35 { 0, KEY_UP ,0x00000020 },
36 { 0, KEY_DOWN ,0x00000040 },
37 { 0, KEY_RIGHT ,0x00000080 },
38 { 0, KEY_LEFT ,0x00000100 },
39 { 0, KEY_SET ,0x00000200 },
40 { 0, KEY_ERASE ,0x00000400 },
41 { 0, KEY_WIFI ,0x00002000 },
42 { 0, KEY_FACE ,0x00000800 },
43 { 0, KEY_PRINT ,0x00004000 },
44 { 0, KEY_FRAMING_ASSIST ,0x00000002 },
45 { 0, KEY_ZOOM_ASSIST ,0x00000004 },
46 { 0, KEY_PLAYBACK ,0x00010000 },
47
48 { 2, KEY_ZOOM_OUT ,0x00000008 },
49 { 2, KEY_ZOOM_OUT ,0x00000018 },
50 { 2, KEY_ZOOM_OUT ,0x00000010 },
51 { 2, KEY_ZOOM_IN ,0x00000002 },
52 { 2, KEY_ZOOM_IN ,0x00000006 },
53 { 2, KEY_ZOOM_IN ,0x00000004 },
54
55 { 0, 0, 0 }
56 };
57 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
58
59 asm volatile(
60 "push {r1-r7, lr}\n"
61 "movs r4, #0\n"
62 "bl my_kbd_read_keys\n"
63 "b _kbd_p1_f_cont\n"
64 );
65
66 return 0;
67 }
68
69
70 void __attribute__((noinline)) mykbd_task() {
71 extern void kbd_p2_f_my();
72 while (physw_run) {
73 _SleepTask(physw_sleep_delay);
74
75 if (wrap_kbd_p1_f() == 1) {
76 kbd_p2_f_my();
77 }
78 }
79
80 _ExitTask();
81 }
82
83
84
85
86 int jogdial_stopped = 0;
87 extern int _get_dial_hw_position(int dial);
88 int get_dial_hw_position(int dial)
89 {
90
91 return _get_dial_hw_position(dial)&~3;
92 }
93
94 extern long dial_positions[4];
95 extern long jog_hw_pos;
96 int get_jogdial_counter() {
97 int p;
98 p = get_dial_hw_position(5);
99
100
101
102
103
104
105
106 return p;
107 }
108 long get_jogdial_direction(void) {
109 static int new_jogdial=0, old_jogdial=0 ;
110
111 old_jogdial=new_jogdial;
112 new_jogdial=get_jogdial_counter();
113
114
115 if (old_jogdial>new_jogdial) return JOGDIAL_RIGHT;
116 else if (old_jogdial<new_jogdial) return JOGDIAL_LEFT;
117 else return 0;
118 }
119 int handle_jogdial() {
120
121
122 if (jogdial_stopped) {
123
124 dial_positions[0] = dial_positions[2] = get_jogdial_counter();
125
126 return 0;
127 }
128 return 1;
129 }
130
131 void jogdial_control(int c) {
132 jogdial_stopped = c;
133 }
134
135 void my_kbd_read_keys() {
136 kbd_update_key_state();
137 kbd_update_physw_bits();
138 }
139
140 void kbd_fetch_data(long *dst)
141 {
142 _GetKbdState(dst);
143 _kbd_read_keys_r2(dst);
144
145
146
147 }