diff options
-rw-r--r-- | docs/feature_haptic_feedback.md | 26 | ||||
-rw-r--r-- | drivers/haptic/haptic.c | 71 |
2 files changed, 94 insertions, 3 deletions
diff --git a/docs/feature_haptic_feedback.md b/docs/feature_haptic_feedback.md index a092e784c..469c9c798 100644 --- a/docs/feature_haptic_feedback.md +++ b/docs/feature_haptic_feedback.md | |||
@@ -162,4 +162,28 @@ This will set what sequence HPT_RST will set as the active mode. If not defined, | |||
162 | 162 | ||
163 | ### DRV2605L Continuous Haptic Mode | 163 | ### DRV2605L Continuous Haptic Mode |
164 | 164 | ||
165 | This mode sets continuous haptic feedback with the option to increase or decrease strength. | 165 | This mode sets continuous haptic feedback with the option to increase or decrease strength. |
166 | |||
167 | ## Haptic Key Exclusion | ||
168 | The Haptic Exclusion is implemented as `__attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t *record)` in haptic.c. This allows a re-definition at the required level with the specific requirement / exclusion. | ||
169 | |||
170 | ### NO_HAPTIC_MOD | ||
171 | With the entry of `#define NO_HAPTIC_MOD` in config.h, modifiers from Left Control to Right GUI will not trigger a feedback. This also includes modifiers in a Mod Tap configuration. | ||
172 | |||
173 | ### NO_HAPTIC_FN | ||
174 | With the entry of `#define NO_HAPTIC_FN` in config.h, layer keys will not rigger a feedback. | ||
175 | |||
176 | ### NO_HAPTIC_ALPHA | ||
177 | With the entry of `#define NO_HAPTIC_ALPHA` in config.h, none of the alpha keys (A ... Z) will trigger a feedback. | ||
178 | |||
179 | ### NO_HAPTIC_PUNCTUATION | ||
180 | With the entry of `#define NO_HAPTIC_PUNCTUATION` in config.h, none of the following keys will trigger a feedback: Enter, ESC, Backspace, Space, Minus, Equal, Left Bracket, Right Bracket, Backslash, Non-US Hash, Semicolon, Quote, Grave, Comma, Slash, Dot, Non-US Backslash. | ||
181 | |||
182 | ### NO_HAPTIC_LOCKKEYS | ||
183 | With the entry of `#define NO_HAPTIC_LOCKKEYS` in config.h, none of the following keys will trigger a feedback: Caps Lock, Scroll Lock, Num Lock. | ||
184 | |||
185 | ### NO_HAPTIC_NAV | ||
186 | With the entry of `#define NO_HAPTIC_NAV` in config.h, none of the following keys will trigger a feedback: Print Screen, Pause, Insert, Delete, Page Down, Page Up, Left Arrow, Up Arrow, Right Arrow, Down Arrow, End, Home. | ||
187 | |||
188 | ### NO_HAPTIC_NUMERIC | ||
189 | With the entry of `#define NO_HAPTIC_NUMERIC` in config.h, none of the following keys between 0 and 9 (KC_1 ... KC_0) will trigger a feedback. \ No newline at end of file | ||
diff --git a/drivers/haptic/haptic.c b/drivers/haptic/haptic.c index de3f40052..3fab1be1a 100644 --- a/drivers/haptic/haptic.c +++ b/drivers/haptic/haptic.c | |||
@@ -291,6 +291,73 @@ void haptic_play(void) { | |||
291 | #endif | 291 | #endif |
292 | } | 292 | } |
293 | 293 | ||
294 | __attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t *record) { | ||
295 | switch(keycode) { | ||
296 | # ifdef NO_HAPTIC_MOD | ||
297 | case QK_MOD_TAP ... QK_MOD_TAP_MAX: | ||
298 | if (record->tap.count == 0) return false; | ||
299 | break; | ||
300 | case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: | ||
301 | if (record->tap.count != TAPPING_TOGGLE) return false; | ||
302 | break; | ||
303 | case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: | ||
304 | if (record->tap.count == 0) return false; | ||
305 | break; | ||
306 | case KC_LCTRL ... KC_RGUI: | ||
307 | case QK_MOMENTARY ... QK_MOMENTARY_MAX: | ||
308 | # endif | ||
309 | # ifdef NO_HAPTIC_FN | ||
310 | case KC_FN0 ... KC_FN31: | ||
311 | # endif | ||
312 | # ifdef NO_HAPTIC_ALPHA | ||
313 | case KC_A ... KC_Z: | ||
314 | # endif | ||
315 | # ifdef NO_HAPTIC_PUNCTUATION | ||
316 | case KC_ENTER: | ||
317 | case KC_ESCAPE: | ||
318 | case KC_BSPACE: | ||
319 | case KC_SPACE: | ||
320 | case KC_MINUS: | ||
321 | case KC_EQUAL: | ||
322 | case KC_LBRACKET: | ||
323 | case KC_RBRACKET: | ||
324 | case KC_BSLASH: | ||
325 | case KC_NONUS_HASH: | ||
326 | case KC_SCOLON: | ||
327 | case KC_QUOTE: | ||
328 | case KC_GRAVE: | ||
329 | case KC_COMMA: | ||
330 | case KC_SLASH: | ||
331 | case KC_DOT: | ||
332 | case KC_NONUS_BSLASH: | ||
333 | # endif | ||
334 | # ifdef NO_HAPTIC_LOCKKEYS | ||
335 | case KC_CAPSLOCK: | ||
336 | case KC_SCROLLLOCK: | ||
337 | case KC_NUMLOCK: | ||
338 | # endif | ||
339 | # ifdef NO_HAPTIC_NAV | ||
340 | case KC_PSCREEN: | ||
341 | case KC_PAUSE: | ||
342 | case KC_INSERT: | ||
343 | case KC_DELETE: | ||
344 | case KC_PGDOWN: | ||
345 | case KC_PGUP: | ||
346 | case KC_LEFT: | ||
347 | case KC_UP: | ||
348 | case KC_RIGHT: | ||
349 | case KC_DOWN: | ||
350 | case KC_END: | ||
351 | case KC_HOME: | ||
352 | # endif | ||
353 | # ifdef NO_HAPTIC_NUMERIC | ||
354 | case KC_1 ... KC_0: | ||
355 | # endif | ||
356 | return false; | ||
357 | } | ||
358 | return true; | ||
359 | } | ||
360 | |||
294 | bool process_haptic(uint16_t keycode, keyrecord_t *record) { | 361 | bool process_haptic(uint16_t keycode, keyrecord_t *record) { |
295 | if (keycode == HPT_ON && record->event.pressed) { | 362 | if (keycode == HPT_ON && record->event.pressed) { |
296 | haptic_enable(); | 363 | haptic_enable(); |
@@ -335,12 +402,12 @@ bool process_haptic(uint16_t keycode, keyrecord_t *record) { | |||
335 | if (haptic_config.enable) { | 402 | if (haptic_config.enable) { |
336 | if (record->event.pressed) { | 403 | if (record->event.pressed) { |
337 | // keypress | 404 | // keypress |
338 | if (haptic_config.feedback < 2) { | 405 | if (haptic_config.feedback < 2 && get_haptic_enabled_key(keycode, record)) { |
339 | haptic_play(); | 406 | haptic_play(); |
340 | } | 407 | } |
341 | } else { | 408 | } else { |
342 | // keyrelease | 409 | // keyrelease |
343 | if (haptic_config.feedback > 0) { | 410 | if (haptic_config.feedback > 0 && get_haptic_enabled_key(keycode, record)) { |
344 | haptic_play(); | 411 | haptic_play(); |
345 | } | 412 | } |
346 | } | 413 | } |