From 263056bc89ff94e3863b085d783df9faaa1517dc Mon Sep 17 00:00:00 2001 From: Sadek Baroudi Date: Mon, 21 Nov 2022 00:35:14 -0800 Subject: [PATCH 1/2] adding haptic feedback and audio support for rock on v3.1 --- keyboards/fingerpunch/fp_haptic.c | 3 ++ keyboards/fingerpunch/rockon/v3/config.h | 47 ++++++++++++++++++- keyboards/fingerpunch/rockon/v3/fp_build.json | 10 ++++ keyboards/fingerpunch/rockon/v3/halconf.h | 6 ++- keyboards/fingerpunch/rockon/v3/mcuconf.h | 6 +++ keyboards/fingerpunch/rockon/v3/readme.md | 2 + keyboards/fingerpunch/rockon/v3/rules.mk | 6 +++ keyboards/fingerpunch/rockon/v3/v3.c | 12 +++++ 8 files changed, 88 insertions(+), 4 deletions(-) diff --git a/keyboards/fingerpunch/fp_haptic.c b/keyboards/fingerpunch/fp_haptic.c index ce71b60645b7..080a448b04b3 100644 --- a/keyboards/fingerpunch/fp_haptic.c +++ b/keyboards/fingerpunch/fp_haptic.c @@ -17,6 +17,9 @@ #include "keyboards/fingerpunch/fp_haptic.h" #ifdef HAPTIC_ENABLE + +#include "drivers/haptic/DRV2605L.h" + layer_state_t fp_layer_state_set_haptic(layer_state_t state) { switch (get_highest_layer(state)) { default: diff --git a/keyboards/fingerpunch/rockon/v3/config.h b/keyboards/fingerpunch/rockon/v3/config.h index 9b07b8470e30..49a06bd913fa 100644 --- a/keyboards/fingerpunch/rockon/v3/config.h +++ b/keyboards/fingerpunch/rockon/v3/config.h @@ -58,8 +58,51 @@ along with this program. If not, see . /* COL2ROW, ROW2COL*/ #define DIODE_DIRECTION COL2ROW -#define ENCODERS_PAD_A {C7, D5, F1} -#define ENCODERS_PAD_B {D2, B7, F0} + +// If we have audio enabled, that means we're not using the center encoder, as they share a pin on the controller +// Note that you need to solder the jumper on the pcb and remove teh audio buzzer from the pcb if using the center encoder +#ifdef AUDIO_ENABLE + #define ENCODERS_PAD_A {C7, D5} + #define ENCODERS_PAD_B {D2, B7} +#else + #define ENCODERS_PAD_A {C7, D5, F1} + #define ENCODERS_PAD_B {D2, B7, F0} +#endif + +#ifdef AUDIO_ENABLE + #define AUDIO_VOICES + #define AUDIO_PIN F1 + #define AUDIO_PWM_DRIVER PWMD2 + #define AUDIO_PWM_CHANNEL 1 + #define AUDIO_STATE_TIMER GPTD4 + // #define AUDIO_PWM_PAL_MODE 42 // only if using AUDIO_DRIVER = pwm_hardware + // #define NO_MUSIC_MODE + #define AUDIO_ENABLE_TONE_MULTIPLEXING + #define AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT 10 + #define STARTUP_SONG SONG(STARTUP_SOUND) + #define DEFAULT_LAYER_SONGS \ + { SONG(QWERTY_SOUND), SONG(COLEMAK_SOUND) } +#endif + +#ifdef HAPTIC_ENABLE + #define FB_ERM_LRA 1 + #define FB_BRAKEFACTOR 3 // For 1x:0, 2x:1, 3x:2, 4x:3, 6x:4, 8x:5, 16x:6, Disable Braking:7 + #define FB_LOOPGAIN 1 // For Low:0, Medium:1, High:2, Very High:3 + #define RATED_VOLTAGE 2 + #define V_PEAK 2.8 + #define V_RMS 2.0 + #define F_LRA 150 // resonance freq + #define DRV_GREETING alert_750ms + #define NO_HAPTIC_ALPHA + #define NO_HAPTIC_LOCKKEYS + #define NO_HAPTIC_PUNCTUATION + #define NO_HAPTIC_NAV + #define NO_HAPTIC_NUMERIC + #define NO_HAPTIC_MOD + #define FP_HAPTIC_MOUSE_BUTTONS + #define FP_HAPTIC_CUT_COPY_PASTE + #define FP_HAPTIC_SAVE +#endif #ifdef CIRQUE_ENABLE // cirque trackpad config diff --git a/keyboards/fingerpunch/rockon/v3/fp_build.json b/keyboards/fingerpunch/rockon/v3/fp_build.json index 6009b5b1023d..9beb1a70656c 100644 --- a/keyboards/fingerpunch/rockon/v3/fp_build.json +++ b/keyboards/fingerpunch/rockon/v3/fp_build.json @@ -22,5 +22,15 @@ "type" : "single", "name" : "ENCODER_ENABLE", "user_input": "Do you have one or more rotary encoders?" + }, + { + "type" : "single", + "name" : "AUDIO_ENABLE", + "user_input": "Do you have an audio buzzer?" + }, + { + "type" : "single", + "name" : "HAPTIC_ENABLE", + "user_input": "Do you have haptic feedback?" } ] diff --git a/keyboards/fingerpunch/rockon/v3/halconf.h b/keyboards/fingerpunch/rockon/v3/halconf.h index ad85b85967ff..52528b1d5952 100644 --- a/keyboards/fingerpunch/rockon/v3/halconf.h +++ b/keyboards/fingerpunch/rockon/v3/halconf.h @@ -22,9 +22,11 @@ #pragma once +#define HAL_USE_PWM TRUE +#define HAL_USE_GPT TRUE #define HAL_USE_SERIAL TRUE -#define HAL_USE_SPI TRUE -#define SPI_USE_WAIT TRUE +#define HAL_USE_SPI TRUE +#define SPI_USE_WAIT TRUE #define SPI_SELECT_MODE SPI_SELECT_MODE_PAD #include_next diff --git a/keyboards/fingerpunch/rockon/v3/mcuconf.h b/keyboards/fingerpunch/rockon/v3/mcuconf.h index b83dc6104256..165cdddbe5ae 100644 --- a/keyboards/fingerpunch/rockon/v3/mcuconf.h +++ b/keyboards/fingerpunch/rockon/v3/mcuconf.h @@ -44,3 +44,9 @@ Compiling: keyboards/fingerpunch/ffkb_byomcu/v3/matrix_74hc595_spi.c #undef STM32_ST_USE_TIMER #define STM32_ST_USE_TIMER 5 + +#undef STM32_GPT_USE_TIM4 +#define STM32_GPT_USE_TIM4 TRUE + +#undef STM32_PWM_USE_TIM2 +#define STM32_PWM_USE_TIM2 TRUE diff --git a/keyboards/fingerpunch/rockon/v3/readme.md b/keyboards/fingerpunch/rockon/v3/readme.md index c29a4df1be22..3f1fcffee005 100644 --- a/keyboards/fingerpunch/rockon/v3/readme.md +++ b/keyboards/fingerpunch/rockon/v3/readme.md @@ -18,6 +18,8 @@ Options are: RGBLIGHT_ENABLE=yes RGB_MATRIX_ENABLE=yes ENCODER_ENABLE=yes + AUDIO_ENABLE=yes + HAPTIC_ENABLE=yes ``` Example of flashing this keyboard: diff --git a/keyboards/fingerpunch/rockon/v3/rules.mk b/keyboards/fingerpunch/rockon/v3/rules.mk index 4165e3c1b140..5f9deb3a6256 100644 --- a/keyboards/fingerpunch/rockon/v3/rules.mk +++ b/keyboards/fingerpunch/rockon/v3/rules.mk @@ -43,6 +43,12 @@ SRC += keyboards/fingerpunch/fp_matrix_74hc595_spi.c QUANTUM_LIB_SRC += spi_master.c CUSTOM_MATRIX = lite +AUDIO_ENABLE ?= no +AUDIO_DRIVER = pwm_software + +HAPTIC_ENABLE ?= no +HAPTIC_DRIVER = DRV2605L + ifeq ($(strip $(CIRQUE_ENABLE)), yes) MOUSEKEY_ENABLE := yes # not required, but enabling for mouse button keys POINTING_DEVICE_ENABLE := yes diff --git a/keyboards/fingerpunch/rockon/v3/v3.c b/keyboards/fingerpunch/rockon/v3/v3.c index 05d2d2df4b30..5ee533d8e552 100644 --- a/keyboards/fingerpunch/rockon/v3/v3.c +++ b/keyboards/fingerpunch/rockon/v3/v3.c @@ -53,3 +53,15 @@ led_config_t g_led_config = { { 1, 4, 4, 4, 4, 4, 1 } }; #endif + +#ifdef AUDIO_ENABLE +// TODO: This is incorrect, see https://github.com/qmk/qmk_firmware/blob/master/docs/feature_audio.md#music-map +const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = LAYOUT_rockon( + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 0 +); +#endif From da15845081dd65c254a6c83e1a654137ee85eaa2 Mon Sep 17 00:00:00 2001 From: Sadek Baroudi Date: Mon, 21 Nov 2022 14:55:39 -0800 Subject: [PATCH 2/2] added audio features, and fixed the haptic keycodes not triggering --- keyboards/fingerpunch/FP_LIBRARY_SUPPORT.md | 5 +- keyboards/fingerpunch/README.md | 12 ++ keyboards/fingerpunch/arachnophobe/rules.mk | 1 + keyboards/fingerpunch/barobord/rules.mk | 1 + .../fingerpunch/barobord_byomcu/rules.mk | 1 + keyboards/fingerpunch/bgkeeb/rules.mk | 1 + keyboards/fingerpunch/bigbarobord/rules.mk | 1 + keyboards/fingerpunch/ffkb/rules.mk | 1 + keyboards/fingerpunch/ffkb_byomcu/rules.mk | 1 + keyboards/fingerpunch/fflx/rules.mk | 1 + keyboards/fingerpunch/fp.c | 3 + keyboards/fingerpunch/fp.h | 3 + keyboards/fingerpunch/fp_audio.c | 130 ++++++++++++++++++ keyboards/fingerpunch/fp_audio.h | 22 +++ keyboards/fingerpunch/fp_haptic.c | 16 +-- keyboards/fingerpunch/fp_keyhandler.c | 3 + keyboards/fingerpunch/luakeeb/rules.mk | 1 + .../fingerpunch/personal/badwings/rules.mk | 4 +- keyboards/fingerpunch/pinkiesout/rules.mk | 1 + keyboards/fingerpunch/rockon/rules.mk | 1 + keyboards/fingerpunch/rockon/v3/config.h | 4 + keyboards/fingerpunch/rockon_bp/rules.mk | 1 + keyboards/fingerpunch/sweeeeep/rules.mk | 1 + 23 files changed, 205 insertions(+), 10 deletions(-) create mode 100644 keyboards/fingerpunch/fp_audio.c create mode 100644 keyboards/fingerpunch/fp_audio.h diff --git a/keyboards/fingerpunch/FP_LIBRARY_SUPPORT.md b/keyboards/fingerpunch/FP_LIBRARY_SUPPORT.md index f05e7693a4cf..874a1440d5af 100644 --- a/keyboards/fingerpunch/FP_LIBRARY_SUPPORT.md +++ b/keyboards/fingerpunch/FP_LIBRARY_SUPPORT.md @@ -17,11 +17,14 @@ Note that below is an example. You should check for the latest version of this c ```make DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ - keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ + keyboards/fingerpunch/fp_rgb_common.c \ keyboards/fingerpunch/fp_rgblight.c \ keyboards/fingerpunch/fp_rgb_matrix.c + ``` ## Personal notes for Sadek's keymaps diff --git a/keyboards/fingerpunch/README.md b/keyboards/fingerpunch/README.md index 5c624d2268e2..4bbe7a409594 100644 --- a/keyboards/fingerpunch/README.md +++ b/keyboards/fingerpunch/README.md @@ -213,6 +213,18 @@ Note that the ctrl-X haptic feedback responses will use control as the modifier, | `FP_HAPTIC_CUT_COPY_PASTE` | (Optional) Enable haptic feedback response for ctrl-x, ctrl-c, ctrl-v | `undefined` | | `FP_HAPTIC_SAVE` | (Optional) Enable haptic feedback response for ctrl-s | `undefined` | +## Audio + +Enable special audio features. Please see https://github.com/qmk/qmk_firmware/blob/master/docs/feature_audio.md for general audio features that you can enable and use. + +Note that the ctrl-X audio responses will use control as the modifier, so it won't work on a Mac by default. However, if are primarily using a Mac, enable the `FP_MAC_PREFERRED` in your config.h + +| Setting | Description | Default | +| --------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------- | +| `FP_AUDIO_MOUSE_BUTTONS` | (Optional) Enable audio response for Mouse 1, 2, and 3 | `undefined` | +| `FP_AUDIO_CUT_COPY_PASTE` | (Optional) Enable audio response for ctrl-x, ctrl-c, ctrl-v | `undefined` | +| `FP_AUDIO_SAVE` | (Optional) Enable audio response for ctrl-s | `undefined` | + ## Keymap diff --git a/keyboards/fingerpunch/arachnophobe/rules.mk b/keyboards/fingerpunch/arachnophobe/rules.mk index bc80a0871246..faa9efa7a15c 100644 --- a/keyboards/fingerpunch/arachnophobe/rules.mk +++ b/keyboards/fingerpunch/arachnophobe/rules.mk @@ -33,6 +33,7 @@ MOUSEKEY_ENABLE = yes DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/barobord/rules.mk b/keyboards/fingerpunch/barobord/rules.mk index e349f59501e2..83dd37ce1219 100644 --- a/keyboards/fingerpunch/barobord/rules.mk +++ b/keyboards/fingerpunch/barobord/rules.mk @@ -51,6 +51,7 @@ endif DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/barobord_byomcu/rules.mk b/keyboards/fingerpunch/barobord_byomcu/rules.mk index 78dab5289af9..143abe92aa82 100644 --- a/keyboards/fingerpunch/barobord_byomcu/rules.mk +++ b/keyboards/fingerpunch/barobord_byomcu/rules.mk @@ -58,6 +58,7 @@ endif DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/bgkeeb/rules.mk b/keyboards/fingerpunch/bgkeeb/rules.mk index a87b3c91c5c4..99cdf49caaf6 100644 --- a/keyboards/fingerpunch/bgkeeb/rules.mk +++ b/keyboards/fingerpunch/bgkeeb/rules.mk @@ -28,6 +28,7 @@ LAYOUTS = split_3x5_3 DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/bigbarobord/rules.mk b/keyboards/fingerpunch/bigbarobord/rules.mk index e7905d121274..9f56f90e4366 100644 --- a/keyboards/fingerpunch/bigbarobord/rules.mk +++ b/keyboards/fingerpunch/bigbarobord/rules.mk @@ -51,6 +51,7 @@ endif DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/ffkb/rules.mk b/keyboards/fingerpunch/ffkb/rules.mk index 0afc7c11bb5a..47a62d442282 100644 --- a/keyboards/fingerpunch/ffkb/rules.mk +++ b/keyboards/fingerpunch/ffkb/rules.mk @@ -66,6 +66,7 @@ endif DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/ffkb_byomcu/rules.mk b/keyboards/fingerpunch/ffkb_byomcu/rules.mk index a55d4b419b85..07c7582fc7de 100644 --- a/keyboards/fingerpunch/ffkb_byomcu/rules.mk +++ b/keyboards/fingerpunch/ffkb_byomcu/rules.mk @@ -1,6 +1,7 @@ DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/fflx/rules.mk b/keyboards/fingerpunch/fflx/rules.mk index 956f444f9da5..994671334e36 100644 --- a/keyboards/fingerpunch/fflx/rules.mk +++ b/keyboards/fingerpunch/fflx/rules.mk @@ -64,6 +64,7 @@ endif DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/fp.c b/keyboards/fingerpunch/fp.c index fc794d998b7e..5b55c9a07c84 100644 --- a/keyboards/fingerpunch/fp.c +++ b/keyboards/fingerpunch/fp.c @@ -134,6 +134,9 @@ layer_state_t layer_state_set_kb(layer_state_t state) { #ifdef HAPTIC_ENABLE state = fp_layer_state_set_haptic(state); #endif // HAPTIC_ENABLE +#ifdef AUDIO_ENABLE + state = fp_layer_state_set_audio(state); +#endif // AUDIO_ENABLE #ifdef POINTING_DEVICE_ENABLE state = fp_layer_state_set_pointing(state); #endif // POINTING_DEVICE_ENABLE diff --git a/keyboards/fingerpunch/fp.h b/keyboards/fingerpunch/fp.h index 3c084f482dbe..8a2b05a56a06 100644 --- a/keyboards/fingerpunch/fp.h +++ b/keyboards/fingerpunch/fp.h @@ -40,6 +40,9 @@ void press_super_tab(bool shift); #ifdef HAPTIC_ENABLE # include "keyboards/fingerpunch/fp_haptic.h" #endif +#ifdef AUDIO_ENABLE +# include "keyboards/fingerpunch/fp_audio.h" +#endif #ifdef POINTING_DEVICE_ENABLE # include "keyboards/fingerpunch/fp_pointing.h" #endif diff --git a/keyboards/fingerpunch/fp_audio.c b/keyboards/fingerpunch/fp_audio.c new file mode 100644 index 000000000000..7b34a67b112c --- /dev/null +++ b/keyboards/fingerpunch/fp_audio.c @@ -0,0 +1,130 @@ +/* Copyright 2022 Sadek Baroudi + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "keyboards/fingerpunch/fp_audio.h" + +#ifdef AUDIO_ENABLE + +#include "song_list.h" +#include "musical_notes.h" + + +#define FP_MOUSE_SOUND_1 EIGHTH_NOTE(_B2), +#define FP_MOUSE_SOUND_2 EIGHTH_NOTE(_B3), +#define FP_MOUSE_SOUND_3 EIGHTH_NOTE(_B2), EIGHTH_NOTE(_B2), + +#define FP_CUT_SOUND EIGHTH_NOTE(_B4), EIGHTH_NOTE(_B3), EIGHTH_NOTE(_B4), +#define FP_COPY_SOUND EIGHTH_NOTE(_B3), EIGHTH_NOTE(_B4), +#define FP_PASTE_SOUND EIGHTH_NOTE(_B4), EIGHTH_NOTE(_B3), + +#define FP_SAVE_SOUND EIGHTH_NOTE(_F2), EIGHTH_NOTE(_F2), + +float fp_mouse_sound_1[][2] = SONG(FP_MOUSE_SOUND_1); +float fp_mouse_sound_2[][2] = SONG(FP_MOUSE_SOUND_2); +float fp_mouse_sound_3[][2] = SONG(FP_MOUSE_SOUND_3); + +float fp_cut_sound[][2] = SONG(FP_CUT_SOUND); +float fp_copy_sound[][2] = SONG(FP_COPY_SOUND); +float fp_paste_sound[][2] = SONG(FP_PASTE_SOUND); + +float fp_save_sound[][2] = SONG(FP_SAVE_SOUND); + +layer_state_t fp_layer_state_set_audio(layer_state_t state) { + switch (get_highest_layer(state)) { + default: + break; + } + return state; +} + +bool fp_process_record_audio(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { +# ifndef FP_DISABLE_CUSTOM_KEYCODES + // NOTE TO SELF: IF I EVER ADD KEYCODES HERE, DETERMINE WHETHER THEY ARE CONSIDERED CUSTOM KEYCODES OR NOT + // In the case of the mouse buttons and ctrl-x,c,v,s features below, they are treated independently, so they aren't effected by FP_DISABLE_CUSTOM_KEYCODES +# endif // FP_DISABLE_CUSTOM_KEYCODES +# ifdef FP_AUDIO_MOUSE_BUTTONS + case KC_BTN1: + if (record->event.pressed) { + PLAY_SONG(fp_mouse_sound_1); + } + break; + case KC_BTN2: + if (record->event.pressed) { + PLAY_SONG(fp_mouse_sound_2); + } + break; + case KC_BTN3: + if (record->event.pressed) { + PLAY_SONG(fp_mouse_sound_3); + } + break; +# endif +# ifdef FP_AUDIO_CUT_COPY_PASTE + case KC_C: // copy + if (record->event.pressed) { +# ifdef FP_MAC_PREFERRED + if (get_mods() & MOD_MASK_GUI) { +# else + if (get_mods() & MOD_MASK_CTRL) { +# endif + PLAY_SONG(fp_copy_sound); + } + } + break; + case KC_X: // cut + if (record->event.pressed) { +# ifdef FP_MAC_PREFERRED + if (get_mods() & MOD_MASK_GUI) { +# else + if (get_mods() & MOD_MASK_CTRL) { +# endif + PLAY_SONG(fp_cut_sound); + } + } + break; + case KC_V: // paste + if (record->event.pressed) { +# ifdef FP_MAC_PREFERRED + if (get_mods() & MOD_MASK_GUI) { +# else + if (get_mods() & MOD_MASK_CTRL) { +# endif + PLAY_SONG(fp_paste_sound); + } + } + break; +# endif +# ifdef FP_AUDIO_SAVE + case KC_S: // save + if (record->event.pressed) { +# ifdef FP_MAC_PREFERRED + if (get_mods() & MOD_MASK_GUI) { +# else + if (get_mods() & MOD_MASK_CTRL) { +# endif + PLAY_SONG(fp_save_sound); + } + } + break; +#endif + default: + break; + } + + return true; +} +#endif diff --git a/keyboards/fingerpunch/fp_audio.h b/keyboards/fingerpunch/fp_audio.h new file mode 100644 index 000000000000..a64cff8d9cd6 --- /dev/null +++ b/keyboards/fingerpunch/fp_audio.h @@ -0,0 +1,22 @@ +/* Copyright 2022 Sadek Baroudi + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include QMK_KEYBOARD_H +#include "keyboards/fingerpunch/fp.h" + +layer_state_t fp_layer_state_set_audio(layer_state_t state); +bool fp_process_record_audio(uint16_t keycode, keyrecord_t *record); diff --git a/keyboards/fingerpunch/fp_haptic.c b/keyboards/fingerpunch/fp_haptic.c index 080a448b04b3..6ed4ebf3caa3 100644 --- a/keyboards/fingerpunch/fp_haptic.c +++ b/keyboards/fingerpunch/fp_haptic.c @@ -55,9 +55,9 @@ bool fp_process_record_haptic(uint16_t keycode, keyrecord_t *record) { case KC_C: // copy if (record->event.pressed) { # ifdef FP_MAC_PREFERRED - if (get_mods() & MOD_MASK_CTRL) { -# else if (get_mods() & MOD_MASK_GUI) { +# else + if (get_mods() & MOD_MASK_CTRL) { # endif DRV_pulse(lg_dblclick_str); } @@ -66,9 +66,9 @@ bool fp_process_record_haptic(uint16_t keycode, keyrecord_t *record) { case KC_X: // cut if (record->event.pressed) { # ifdef FP_MAC_PREFERRED - if (get_mods() & MOD_MASK_CTRL) { -# else if (get_mods() & MOD_MASK_GUI) { +# else + if (get_mods() & MOD_MASK_CTRL) { # endif DRV_pulse(lg_dblclick_str); } @@ -77,9 +77,9 @@ bool fp_process_record_haptic(uint16_t keycode, keyrecord_t *record) { case KC_V: // paste if (record->event.pressed) { # ifdef FP_MAC_PREFERRED - if (get_mods() & MOD_MASK_CTRL) { -# else if (get_mods() & MOD_MASK_GUI) { +# else + if (get_mods() & MOD_MASK_CTRL) { # endif DRV_pulse(soft_bump); } @@ -90,9 +90,9 @@ bool fp_process_record_haptic(uint16_t keycode, keyrecord_t *record) { case KC_S: // save if (record->event.pressed) { # ifdef FP_MAC_PREFERRED - if (get_mods() & MOD_MASK_CTRL) { -# else if (get_mods() & MOD_MASK_GUI) { +# else + if (get_mods() & MOD_MASK_CTRL) { # endif DRV_pulse(pulsing_strong); } diff --git a/keyboards/fingerpunch/fp_keyhandler.c b/keyboards/fingerpunch/fp_keyhandler.c index a8be24c95a64..06f62ae13fd2 100644 --- a/keyboards/fingerpunch/fp_keyhandler.c +++ b/keyboards/fingerpunch/fp_keyhandler.c @@ -38,6 +38,9 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { #ifdef HAPTIC_ENABLE && fp_process_record_haptic(keycode, record) #endif +#ifdef AUDIO_ENABLE + && fp_process_record_audio(keycode, record) +#endif #if defined(POINTING_DEVICE_ENABLE) && fp_process_record_pointing(keycode, record) #endif diff --git a/keyboards/fingerpunch/luakeeb/rules.mk b/keyboards/fingerpunch/luakeeb/rules.mk index 603a6ee88e26..00c807a242d9 100644 --- a/keyboards/fingerpunch/luakeeb/rules.mk +++ b/keyboards/fingerpunch/luakeeb/rules.mk @@ -28,6 +28,7 @@ LAYOUTS = split_3x5_4 DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/personal/badwings/rules.mk b/keyboards/fingerpunch/personal/badwings/rules.mk index 97d8416ffdf9..67ee61ea55f3 100644 --- a/keyboards/fingerpunch/personal/badwings/rules.mk +++ b/keyboards/fingerpunch/personal/badwings/rules.mk @@ -29,8 +29,10 @@ endif DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ - keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ + keyboards/fingerpunch/fp_rgb_common.c \ keyboards/fingerpunch/fp_rgblight.c \ keyboards/fingerpunch/fp_rgb_matrix.c diff --git a/keyboards/fingerpunch/pinkiesout/rules.mk b/keyboards/fingerpunch/pinkiesout/rules.mk index 14e64579456d..ed5eb21cc24e 100644 --- a/keyboards/fingerpunch/pinkiesout/rules.mk +++ b/keyboards/fingerpunch/pinkiesout/rules.mk @@ -51,6 +51,7 @@ endif DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/rockon/rules.mk b/keyboards/fingerpunch/rockon/rules.mk index a55d4b419b85..07c7582fc7de 100644 --- a/keyboards/fingerpunch/rockon/rules.mk +++ b/keyboards/fingerpunch/rockon/rules.mk @@ -1,6 +1,7 @@ DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/rockon/v3/config.h b/keyboards/fingerpunch/rockon/v3/config.h index 49a06bd913fa..8d87e948146d 100644 --- a/keyboards/fingerpunch/rockon/v3/config.h +++ b/keyboards/fingerpunch/rockon/v3/config.h @@ -75,10 +75,14 @@ along with this program. If not, see . #define AUDIO_PWM_DRIVER PWMD2 #define AUDIO_PWM_CHANNEL 1 #define AUDIO_STATE_TIMER GPTD4 + #define AUDIO_VOICES // #define AUDIO_PWM_PAL_MODE 42 // only if using AUDIO_DRIVER = pwm_hardware // #define NO_MUSIC_MODE #define AUDIO_ENABLE_TONE_MULTIPLEXING #define AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT 10 + #define FP_AUDIO_MOUSE_BUTTONS + #define FP_AUDIO_CUT_COPY_PASTE + #define FP_AUDIO_SAVE #define STARTUP_SONG SONG(STARTUP_SOUND) #define DEFAULT_LAYER_SONGS \ { SONG(QWERTY_SOUND), SONG(COLEMAK_SOUND) } diff --git a/keyboards/fingerpunch/rockon_bp/rules.mk b/keyboards/fingerpunch/rockon_bp/rules.mk index 063b1fe8b277..ba73fc794d24 100644 --- a/keyboards/fingerpunch/rockon_bp/rules.mk +++ b/keyboards/fingerpunch/rockon_bp/rules.mk @@ -63,6 +63,7 @@ endif DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \ diff --git a/keyboards/fingerpunch/sweeeeep/rules.mk b/keyboards/fingerpunch/sweeeeep/rules.mk index 55183c76e46b..e2af3d3d2a46 100644 --- a/keyboards/fingerpunch/sweeeeep/rules.mk +++ b/keyboards/fingerpunch/sweeeeep/rules.mk @@ -34,6 +34,7 @@ LAYOUTS = split_3x5_3 # Community layout support DEFERRED_EXEC_ENABLE = yes SRC += keyboards/fingerpunch/fp.c \ keyboards/fingerpunch/fp_haptic.c \ + keyboards/fingerpunch/fp_audio.c \ keyboards/fingerpunch/fp_keyhandler.c \ keyboards/fingerpunch/fp_pointing.c \ keyboards/fingerpunch/fp_rgb_common.c \