forked from 400plus/400plus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshortcuts.c
410 lines (341 loc) · 8.37 KB
/
shortcuts.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
#include <string.h>
#include "firmware.h"
#include "main.h"
#include "macros.h"
#include "autoiso.h"
#include "display.h"
#include "persist.h"
#include "settings.h"
#include "scripts.h"
#include "utils.h"
#include "intercom.h"
#include "shortcuts.h"
const char *label_iso = SHORTCUT_LABEL_ISO;
const char *label_mlu = SHORTCUT_LABEL_MLU;
const char *label_aeb = SHORTCUT_LABEL_AEB;
const char *label_flash = SHORTCUT_LABEL_FLASH;
const char *label_display = SHORTCUT_LABEL_DISPLAY;
void repeat_last_script (void);
void shortcut_start(shortcut_t action);
void shortcut_iso_toggle (void);
void shortcut_aeb_toggle (void);
void shortcut_iso_set (iso_t iso);
void shortcut_mlu_toggle (void);
void shortcut_efl_toggle (void);
void shortcut_efl_set (ec_t value);
void shortcut_f2c_toggle (void);
void shortcut_aeb_set (ec_t value);
void shortcut_disp_set (int brightness);
void shortcut_info_iso (void);
void shortcut_info_mlu (void);
void shortcut_info_aeb (void);
void shortcut_info_flash (void);
void shortcut_info_display (void);
void shortcut_info (const char *label);
void shortcut_info_str(const char *label, const char *value);
void shortcut_info_int(const char *label, const int value);
void shortcut_info_ec (const char *label, const ec_t value);
void shortcut_info_end(void);
void shortcut_jump() {
shortcut_start(settings.shortcut_jump);
}
void shortcut_trash() {
shortcut_start(settings.shortcut_trash);
}
void shortcut_disp() {
if (settings.button_disp) {
if (FLAG_GUI_MODE == GUIMODE_OFF) {
press_button(IC_BUTTON_DISP);
} else {
status.shortcut_running = SHORTCUT_DISPLAY;
shortcut_info_display();
}
} else {
press_button(IC_BUTTON_DISP);
}
}
void shortcut_start(shortcut_t action) {
char *msg = NULL;
status.shortcut_running = action;
switch (action) {
case SHORTCUT_ISO:
shortcut_info_iso();
break;
case SHORTCUT_SCRIPT:
repeat_last_script();
break;
case SHORTCUT_MLU:
shortcut_info_mlu();
break;
case SHORTCUT_AEB:
shortcut_info_aeb();
break;
case SHORTCUT_HACK_MENU:
menu_main_start();
break;
case SHORTCUT_FLASH:
shortcut_info_flash();
break;
case SHORTCUT_DISPLAY:
shortcut_info_display();
break;
#ifdef DEV_BTN_ACTION
case SHORTCUT_DEV_BTN:
dev_btn_action();
break;
#endif
default:
break;
}
if (msg) {
dialog_item_set_str(hMainDialog, 0x26, msg);
display_refresh();
}
}
void shortcut_stop() {
status.shortcut_running = SHORTCUT_NONE;
}
void shortcut_event_disp() {
press_button(IC_BUTTON_DISP);
enqueue_action(beep);
shortcut_event_end();
}
void shortcut_event_end() {
switch (status.shortcut_running) {
case SHORTCUT_AEB:
enqueue_action(persist_write);
break;
default:
break;
}
status.shortcut_running = SHORTCUT_NONE;
shortcut_info_end();
}
void shortcut_event_av(void) {
switch (status.shortcut_running) {
case SHORTCUT_FLASH:
shortcut_f2c_toggle();
break;
default:
break;
}
}
void shortcut_event_set(void) {
switch (status.shortcut_running) {
case SHORTCUT_ISO:
shortcut_iso_toggle();
break;
case SHORTCUT_MLU:
shortcut_mlu_toggle();
break;
case SHORTCUT_AEB:
shortcut_aeb_toggle();
break;
case SHORTCUT_FLASH:
shortcut_efl_toggle();
break;
case SHORTCUT_DISPLAY:
enqueue_action(beep);
shortcut_event_end();
break;
default:
break;
}
}
void shortcut_event_up(void) {
switch (status.shortcut_running) {
case SHORTCUT_ISO:
shortcut_iso_set(iso_next(DPData.iso));
break;
case SHORTCUT_AEB:
shortcut_aeb_set(MIN((EV_TRUNC(DPData.ae_bkt) + EV_CODE(1, 0)), EC_MAX));
break;
case SHORTCUT_FLASH:
shortcut_efl_set(MIN((EV_TRUNC(DPData.efcomp) + EV_CODE(1, 0)), EC_MAX));
break;
case SHORTCUT_DISPLAY:
shortcut_disp_set(7);
break;
default:
break;
}
}
void shortcut_event_down(void) {
switch (status.shortcut_running) {
case SHORTCUT_ISO:
shortcut_iso_set(iso_prev(DPData.iso));
break;
case SHORTCUT_AEB:
shortcut_aeb_set(MAX((EV_TRUNC(DPData.ae_bkt) - EV_CODE(1, 0)), EC_ZERO));
break;
case SHORTCUT_FLASH:
shortcut_efl_set(MAX((EV_TRUNC(DPData.efcomp) - EV_CODE(1, 0)), EC_MIN));
break;
case SHORTCUT_DISPLAY:
shortcut_disp_set(1);
break;
default:
break;
}
}
void shortcut_event_right(void) {
switch (status.shortcut_running) {
case SHORTCUT_ISO:
shortcut_iso_set(iso_inc(DPData.iso));
break;
case SHORTCUT_AEB:
shortcut_aeb_set(ec_inc(DPData.ae_bkt, FALSE));
break;
case SHORTCUT_FLASH:
shortcut_efl_set(ec_inc(DPData.efcomp, FALSE));
break;
case SHORTCUT_DISPLAY:
shortcut_disp_set(MIN(DPData.lcd_brightness + 1, 7));
break;
default:
break;
}
}
void shortcut_event_left(void) {
switch (status.shortcut_running) {
case SHORTCUT_ISO:
shortcut_iso_set(iso_dec(DPData.iso));
break;
case SHORTCUT_AEB:
shortcut_aeb_set(MAX(ec_dec(DPData.ae_bkt, FALSE), EV_ZERO));
break;
case SHORTCUT_FLASH:
shortcut_efl_set(ec_dec(DPData.efcomp, FALSE));
break;
case SHORTCUT_DISPLAY:
shortcut_disp_set(MAX(DPData.lcd_brightness - 1, 1));
break;
default:
break;
}
}
void shortcut_iso_toggle() {
settings.autoiso_enable = ! settings.autoiso_enable;
enqueue_action(settings_write);
shortcut_info_iso();
}
void shortcut_aeb_toggle() {
shortcut_aeb_set(DPData.ae_bkt ? EC_ZERO : persist.last_aeb);
}
void shortcut_iso_set(iso_t iso) {
if (settings.autoiso_enable) {
settings.autoiso_enable = FALSE;
enqueue_action(settings_write);
enqueue_action(beep);
}
send_to_intercom(IC_SET_ISO, iso);
shortcut_info_iso();
}
void shortcut_mlu_toggle() {
send_to_intercom(IC_SET_CF_MIRROR_UP_LOCK, 1 - DPData.cf_mirror_up_lock);
shortcut_info_mlu();
}
void shortcut_efl_toggle() {
send_to_intercom(IC_SET_CF_EMIT_FLASH, 1 - DPData.cf_emit_flash);
shortcut_info_flash();
}
void shortcut_efl_set(ec_t value) {
send_to_intercom(IC_SET_EFCOMP, value);
shortcut_info_flash();
}
void shortcut_f2c_toggle(void) {
if (DPData.cf_emit_flash)
send_to_intercom(IC_SET_CF_FLASH_SYNC_REAR, 1 - DPData.cf_flash_sync_rear);
shortcut_info_flash();
}
void shortcut_aeb_set(ec_t value) {
send_to_intercom(IC_SET_AE_BKT, value);
persist.aeb = value;
if (persist.aeb)
persist.last_aeb = persist.aeb;
shortcut_info_aeb();
}
void shortcut_disp_set(int brightness) {
send_to_intercom(IC_SET_LCD_BRIGHTNESS, brightness);
shortcut_info_display();
}
#ifdef DEV_BTN_ACTION
void dev_btn_action() {
// quick shortcut for developers to test stuff
beep();
ptp_dump_info();
}
#endif
void repeat_last_script(void) {
switch (persist.last_script) {
case SCRIPT_EXT_AEB:
script_ext_aeb();
break;
case SCRIPT_EFL_AEB:
script_efl_aeb();
break;
case SCRIPT_ISO_AEB:
script_iso_aeb();
break;
case SCRIPT_INTERVAL:
script_interval();
break;
case SCRIPT_WAVE:
script_wave();
break;
case SCRIPT_TIMER:
script_self_timer();
break;
default:
break;
}
}
void shortcut_info_iso() {
char buffer[8] = "AUTO";
if (!settings.autoiso_enable)
iso_print(buffer, DPData.iso);
shortcut_info_str(label_iso, buffer);
}
void shortcut_info_mlu() {
shortcut_info_str(label_mlu, DPData.cf_mirror_up_lock ? " On" : " Off");
}
void shortcut_info_aeb() {
shortcut_info_ec(label_aeb, DPData.ae_bkt);
}
void shortcut_info_flash() {
char buffer[8] = "";
sprintf(buffer, "%s", DPData.cf_emit_flash ? (DPData.cf_flash_sync_rear ? "2nd" : "On" ) : "Off");
shortcut_info_str(label_flash, buffer);
}
void shortcut_info_display() {
shortcut_info_int(label_display, DPData.lcd_brightness);
}
void shortcut_info(const char *label) {
dialog_item_set_label(hMainDialog, 0x08, label, 1 + strlen(label), 0x26);
display_refresh();
}
void shortcut_info_str(const char *label, const char *value) {
dialog_item_set_label(hMainDialog, 0x08, value, 1 + strlen(value), 0x04);
shortcut_info(label);
}
void shortcut_info_int(const char *label, const int value) {
char buffer[8];
sprintf(buffer, "%4i", value);
shortcut_info_str(label, buffer);
}
void shortcut_info_ec(const char *label, const ec_t value) {
int symbol = get_efcomp_data(value);
if (value != EC_ZERO)
dialog_item_set_label(hMainDialog, 0x12, &symbol, 0x04, 0x09);
shortcut_info(label);
}
void shortcut_info_end() {
char label[8], value[8];
const int symbol = 0xFC;
sprintf(label, "%i", DPData.avail_shot);
dialog_item_set_label(hMainDialog, 0x08, label, 1 + strlen(label), 0x26);
iso_print(value, DPData.iso);
dialog_item_set_label(hMainDialog, 0x08, value, 1 + strlen(value), 0x04);
dialog_item_set_label(hMainDialog, 0x12, &symbol, 0x04, 0x09);
display_refresh();
}