diff options
Diffstat (limited to 'tmk_core/common/action_util.c')
-rw-r--r-- | tmk_core/common/action_util.c | 113 |
1 files changed, 101 insertions, 12 deletions
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index 148162a51..afd4ae8b2 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c | |||
@@ -67,12 +67,12 @@ bool has_oneshot_mods_timed_out(void) { | |||
67 | 67 | ||
68 | /* oneshot layer */ | 68 | /* oneshot layer */ |
69 | #ifndef NO_ACTION_ONESHOT | 69 | #ifndef NO_ACTION_ONESHOT |
70 | /* oneshot_layer_data bits | 70 | /** \brief oneshot_layer_data bits |
71 | * LLLL LSSS | 71 | * LLLL LSSS |
72 | * where: | 72 | * where: |
73 | * L => are layer bits | 73 | * L => are layer bits |
74 | * S => oneshot state bits | 74 | * S => oneshot state bits |
75 | */ | 75 | */ |
76 | static int8_t oneshot_layer_data = 0; | 76 | static int8_t oneshot_layer_data = 0; |
77 | 77 | ||
78 | inline uint8_t get_oneshot_layer(void) { return oneshot_layer_data >> 3; } | 78 | inline uint8_t get_oneshot_layer(void) { return oneshot_layer_data >> 3; } |
@@ -86,7 +86,10 @@ inline bool has_oneshot_layer_timed_out() { | |||
86 | } | 86 | } |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | /* Oneshot layer */ | 89 | /** \brief Set oneshot layer |
90 | * | ||
91 | * FIXME: needs doc | ||
92 | */ | ||
90 | void set_oneshot_layer(uint8_t layer, uint8_t state) | 93 | void set_oneshot_layer(uint8_t layer, uint8_t state) |
91 | { | 94 | { |
92 | oneshot_layer_data = layer << 3 | state; | 95 | oneshot_layer_data = layer << 3 | state; |
@@ -95,12 +98,20 @@ void set_oneshot_layer(uint8_t layer, uint8_t state) | |||
95 | oneshot_layer_time = timer_read(); | 98 | oneshot_layer_time = timer_read(); |
96 | #endif | 99 | #endif |
97 | } | 100 | } |
101 | /** \brief Reset oneshot layer | ||
102 | * | ||
103 | * FIXME: needs doc | ||
104 | */ | ||
98 | void reset_oneshot_layer(void) { | 105 | void reset_oneshot_layer(void) { |
99 | oneshot_layer_data = 0; | 106 | oneshot_layer_data = 0; |
100 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 107 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
101 | oneshot_layer_time = 0; | 108 | oneshot_layer_time = 0; |
102 | #endif | 109 | #endif |
103 | } | 110 | } |
111 | /** \brief Clear oneshot layer | ||
112 | * | ||
113 | * FIXME: needs doc | ||
114 | */ | ||
104 | void clear_oneshot_layer_state(oneshot_fullfillment_t state) | 115 | void clear_oneshot_layer_state(oneshot_fullfillment_t state) |
105 | { | 116 | { |
106 | uint8_t start_state = oneshot_layer_data; | 117 | uint8_t start_state = oneshot_layer_data; |
@@ -112,12 +123,20 @@ void clear_oneshot_layer_state(oneshot_fullfillment_t state) | |||
112 | #endif | 123 | #endif |
113 | } | 124 | } |
114 | } | 125 | } |
126 | /** \brief Is oneshot layer active | ||
127 | * | ||
128 | * FIXME: needs doc | ||
129 | */ | ||
115 | bool is_oneshot_layer_active(void) | 130 | bool is_oneshot_layer_active(void) |
116 | { | 131 | { |
117 | return get_oneshot_layer_state(); | 132 | return get_oneshot_layer_state(); |
118 | } | 133 | } |
119 | #endif | 134 | #endif |
120 | 135 | ||
136 | /** \brief Send keyboard report | ||
137 | * | ||
138 | * FIXME: needs doc | ||
139 | */ | ||
121 | void send_keyboard_report(void) { | 140 | void send_keyboard_report(void) { |
122 | keyboard_report->mods = real_mods; | 141 | keyboard_report->mods = real_mods; |
123 | keyboard_report->mods |= weak_mods; | 142 | keyboard_report->mods |= weak_mods; |
@@ -140,29 +159,90 @@ void send_keyboard_report(void) { | |||
140 | host_keyboard_send(keyboard_report); | 159 | host_keyboard_send(keyboard_report); |
141 | } | 160 | } |
142 | 161 | ||
143 | /* modifier */ | 162 | /** \brief Get mods |
163 | * | ||
164 | * FIXME: needs doc | ||
165 | */ | ||
144 | uint8_t get_mods(void) { return real_mods; } | 166 | uint8_t get_mods(void) { return real_mods; } |
167 | /** \brief add mods | ||
168 | * | ||
169 | * FIXME: needs doc | ||
170 | */ | ||
145 | void add_mods(uint8_t mods) { real_mods |= mods; } | 171 | void add_mods(uint8_t mods) { real_mods |= mods; } |
172 | /** \brief del mods | ||
173 | * | ||
174 | * FIXME: needs doc | ||
175 | */ | ||
146 | void del_mods(uint8_t mods) { real_mods &= ~mods; } | 176 | void del_mods(uint8_t mods) { real_mods &= ~mods; } |
177 | /** \brief set mods | ||
178 | * | ||
179 | * FIXME: needs doc | ||
180 | */ | ||
147 | void set_mods(uint8_t mods) { real_mods = mods; } | 181 | void set_mods(uint8_t mods) { real_mods = mods; } |
182 | /** \brief clear mods | ||
183 | * | ||
184 | * FIXME: needs doc | ||
185 | */ | ||
148 | void clear_mods(void) { real_mods = 0; } | 186 | void clear_mods(void) { real_mods = 0; } |
149 | 187 | ||
150 | /* weak modifier */ | 188 | /** \brief get weak mods |
189 | * | ||
190 | * FIXME: needs doc | ||
191 | */ | ||
151 | uint8_t get_weak_mods(void) { return weak_mods; } | 192 | uint8_t get_weak_mods(void) { return weak_mods; } |
193 | /** \brief add weak mods | ||
194 | * | ||
195 | * FIXME: needs doc | ||
196 | */ | ||
152 | void add_weak_mods(uint8_t mods) { weak_mods |= mods; } | 197 | void add_weak_mods(uint8_t mods) { weak_mods |= mods; } |
198 | /** \brief del weak mods | ||
199 | * | ||
200 | * FIXME: needs doc | ||
201 | */ | ||
153 | void del_weak_mods(uint8_t mods) { weak_mods &= ~mods; } | 202 | void del_weak_mods(uint8_t mods) { weak_mods &= ~mods; } |
203 | /** \brief set weak mods | ||
204 | * | ||
205 | * FIXME: needs doc | ||
206 | */ | ||
154 | void set_weak_mods(uint8_t mods) { weak_mods = mods; } | 207 | void set_weak_mods(uint8_t mods) { weak_mods = mods; } |
208 | /** \brief clear weak mods | ||
209 | * | ||
210 | * FIXME: needs doc | ||
211 | */ | ||
155 | void clear_weak_mods(void) { weak_mods = 0; } | 212 | void clear_weak_mods(void) { weak_mods = 0; } |
156 | 213 | ||
157 | /* macro modifier */ | 214 | /* macro modifier */ |
215 | /** \brief get macro mods | ||
216 | * | ||
217 | * FIXME: needs doc | ||
218 | */ | ||
158 | uint8_t get_macro_mods(void) { return macro_mods; } | 219 | uint8_t get_macro_mods(void) { return macro_mods; } |
220 | /** \brief add macro mods | ||
221 | * | ||
222 | * FIXME: needs doc | ||
223 | */ | ||
159 | void add_macro_mods(uint8_t mods) { macro_mods |= mods; } | 224 | void add_macro_mods(uint8_t mods) { macro_mods |= mods; } |
225 | /** \brief del macro mods | ||
226 | * | ||
227 | * FIXME: needs doc | ||
228 | */ | ||
160 | void del_macro_mods(uint8_t mods) { macro_mods &= ~mods; } | 229 | void del_macro_mods(uint8_t mods) { macro_mods &= ~mods; } |
230 | /** \brief set macro mods | ||
231 | * | ||
232 | * FIXME: needs doc | ||
233 | */ | ||
161 | void set_macro_mods(uint8_t mods) { macro_mods = mods; } | 234 | void set_macro_mods(uint8_t mods) { macro_mods = mods; } |
235 | /** \brief clear macro mods | ||
236 | * | ||
237 | * FIXME: needs doc | ||
238 | */ | ||
162 | void clear_macro_mods(void) { macro_mods = 0; } | 239 | void clear_macro_mods(void) { macro_mods = 0; } |
163 | 240 | ||
164 | /* Oneshot modifier */ | ||
165 | #ifndef NO_ACTION_ONESHOT | 241 | #ifndef NO_ACTION_ONESHOT |
242 | /** \brief set oneshot mods | ||
243 | * | ||
244 | * FIXME: needs doc | ||
245 | */ | ||
166 | void set_oneshot_mods(uint8_t mods) | 246 | void set_oneshot_mods(uint8_t mods) |
167 | { | 247 | { |
168 | oneshot_mods = mods; | 248 | oneshot_mods = mods; |
@@ -170,6 +250,10 @@ void set_oneshot_mods(uint8_t mods) | |||
170 | oneshot_time = timer_read(); | 250 | oneshot_time = timer_read(); |
171 | #endif | 251 | #endif |
172 | } | 252 | } |
253 | /** \brief clear oneshot mods | ||
254 | * | ||
255 | * FIXME: needs doc | ||
256 | */ | ||
173 | void clear_oneshot_mods(void) | 257 | void clear_oneshot_mods(void) |
174 | { | 258 | { |
175 | oneshot_mods = 0; | 259 | oneshot_mods = 0; |
@@ -177,14 +261,19 @@ void clear_oneshot_mods(void) | |||
177 | oneshot_time = 0; | 261 | oneshot_time = 0; |
178 | #endif | 262 | #endif |
179 | } | 263 | } |
264 | /** \brief get oneshot mods | ||
265 | * | ||
266 | * FIXME: needs doc | ||
267 | */ | ||
180 | uint8_t get_oneshot_mods(void) | 268 | uint8_t get_oneshot_mods(void) |
181 | { | 269 | { |
182 | return oneshot_mods; | 270 | return oneshot_mods; |
183 | } | 271 | } |
184 | #endif | 272 | #endif |
185 | 273 | ||
186 | /* | 274 | /** \brief inspect keyboard state |
187 | * inspect keyboard state | 275 | * |
276 | * FIXME: needs doc | ||
188 | */ | 277 | */ |
189 | uint8_t has_anymod(void) | 278 | uint8_t has_anymod(void) |
190 | { | 279 | { |