]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add keycodes to turn on, turn off and toggle faux clicky
authorPriyadi Iman Nurcahyo <priyadi@priyadi.net>
Mon, 13 Feb 2017 07:55:35 +0000 (14:55 +0700)
committerPriyadi Iman Nurcahyo <priyadi@priyadi.net>
Mon, 13 Feb 2017 07:55:35 +0000 (14:55 +0700)
quantum/fauxclicky.h
quantum/quantum.c
quantum/quantum_keycodes.h

index 6cfc291c051915e016ff0b01bcb88c840a769bb3..109bd0d83eb83621f297b1210571c12038e2cbb8 100644 (file)
@@ -18,6 +18,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #endif
 
 #include "musical_notes.h"
+#include "stdbool.h"
 
 __attribute__ ((weak))
 float fauxclicky_pressed_note[2];
@@ -26,6 +27,8 @@ float fauxclicky_released_note[2];
 __attribute__ ((weak))
 float fauxclicky_beep_note[2];
 
+bool fauxclicky_enabled;
+
 //
 // tempo in BPM
 //
@@ -52,6 +55,15 @@ float fauxclicky_beep_note[2];
     fauxclicky_stop(); \
 } while (0)
 
+// toggle
+#define FAUXCLICKY_TOGGLE do { \
+    if (fauxclicky_enabled) { \
+        FAUXCLICKY_OFF; \
+    } else { \
+        FAUXCLICKY_ON; \
+    } \
+} while (0)
+
 //
 // pin configuration
 //
index 45ea8cb73c0553452aa9e1fc4a29e082a85ad4a2..2088c10c955ea3e21a1e9a88fb62240c4cf81f9e 100644 (file)
@@ -7,6 +7,10 @@
 #define TAPPING_TERM 200
 #endif
 
+#ifdef FAUXCLICKY_ENABLE
+#include "fauxclicky.h"
+#endif
+
 static void do_code16 (uint16_t code, void (*f) (uint8_t)) {
   switch (code) {
   case QK_MODS ... QK_MODS_MAX:
@@ -196,6 +200,26 @@ bool process_record_quantum(keyrecord_t *record) {
       }
          return false;
       break;
+  #ifdef FAUXCLICKY_ENABLE
+  case FC_TOG:
+    if (record->event.pressed) {
+      FAUXCLICKY_TOGGLE;
+    }
+    return false;
+    break;
+  case FC_ON:
+    if (record->event.pressed) {
+      FAUXCLICKY_ON;
+    }
+    return false;
+    break;
+  case FC_OFF:
+    if (record->event.pressed) {
+      FAUXCLICKY_OFF;
+    }
+    return false;
+    break;
+  #endif
        #ifdef RGBLIGHT_ENABLE
        case RGB_TOG:
                if (record->event.pressed) {
index ab2e790269e777944785797405f17405fcd3bd3e..cc7a5013f64e96b9f8fb140e2cb124ead8b302bf 100644 (file)
@@ -86,6 +86,13 @@ enum quantum_keycodes {
     AU_OFF,
     AU_TOG,
 
+#ifdef FAUXCLICKY_ENABLE
+    // Faux clicky
+    FC_ON,
+    FC_OFF,
+    FC_TOG,
+#endif
+
     // Music mode on/off/toggle
     MU_ON,
     MU_OFF,