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