Skip to content

Commit

Permalink
Merge pull request qmk#20 from sadekbaroudi/fp/rockon_haptic_and_audio
Browse files Browse the repository at this point in the history
haptic and audio keycode feature support for rock on and other boards
  • Loading branch information
sadekbaroudi authored Nov 21, 2022
2 parents 2f5017f + da15845 commit 5701f38
Show file tree
Hide file tree
Showing 29 changed files with 293 additions and 14 deletions.
5 changes: 4 additions & 1 deletion keyboards/fingerpunch/FP_LIBRARY_SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions keyboards/fingerpunch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/arachnophobe/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/barobord/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/barobord_byomcu/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/bgkeeb/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/bigbarobord/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/ffkb/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/ffkb_byomcu/rules.mk
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/fflx/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 3 additions & 0 deletions keyboards/fingerpunch/fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions keyboards/fingerpunch/fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
130 changes: 130 additions & 0 deletions keyboards/fingerpunch/fp_audio.c
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

#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
22 changes: 22 additions & 0 deletions keyboards/fingerpunch/fp_audio.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

#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);
19 changes: 11 additions & 8 deletions keyboards/fingerpunch/fp_haptic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -52,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);
}
Expand All @@ -63,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);
}
Expand All @@ -74,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);
}
Expand All @@ -87,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);
}
Expand Down
3 changes: 3 additions & 0 deletions keyboards/fingerpunch/fp_keyhandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/luakeeb/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 3 additions & 1 deletion keyboards/fingerpunch/personal/badwings/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions keyboards/fingerpunch/pinkiesout/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions keyboards/fingerpunch/rockon/rules.mk
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
Loading

0 comments on commit 5701f38

Please sign in to comment.