This source file includes following definitions.
- kbd_get_autoclicked_key
- kbd_is_blocked
- enter_alt
- exit_alt
- kbd_process
1 #include "camera.h"
2 #include "conf.h"
3 #include "keyboard.h"
4 #include "action_stack.h"
5 #include "lang.h"
6 #include "gui.h"
7 #include "gui_lang.h"
8 #include "console.h"
9 #include "usb_remote.h"
10 #include "clock.h"
11 #include "debug_led.h"
12
13
14
15
16 static long last_kbd_key = 0;
17 static long last_kbd_time = 0;
18 static long press_count = 0;
19
20 long kbd_get_autoclicked_key()
21 {
22 register long key, t;
23
24 key=kbd_get_clicked_key();
25 if (key && (key != last_kbd_key))
26 {
27 last_kbd_key = key;
28 press_count = 0;
29 last_kbd_time = get_tick_count();
30 return key;
31 }
32 else
33 {
34 if (last_kbd_key && kbd_is_key_pressed(last_kbd_key))
35 {
36 t = get_tick_count();
37 if (t-last_kbd_time > ((press_count) ? KBD_REPEAT_DELAY : KBD_INITIAL_DELAY))
38 {
39 ++press_count;
40 last_kbd_time = t;
41 return last_kbd_key;
42 }
43 else
44 {
45 return 0;
46 }
47 }
48 else
49 {
50 last_kbd_key = 0;
51 return 0;
52 }
53 }
54 }
55
56
57
58 int kbd_blocked;
59
60 int kbd_is_blocked()
61 {
62 return kbd_blocked;
63 }
64
65 void enter_alt(int script_mode)
66 {
67 clear_usb_power();
68 kbd_blocked = 1;
69 gui_set_alt_mode_state(script_mode ? ALT_MODE_ENTER_SCRIPT : ALT_MODE_ENTER);
70 }
71
72 void exit_alt()
73 {
74 kbd_blocked = 0;
75 gui_set_alt_mode_state(ALT_MODE_LEAVE);
76 }
77
78
79
80
81 long kbd_process()
82 {
83 static int key_pressed;
84
85 if( usb_HPtimer_handle==0) usb_remote_key();
86
87 if (camera_info.perf.md_af_tuning)
88 {
89 switch (camera_info.perf.md_af_on_flag)
90 {
91 case 1:
92 if (get_tick_count() >= (int)(camera_info.perf.md_detect_tick + camera_info.perf.md_af_on_delay))
93 {
94 camera_info.perf.md_af_on_flag = 2;
95 camera_set_led(camera_info.cam_af_led,1,200);
96 }
97 break;
98 case 2:
99 if (get_tick_count() >= (int)(camera_info.perf.md_detect_tick + camera_info.perf.md_af_on_delay + camera_info.perf.md_af_on_time))
100 {
101 camera_info.perf.md_af_on_flag = 0;
102 camera_set_led(camera_info.cam_af_led,0,0);
103 }
104 break;
105 }
106 }
107
108
109 script_check_terminate();
110
111
112 if (kbd_get_pressed_key() == 0)
113 last_kbd_key = 0;
114
115
116 if (kbd_get_clicked_key())
117 {
118 camera_info.state.kbd_last_clicked = kbd_get_clicked_key();
119 camera_info.state.kbd_last_clicked_time = get_tick_count();
120 }
121
122
123 camera_info.state.is_shutter_half_press = kbd_is_key_pressed(KEY_SHOOT_HALF);
124
125
126 extern void shooting_update_state(void);
127 shooting_update_state();
128
129
130
131
132
133
134 if ( key_pressed && !usb_remote_active )
135 {
136 if (kbd_is_key_pressed(conf.alt_mode_button)
137 || ((key_pressed >= CAM_EMUL_KEYPRESS_DELAY)
138 && (key_pressed < CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)))
139 {
140 if (key_pressed <= CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)
141 key_pressed++;
142 if (key_pressed == CAM_EMUL_KEYPRESS_DELAY)
143 kbd_key_press(conf.alt_mode_button);
144 else if (key_pressed == CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)
145 kbd_key_release(conf.alt_mode_button);
146 return 1;
147 }
148 else if (kbd_get_pressed_key() == 0)
149 {
150 if (key_pressed < CAM_EMUL_KEYPRESS_DELAY)
151 {
152 if (!kbd_blocked)
153 {
154
155 if(conf.script_startup==SCRIPT_AUTOSTART_ALT) script_run_on_alt_flag = 1;
156 enter_alt(camera_info.state.state_kbd_script_run);
157 }
158 else
159 exit_alt();
160 }
161 key_pressed = 0;
162 return 1;
163 }
164 return 1;
165 }
166
167
168 if (camera_info.state.is_shutter_half_press && kbd_is_key_pressed(conf.alt_mode_button))
169 return 0;
170
171 if (kbd_is_key_pressed(conf.alt_mode_button))
172 {
173 key_pressed = 1;
174 kbd_key_release_all();
175 return 1;
176 }
177
178 #ifdef CAM_TOUCHSCREEN_UI
179 extern int ts_process_touch();
180 if (ts_process_touch())
181 {
182 gui_set_need_restore();
183 }
184 #endif
185
186
187
188 if ( !kbd_blocked || usb_remote_active )
189 {
190 kbd_blocked = handle_usb_remote();
191 }
192
193 if (gui_kbd_process())
194 return 1;
195
196 action_stack_process_all();
197
198
199
200 extern void start_ptp_script();
201 start_ptp_script();
202
203 return kbd_blocked;
204 }