This source file includes following definitions.
- get_usb_bit
- wrap_kbd_p1_f
- mykbd_task
- get_dial_hw_position
- 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 KeyMap keymap[] = {
23
24 { 0, KEY_PLAYBACK ,0x00000002 },
25 { 0, KEY_SHOOT_FULL ,0x0000000c },
26 { 0, KEY_SHOOT_FULL_ONLY ,0x00000008 },
27 { 0, KEY_SHOOT_HALF ,0x00000004 },
28 { 0, KEY_VIDEO ,0x00000100 },
29 { 0, KEY_MENU ,0x00000200 },
30 { 0, KEY_DISPLAY ,0x00002000 },
31 { 0, KEY_UP ,0x00004000 },
32 { 0, KEY_DOWN ,0x00008000 },
33 { 0, KEY_RIGHT ,0x00010000 },
34 { 1, KEY_LEFT ,0x00000004 },
35 { 1, KEY_SET ,0x00000008 },
36
37 { 1, KEY_WIFI ,0x00000020 },
38 { 1, KEY_FRAMING_ASSIST ,0x00000010 },
39 { 2, KEY_ZOOM_IN ,0x00000002 },
40 { 2, KEY_ZOOM_IN ,0x00000004 },
41 { 2, KEY_ZOOM_OUT ,0x00000008 },
42 { 2, KEY_ZOOM_OUT ,0x00000010 },
43 { 0, 0, 0 }
44 };
45
46
47
48
49 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
50
51 asm volatile(
52 "push {r1-r7, lr}\n"
53 "movs r4, #0\n"
54 "bl my_kbd_read_keys\n"
55 "b _kbd_p1_f_cont\n"
56 );
57
58 return 0;
59 }
60
61
62 void __attribute__((noinline)) mykbd_task() {
63 extern void kbd_p2_f_my();
64 while (physw_run) {
65 _SleepTask(physw_sleep_delay);
66
67 if (wrap_kbd_p1_f() == 1) {
68 #ifdef CAM_HAS_JOGDIAL
69 kbd_p2_f_my();
70 #else
71 _kbd_p2_f();
72 #endif
73 }
74 }
75
76 _ExitTask();
77 }
78
79
80
81
82
83
84
85 #ifdef CAM_HAS_JOGDIAL
86 extern int _get_dial_hw_position(int dial);
87 #define DIAL_HW_REAR 4
88 int get_dial_hw_position(int dial)
89 {
90
91 return _get_dial_hw_position(dial)&~3;
92 }
93 int jogdial_stopped=0;
94
95 extern long dial_positions[2];
96
97 long get_jogdial_direction(void) {
98 static int new_jogdial=0, old_jogdial=0;
99
100 old_jogdial=new_jogdial;
101 new_jogdial=get_dial_hw_position(DIAL_HW_REAR);
102
103
104
105
106 if (old_jogdial>new_jogdial) return JOGDIAL_LEFT;
107 else if (old_jogdial<new_jogdial) return JOGDIAL_RIGHT;
108 else return 0;
109 }
110
111 int handle_jogdial() {
112
113 if (jogdial_stopped) {
114
115 dial_positions[0] = dial_positions[1] = get_dial_hw_position(DIAL_HW_REAR);
116 return 0;
117 }
118 return 1;
119 }
120
121 void jogdial_control(int c) {
122 jogdial_stopped = c;
123 }
124 #endif
125
126 void my_kbd_read_keys() {
127 kbd_update_key_state();
128 kbd_update_physw_bits();
129 }
130
131 void kbd_fetch_data(long *dst)
132 {
133 _GetKbdState(dst);
134 _kbd_read_keys_r2(dst);
135 }