aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_haptic.c
diff options
context:
space:
mode:
authorPurdea Andrei <andrei@purdea.ro>2021-11-02 07:54:29 +0200
committerGitHub <noreply@github.com>2021-11-02 16:54:29 +1100
commit76fb54403ccd3ebaf1ca49c5172335e3593c5c5c (patch)
tree30b41c0b027baa5b9494f80ec0fd83c50a53fd5b /quantum/process_keycode/process_haptic.c
parent85d94d0c4d97de3d1b7ce0476499f44e79c25944 (diff)
downloadqmk_firmware-76fb54403ccd3ebaf1ca49c5172335e3593c5c5c.tar.gz
qmk_firmware-76fb54403ccd3ebaf1ca49c5172335e3593c5c5c.zip
haptic: Feature to disable it when usb port is not configured or suspended. (#12692)
This also add support for specifying a LED pin to indicate haptic status, and also adds support for a haptic-enable pin, which is useful to turn off the boost converter on the solenoid driver.
Diffstat (limited to 'quantum/process_keycode/process_haptic.c')
-rw-r--r--quantum/process_keycode/process_haptic.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/quantum/process_keycode/process_haptic.c b/quantum/process_keycode/process_haptic.c
index 1b9c2f24f..466c8e554 100644
--- a/quantum/process_keycode/process_haptic.c
+++ b/quantum/process_keycode/process_haptic.c
@@ -17,6 +17,7 @@
17#include "process_haptic.h" 17#include "process_haptic.h"
18#include "quantum_keycodes.h" 18#include "quantum_keycodes.h"
19#include "action_tapping.h" 19#include "action_tapping.h"
20#include "usb_device_state.h"
20 21
21__attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t *record) { 22__attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t *record) {
22 switch (keycode) { 23 switch (keycode) {
@@ -131,7 +132,7 @@ bool process_haptic(uint16_t keycode, keyrecord_t *record) {
131 } 132 }
132 } 133 }
133 134
134 if (haptic_get_enable()) { 135 if (haptic_get_enable() && ((!HAPTIC_OFF_IN_LOW_POWER) || (usb_device_state == USB_DEVICE_STATE_CONFIGURED))) {
135 if (record->event.pressed) { 136 if (record->event.pressed) {
136 // keypress 137 // keypress
137 if (haptic_get_feedback() < 2 && get_haptic_enabled_key(keycode, record)) { 138 if (haptic_get_feedback() < 2 && get_haptic_enabled_key(keycode, record)) {