This source file includes following definitions.
- script_shoot_hooks_reset
- script_shoot_hook_set
- script_shoot_hook_run
- script_shoot_hook_ready
- script_shoot_hook_continue
- script_shoot_hook_count
1 #include "stdlib.h"
2 #include "string.h"
3 #include "ctype.h"
4 #include "script_shoot_hook.h"
5 #include "script_api.h"
6
7 typedef struct {
8 int count;
9 int timeout;
10 int active;
11 } script_shoot_hook_t;
12
13 const char* shoot_hook_names[SCRIPT_NUM_SHOOT_HOOKS] = {
14 "hook_preshoot",
15 "hook_shoot",
16 "hook_raw",
17 };
18
19 static script_shoot_hook_t hooks[SCRIPT_NUM_SHOOT_HOOKS];
20
21
22 void script_shoot_hooks_reset(void)
23 {
24 memset(hooks,0,sizeof(hooks));
25 }
26
27
28 void script_shoot_hook_set(int hook,int timeout) {
29 hooks[hook].timeout = timeout;
30 }
31
32 void rawop_update_hook_status(int active);
33
34
35 void script_shoot_hook_run(int hook)
36 {
37 int timeleft = hooks[hook].timeout;
38 hooks[hook].count++;
39
40 if(timeleft > 0) {
41
42
43 if(hook == SCRIPT_SHOOT_HOOK_RAW) {
44 rawop_update_hook_status(1);
45 }
46 hooks[hook].active = 1;
47 while(timeleft > 0 && hooks[hook].active) {
48 msleep(10);
49 timeleft -= 10;
50 }
51 if(hook == SCRIPT_SHOOT_HOOK_RAW) {
52 rawop_update_hook_status(0);
53 }
54 hooks[hook].active = 0;
55 }
56
57 }
58
59
60 int script_shoot_hook_ready(int hook)
61 {
62 return hooks[hook].active;
63 }
64
65
66 void script_shoot_hook_continue(int hook)
67 {
68 hooks[hook].active = 0;
69 }
70
71
72 int script_shoot_hook_count(int hook)
73 {
74 return hooks[hook].count;
75 }
76