1
0
Fork 0

Yet another update to drashna keymaps and userspace (#3787)

* Make tap function inline

* Use better makefile keyboard detection

* Remove Copy-Paste macro

* Add F11/F12 to Iris

* Minor tweaks to userspace config

* Set audio clicky randomness to 1.5
* Set NO_DEBUG to only be set if console is not enabled

* Move NO_MUSIC_MODE to userspace config.h

* Reduce Ergodox Debounce

* Add Planck Light config

* Use OSM for ortho 4x12

* Music Mode changes for planck light

* Cleanup do to shutdown user and other fixes in Master

* Add and use 'shutdown_user' fzunction

* Remove global NO_MUSIC_MODE define

* Add NO_MUSIC_MODE to individual keymaps

* Change layer colors

* Remove NO_PRINT and NO_DEBUG from userspace config.h

Since these are automatically disabled if the console isn't enabled.

* Remove backlight code if backlight isn't enabled

* Remove Twinkle from Ergodox

* Disable RGB twinkling and enable PSM

* Clean up RGB matrix code

* Clean up planck light indicators

* Clean up tap code

* Rules cleanup for ortho 4x12

* Fix up userspace template

* Revert "Clean up tap code"

This reverts commit 09f64d6d67aa021c3b5ac86a9a739a5ca2b9c1ec.

* Organize includes

* userspace cleanup

* Fix modifier spelling error

* Fix userspace rules

* Disable Permissive Hold again

* Minor clean up

* Fix Tap stuff

* Viterbi Updates for file size
This commit is contained in:
Drashna Jael're 2018-08-29 10:42:15 -07:00 committed by Jack Humbert
parent 661ca4440c
commit e4bbe057f2
19 changed files with 280 additions and 222 deletions

View file

@ -11,8 +11,10 @@
SONG(OVERWATCH_THEME) \
}
#define AUDIO_CLICKY_FREQ_RANDOMNESS 1.0f
#define AUDIO_CLICKY_FREQ_RANDOMNESS 1.5f
// #ifdef RGBLIGHT_ENABLE
// #define NO_MUSIC_MODE
// #endif //RGBLIGHT_ENABLE
#endif
#ifdef RGBLIGHT_ENABLE
@ -40,8 +42,8 @@
// and when this option isn't enabled, z rapidly followed by x
// actually sends Ctrl-x. That's bad.)
#define IGNORE_MOD_TAP_INTERRUPT
#undef PERMISSIVE_HOLD
#undef PREVENT_STUCK_MODIFIERS
#undef PERMISSIVE_HOLD
#define PREVENT_STUCK_MODIFIERS
// #define TAPPING_FORCE_HOLD
//#define RETRO_TAPPING
@ -59,12 +61,6 @@
// Disable action_get_macro and fn_actions, since we don't use these
// and it saves on space in the firmware.
#ifndef NO_DEBUG
#define NO_DEBUG
#endif // !NO_DEBUG
#if !defined(NO_PRINT) && !defined(CONSOLE_ENABLE)
#define NO_PRINT
#endif // !NO_PRINT
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION

View file

@ -16,16 +16,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "drashna.h"
#include "version.h"
#include "eeprom.h"
#include "tap_dances.h"
#include "rgb_stuff.h"
float tone_copy[][2] = SONG(SCROLL_LOCK_ON_SOUND);
float tone_paste[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
static uint16_t copy_paste_timer;
userspace_config_t userspace_config;
// Helper Functions
@ -35,8 +28,14 @@ userspace_config_t userspace_config;
// the same thing, but with differring text sent.
bool send_game_macro(const char *str, keyrecord_t *record, bool override) {
if (!record->event.pressed || override) {
uint16_t keycode;
if (userspace_config.is_overwatch) {
keycode = KC_BSPC;
} else {
keycode = KC_ENTER;
}
clear_keyboard();
tap(userspace_config.is_overwatch ? KC_BSPC : KC_ENTER);
tap(keycode);
wait_ms(50);
send_string_with_delay(str, MACRO_TIMER);
wait_ms(50);
@ -46,8 +45,6 @@ bool send_game_macro(const char *str, keyrecord_t *record, bool override) {
return false;
}
void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); };
bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) {
static uint16_t this_timer;
if(pressed) {
@ -93,6 +90,9 @@ void matrix_init_keymap(void) {}
__attribute__ ((weak))
void startup_keymap(void) {}
__attribute__ ((weak))
void shutdown_keymap(void) {}
__attribute__ ((weak))
void suspend_power_down_keymap(void) {}
@ -127,6 +127,7 @@ __attribute__ ((weak))
void led_set_keymap(uint8_t usb_led) {}
// Call user matrix init, set default RGB colors and then
// call the keymap's init function
void matrix_init_user(void) {
@ -158,6 +159,24 @@ void startup_user (void) {
startup_keymap();
}
void shutdown_user (void) {
#ifdef RGBLIGHT_ENABLE
rgblight_enable_noeeprom();
rgblight_mode_noeeprom(1);
rgblight_setrgb_red();
#endif // RGBLIGHT_ENABLE
#ifdef RGB_MATRIX_ENABLE
rgb_led led;
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
led = g_rgb_leds[i];
if (led.matrix_co.raw < 0xFF) {
rgb_matrix_set_color( i, 0xFF, 0x00, 0x00 );
}
}
#endif //RGB_MATRIX_ENABLE
shutdown_keymap();
}
void suspend_power_down_user(void)
{
suspend_power_down_keymap();
@ -246,20 +265,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return false;
break;
case KC_RESET: // Custom RESET code that sets RGBLights to RED
if (!record->event.pressed) {
#ifdef RGBLIGHT_ENABLE
rgblight_enable_noeeprom();
rgblight_mode_noeeprom(1);
rgblight_setrgb_red();
#endif // RGBLIGHT_ENABLE
reset_keyboard();
}
return false;
break;
case EPRM: // Resets EEPROM
if (record->event.pressed) {
eeconfig_init();
@ -333,28 +338,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return false; break;
case KC_CCCV: // One key copy/paste
if(record->event.pressed){
copy_paste_timer = timer_read();
} else {
if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy
register_code(KC_LCTL);
tap(KC_C);
unregister_code(KC_LCTL);
#ifdef AUDIO_ENABLE
PLAY_SONG(tone_copy);
#endif
} else { // Tap, paste
register_code(KC_LCTL);
tap(KC_V);
unregister_code(KC_LCTL);
#ifdef AUDIO_ENABLE
PLAY_SONG(tone_paste);
#endif
}
}
return false;
break;
case CLICKY_TOGGLE:
#ifdef AUDIO_CLICKY
userspace_config.clicky_enable = clicky_enable;

View file

@ -15,11 +15,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USERSPACE
#define USERSPACE
#pragma once
#include "quantum.h"
#include "version.h"
#include "eeprom.h"
#ifdef RGB_MATRIX_ENABLE
#include "rgb_matrix.h"
#endif
// Define layer names
enum userspace_layers {
_QWERTY = 0,
@ -53,7 +55,7 @@ extern bool clicky_enable;
void rgblight_sethsv_default_helper(uint8_t index);
#endif // RGBLIGHT_ENABLE
void tap(uint16_t keycode);
inline void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); };
bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed);
bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer);
@ -90,7 +92,6 @@ enum userspace_custom_keycodes {
KC_C9,
KC_GGEZ,
KC_MAKE, // Run keyboard's customized make command
KC_RESET, // Resets keyboard, with red underglow
KC_RGB_T, // Toggles RGB Layer Indication mode
KC_SECRET_1, // test1
KC_SECRET_2, // test2
@ -123,6 +124,7 @@ enum userspace_custom_keycodes {
#define COLEMAK KC_COLEMAK
#define WORKMAN KC_WORKMAN
#define KC_RESET RESET
#define KC_RST KC_RESET
#ifdef SWAP_HANDS_ENABLE
@ -131,6 +133,11 @@ enum userspace_custom_keycodes {
#define KC_C1R3 KC_BSPC
#endif // SWAP_HANDS_ENABLE
#define BK_LWER LT(_LOWER, KC_BSPC)
#define SP_LWER LT(_LOWER, KC_SPC)
#define DL_RAIS LT(_RAISE, KC_DEL)
#define ET_RAIS LT(_RAISE, KC_ENTER)
// OSM keycodes, to keep things clean and easy to change
#define KC_MLSF OSM(MOD_LSFT)
#define KC_MRSF OSM(MOD_RSFT)
@ -325,7 +332,7 @@ enum {
#define _________________ADJUST_L1_________________ RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, RGB_TOG
#define _________________ADJUST_L2_________________ _______, CK_TOGG, AU_ON, AU_OFF, AG_NORM
#define _________________ADJUST_L2_________________ MU_TOG , CK_TOGG, AU_ON, AU_OFF, AG_NORM
#define _________________ADJUST_L3_________________ RGB_RMOD,RGB_HUD,RGB_SAD, RGB_VAD, KC_RGB_T
#define _________________ADJUST_R1_________________ KC_SEC1, KC_SEC2, KC_SEC3, KC_SEC4, KC_SEC5
@ -350,4 +357,3 @@ enum {
LT(_LOWER, KC_SPACE),KC_BSPC, KC_END, KC_PGDN, KC_DEL, LT(_RAISE, KC_ENTER)
#endif // !USERSPACE

View file

@ -267,7 +267,7 @@ void matrix_init_rgb(void) {
case _COLEMAK:
rgblight_sethsv_noeeprom_magenta(); break;
case _DVORAK:
rgblight_sethsv_noeeprom_green(); break;
rgblight_sethsv_noeeprom_springgreen(); break;
case _WORKMAN:
rgblight_sethsv_noeeprom_goldenrod(); break;
default:
@ -313,7 +313,7 @@ uint32_t layer_state_set_rgb(uint32_t state) {
rgblight_mode_noeeprom(5);
break;
case _LOWER:
rgblight_sethsv_noeeprom_orange();
rgblight_sethsv_noeeprom_green();
rgblight_mode_noeeprom(5);
break;
case _ADJUST:
@ -325,7 +325,7 @@ uint32_t layer_state_set_rgb(uint32_t state) {
case _COLEMAK:
rgblight_sethsv_noeeprom_magenta(); break;
case _DVORAK:
rgblight_sethsv_noeeprom_green(); break;
rgblight_sethsv_noeeprom_springgreen(); break;
case _WORKMAN:
rgblight_sethsv_noeeprom_goldenrod(); break;
default:

View file

@ -13,4 +13,3 @@ void matrix_init_rgb(void);
void matrix_scan_rgb(void);
uint32_t layer_state_set_rgb(uint32_t state);

View file

@ -1,7 +1,5 @@
#include "drashna.h"
#include "quantum.h"
#include "action.h"
#include "version.h"
#include "template.h"
// Add reconfigurable functions here, for keymap customization
// This allows for a global, userspace functions, and continued
@ -10,25 +8,15 @@
__attribute__ ((weak))
void matrix_init_keymap(void) {}
__attribute__ ((weak))
void matrix_scan_keymap(void) {}
__attribute__ ((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
return true;
}
__attribute__ ((weak))
uint32_t layer_state_set_keymap (uint32_t state) {
return state;
}
__attribute__ ((weak))
void led_set_keymap(uint8_t usb_led) {}
// Call user matrix init, then call the keymap's init function
void matrix_init_user(void) {
matrix_init_keymap();
}
__attribute__ ((weak))
void matrix_scan_keymap(void) {}
// No global matrix scan code, so just run keymap's matix
// scan function
void matrix_scan_user(void) {
@ -36,11 +24,16 @@ void matrix_scan_user(void) {
}
__attribute__ ((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
return true;
}
// Defines actions tor my global custom keycodes. Defined in drashna.h file
// Then runs the _keymap's recod handier if not processed here,
// And use "NEWPLACEHOLDER" for new safe range
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_MAKE:
if (!record->event.pressed) {
@ -56,12 +49,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
return false;
break;
case KC_RESET:
if (!record->event.pressed) {
reset_keyboard();
}
return false;
break;
case EPRM:
if (record->event.pressed) {
eeconfig_init();
@ -78,13 +66,66 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return process_record_keymap(keycode, record);
}
// Runs state check and changes underglow color and animation
// on layer change, no matter where the change was initiated
// Then runs keymap's layer change check
__attribute__ ((weak))
uint32_t layer_state_set_keymap (uint32_t state) {
return state;
}
uint32_t layer_state_set_user (uint32_t state) {
return layer_state_set_keymap (state);
}
__attribute__ ((weak))
void led_set_keymap(uint8_t usb_led) {}
void led_set_user(uint8_t usb_led) {
led_set_keymap(usb_led);
}
__attribute__ ((weak))
void suspend_power_down_keymap(void) {}
void suspend_power_down_user(void)
{
suspend_power_down_keymap();
}
__attribute__ ((weak))
void suspend_wakeup_init_keymap(void) {}
void suspend_wakeup_init_user(void)
{
suspend_wakeup_init_keymap();
#ifdef KEYBOARD_ergodox_ez
wait_ms(10);
#endif
}
__attribute__ ((weak))
void startup_keymap(void) {}
void startup_user (void) {
#ifdef RGBLIGHT_ENABLE
matrix_init_rgb();
#endif //RGBLIGHT_ENABLE
startup_keymap();
}
__attribute__ ((weak))
void shutdown_keymap(void) {}
void shutdown_user (void) {
shutdown_keymap();
}

View file

@ -2,8 +2,10 @@
#define USERSPACE
#include "quantum.h"
#include "version.h"
#include "eeprom.h"
// Define layer names
// Define layer names
#define BASE 0
enum custom_keycodes {