forked from 400plus/400plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.c
317 lines (255 loc) · 6.96 KB
/
actions.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
#include <vxworks.h>
#include <dirent.h>
#include "macros.h"
#include "main.h"
#include "firmware.h"
#include "bmp.h"
#include "cmodes.h"
#include "debug.h"
#include "display.h"
#include "exposure.h"
#include "languages.h"
#include "memspy.h"
#include "menu_main.h"
#include "persist.h"
#include "scripts.h"
#include "settings.h"
#include "utils.h"
#include "ptp.h"
#include "actions.h"
void set_intermediate_iso(void);
void repeat_last_script (void);
void button_action(button_action_t action);
#ifdef DEV_BTN_ACTION
void dev_btn_action() {
// quick shortcut for developers to test stuff
beep();
ptp_dump_info();
}
#endif
void start_up() {
#if 0
debug_log("AF: Creating directories (%#x)", GetErrorNum());
if (FIO_CreateDirectory(PathBase))
printf_log(8,8,"Error[%#x]: CreateDir(" PathBase ")", GetErrorNum());
if (FIO_CreateDirectory(PathLogs))
printf_log(8,8,"Error[%#x]: CreateDir(" PathLogs ")", GetErrorNum());
if (FIO_CreateDirectory(PathLang))
printf_log(8,8,"Error[%#x]: CreateDir(" PathLang ")", GetErrorNum());
if (FIO_CreateDirectory(PathPresets))
printf_log(8,8,"Error[%#x]: CreateDir(" PathPresets ")", GetErrorNum());
#endif
// Recover persisting information
persist_read();
// Read settings from file
settings_read();
// If configured, start debug mode
if (settings.debug_on_poweron)
start_debug_mode();
// If configured, restore AEB
if (settings.persist_aeb)
send_to_intercom(IC_SET_AE_BKT, persist.aeb);
// Enable IR remote
// i'm not sure where to call this? perhaps this isn't the right place.
if (settings.remote_enable)
remote_on();
// Enable extended ISOs
// Enable (hidden) CFn.8 for ISO H
send_to_intercom(IC_SET_CF_EXTEND_ISO, 1);
// Enable realtime ISO change
send_to_intercom(IC_SET_REALTIME_ISO_0, 0);
send_to_intercom(IC_SET_REALTIME_ISO_1, 0);
// turn off the blue led after it was lighten by our hack_task_MainCtrl()
eventproc_EdLedOff();
// Set current language
enqueue_action(lang_pack_init);
// Read custom modes configuration from file
enqueue_action(cmodes_read);
// And optionally apply a custom mode
enqueue_action(cmode_recall);
#ifdef MEMSPY
debug_log("starting memspy task");
CreateTask("memspy", 0x1e, 0x1000, memspy_task, 0);
#endif
#if 0
debug_log("=== DUMPING DDD ===");
printf_DDD_log( (void*)(int)(0x00007604+0x38) );
debug_log("maindlg @ 0x%08X, handler @ 0x%08X", hMainDialog, hMainDialog->event_handler);
debug_log("dumping");
long *addr = (long*) 0x7F0000;
int file = FIO_OpenFile("A:/dump.bin", O_CREAT | O_WRONLY , 644);
if (file != -1) {
FIO_WriteFile(file, addr, 0xFFFF);
FIO_CloseFile(file);
beep();
}
#endif
#ifdef DEBUG
DIR *dirp;
struct dirent *dp;
if ((dirp = opendir("A:\\")) == NULL) {
printf_log(8,8, "[400plus-DIR]: opendir error");
return;
}
do {
if ((dp = readdir(dirp)) != NULL)
printf_log(8,8, "[400plus-DIR]: found '%s'", dp->d_name);
} while (dp != NULL);
closedir(dirp);
#endif
}
void set_metering_spot() {
press_button(IC_BUTTON_SET);
send_to_intercom(IC_SET_METERING, METERING_MODE_SPOT);
print_icu_info();
beep();
}
void set_whitebalance_colortemp() {
press_button(IC_BUTTON_SET);
send_to_intercom(IC_SET_WB, WB_MODE_COLORTEMP);
print_icu_info();
beep();
}
void set_intermediate_iso() {
if (AE_IS_CREATIVE(DPData.ae)) {
send_to_intercom(IC_SET_ISO, iso_roll(DPData.iso));
// No need to set a proper value here,
// we hacked this function at hack_item_set_label_int()
dialog_set_property_str(hMainDialog, 0x04, "0000");
print_icu_info();
display_refresh();
}
}
void drivemode_set() {
if (settings.remote_enable) {
printf_log(8,8, "[400Plus-DRIVE]: re-setting IR remote enable");
remote_on();
}
if (settings.remote_delay) {
printf_log(8,8, "[400Plus-DRIVE]: re-setting IR remote delay");
remote_delay(TRUE);
}
}
void toggle_img_format() {
static int first_call = TRUE;
if (!first_call && AE_IS_AUTO(DPData.ae)) {
switch (DPData.img_format) {
case IMG_FORMAT_JPG:
send_to_intercom(IC_SET_IMG_FORMAT, IMG_FORMAT_RAW);
break;
case IMG_FORMAT_RAW:
send_to_intercom(IC_SET_IMG_FORMAT, IMG_FORMAT_JPG | IMG_FORMAT_RAW);
break;
case IMG_FORMAT_JPG | IMG_FORMAT_RAW:
send_to_intercom(IC_SET_IMG_FORMAT, IMG_FORMAT_JPG);
break;
}
send_to_intercom(IC_SET_IMG_QUALITY, IMG_QUALITY_HIGH);
send_to_intercom(IC_SET_IMG_SIZE, IMG_SIZE_L);
}
first_call = FALSE;
}
void toggle_CfMLU() {
char message[LP_MAX_WORD];
send_to_intercom(IC_SET_CF_MIRROR_UP_LOCK, !DPData.cf_mirror_up_lock);
sprintf(message, "%s: %s", LP_WORD(L_A_MIRROR_LOCKUP), DPData.cf_mirror_up_lock ? LP_WORD(L_A_YES) : LP_WORD(L_A_NO));
display_message_set(message, ACTION_MSG_TIMEOUT);
}
void toggle_CfEmitFlash(void) {
char message[LP_MAX_WORD];
send_to_intercom(IC_SET_CF_EMIT_FLASH, !DPData.cf_emit_flash);
sprintf(message, "%s: %s",LP_WORD(L_A_FLASH),(DPData.cf_emit_flash ? LP_WORD(L_A_NO) : LP_WORD(L_A_YES)));
display_message_set(message, ACTION_MSG_TIMEOUT);
}
void toggle_CfFlashSyncRear() {
send_to_intercom(IC_SET_CF_FLASH_SYNC_REAR, !DPData.cf_flash_sync_rear);
}
void toggle_AEB() {
int aeb;
static int last_toggle = 0;
if (timestamp() - last_toggle < ACTION_AEB_TIMEOUT)
// Button was pressed recently: roll over all range
aeb = (EV_TRUNC(DPData.ae_bkt) + EV_CODE(1, 0)) % EV_CODE(6, 0);
else if (DPData.ae_bkt)
// Button was pressed long ago, and AEB is on: switch it off
aeb = EC_ZERO;
else
// Button was pressed long ago, and AEB is off: switch it on
aeb = persist.last_aeb;
send_to_intercom(IC_SET_AE_BKT, aeb);
persist.aeb = aeb;
if (persist.aeb)
persist.last_aeb = persist.aeb;
enqueue_action(persist_write);
last_toggle = timestamp();
}
void restore_iso() {
send_to_intercom(IC_SET_ISO, EV_TRUNC(DPData.iso));
}
void restore_wb() {
if (DPData.wb == WB_MODE_COLORTEMP)
send_to_intercom(IC_SET_WB, WB_MODE_AUTO);
}
void restore_metering() {
if (DPData.metering == METERING_MODE_SPOT)
send_to_intercom(IC_SET_METERING, METERING_MODE_EVAL);
}
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 button_jump_action() {
button_action(settings.button_jump);
}
void button_trash_action() {
button_action(settings.button_trash);
}
void button_action(button_action_t action) {
switch (action) {
case BUTTON_ACTION_ISO:
set_intermediate_iso();
break;
case BUTTON_ACTION_SCRIPT:
repeat_last_script();
break;
case BUTTON_ACTION_MLU:
toggle_CfMLU();
break;
case BUTTON_ACTION_AEB:
toggle_AEB();
break;
case BUTTON_ACTION_HACK_MENU:
menu_main_start();
break;
case BUTTON_ACTION_TOGGLE_FLASH:
toggle_CfEmitFlash();
break;
#ifdef DEV_BTN_ACTION
case BUTTON_ACTION_DEV_BTN:
dev_btn_action();
break;
#endif
default:
break;
}
}