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