diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/action.c | 2 | ||||
-rw-r--r-- | quantum/audio/audio.c | 27 | ||||
-rw-r--r-- | quantum/audio/audio.h | 6 | ||||
-rw-r--r-- | quantum/eeconfig.c | 6 | ||||
-rw-r--r-- | quantum/eeconfig.h | 64 | ||||
-rw-r--r-- | quantum/main.c | 35 | ||||
-rw-r--r-- | quantum/pointing_device/pointing_device_auto_mouse.c | 20 | ||||
-rw-r--r-- | quantum/pointing_device/pointing_device_auto_mouse.h | 4 |
8 files changed, 115 insertions, 49 deletions
diff --git a/quantum/action.c b/quantum/action.c index 8dae32b2cb..74ef55e5eb 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -658,7 +658,6 @@ void process_action(keyrecord_t *record, action_t action) { layer_off(action.layer_tap.val); break; } else if (tap_count < ONESHOT_TAP_TOGGLE) { - layer_on(action.layer_tap.val); set_oneshot_layer(action.layer_tap.val, ONESHOT_START); } } else { @@ -671,7 +670,6 @@ void process_action(keyrecord_t *record, action_t action) { } # else if (event.pressed) { - layer_on(action.layer_tap.val); set_oneshot_layer(action.layer_tap.val, ONESHOT_START); } else { clear_oneshot_layer_state(ONESHOT_PRESSED); diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index c1a1500493..b2611c5f09 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -20,6 +20,7 @@ #include "debug.h" #include "wait.h" #include "util.h" +#include "gpio.h" /* audio system: * @@ -121,6 +122,32 @@ static bool audio_initialized = false; static bool audio_driver_stopped = true; audio_config_t audio_config; +#ifndef AUDIO_POWER_CONTROL_PIN_ON_STATE +# define AUDIO_POWER_CONTROL_PIN_ON_STATE 1 +#endif + +void audio_driver_initialize(void) { +#ifdef AUDIO_POWER_CONTROL_PIN + gpio_set_pin_output_push_pull(AUDIO_POWER_CONTROL_PIN); + gpio_write_pin(AUDIO_POWER_CONTROL_PIN, !AUDIO_POWER_CONTROL_PIN_ON_STATE); +#endif + audio_driver_initialize_impl(); +} + +void audio_driver_stop(void) { + audio_driver_stop_impl(); +#ifdef AUDIO_POWER_CONTROL_PIN + gpio_write_pin(AUDIO_POWER_CONTROL_PIN, !AUDIO_POWER_CONTROL_PIN_ON_STATE); +#endif +} + +void audio_driver_start(void) { +#ifdef AUDIO_POWER_CONTROL_PIN + gpio_write_pin(AUDIO_POWER_CONTROL_PIN, AUDIO_POWER_CONTROL_PIN_ON_STATE); +#endif + audio_driver_start_impl(); +} + void eeconfig_update_audio_current(void) { eeconfig_update_audio(audio_config.raw); } diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index eb0bedc6f9..054331d6f3 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -215,9 +215,9 @@ void audio_startup(void); // hardware interface // implementation in the driver_avr/arm_* respective parts -void audio_driver_initialize(void); -void audio_driver_start(void); -void audio_driver_stop(void); +void audio_driver_initialize_impl(void); +void audio_driver_start_impl(void); +void audio_driver_stop_impl(void); /** * @brief get the number of currently active tones diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index 2d2180b4b4..40690d6a97 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c @@ -19,6 +19,8 @@ void via_eeprom_set_valid(bool valid); void eeconfig_init_via(void); #endif +_Static_assert((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect"); + /** \brief eeconfig enable * * FIXME: needs doc @@ -57,11 +59,9 @@ void eeconfig_init_quantum(void) { eeprom_update_byte(EECONFIG_AUDIO, 0); eeprom_update_dword(EECONFIG_RGBLIGHT, 0); eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, 0); - eeprom_update_byte(EECONFIG_UNUSED, 0); eeprom_update_byte(EECONFIG_UNICODEMODE, 0); eeprom_update_byte(EECONFIG_STENOMODE, 0); - uint64_t dummy = 0; - eeprom_update_block(&dummy, EECONFIG_RGB_MATRIX, sizeof(uint64_t)); + eeprom_write_qword(EECONFIG_RGB_MATRIX, 0); eeprom_update_dword(EECONFIG_HAPTIC, 0); #if defined(HAPTIC_ENABLE) haptic_reset(); diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h index d7cce166bd..fa0dd799d1 100644 --- a/quantum/eeconfig.h +++ b/quantum/eeconfig.h @@ -19,37 +19,57 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <stdint.h> #include <stdbool.h> +#include <stddef.h> // offsetof #include "eeprom.h" +#include "util.h" #ifndef EECONFIG_MAGIC_NUMBER -# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE6 // When changing, decrement this value to avoid future re-init issues +# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE5 // When changing, decrement this value to avoid future re-init issues #endif #define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF +// Dummy struct only used to calculate offsets +typedef struct PACKED { + uint16_t magic; + uint8_t debug; + uint8_t default_layer; + uint16_t keymap; + uint8_t backlight; + uint8_t audio; + uint32_t rgblight; + uint8_t unicode; + uint8_t steno; + uint8_t handedness; + uint32_t keyboard; + uint32_t user; + union { // Mutually exclusive + uint32_t led_matrix; + uint64_t rgb_matrix; + }; + uint32_t haptic; + uint8_t rgblight_ext; +} eeprom_core_t; + /* EEPROM parameter address */ -#define EECONFIG_MAGIC (uint16_t *)0 -#define EECONFIG_DEBUG (uint8_t *)2 -#define EECONFIG_DEFAULT_LAYER (uint8_t *)3 -#define EECONFIG_KEYMAP (uint16_t *)4 -#define EECONFIG_BACKLIGHT (uint8_t *)6 -#define EECONFIG_AUDIO (uint8_t *)7 -#define EECONFIG_RGBLIGHT (uint32_t *)8 -#define EECONFIG_UNICODEMODE (uint8_t *)12 -#define EECONFIG_STENOMODE (uint8_t *)13 -// EEHANDS for two handed boards -#define EECONFIG_HANDEDNESS (uint8_t *)14 -#define EECONFIG_KEYBOARD (uint32_t *)15 -#define EECONFIG_USER (uint32_t *)19 -#define EECONFIG_UNUSED (uint8_t *)23 -// Mutually exclusive -#define EECONFIG_LED_MATRIX (uint32_t *)24 -#define EECONFIG_RGB_MATRIX (uint64_t *)24 - -#define EECONFIG_HAPTIC (uint32_t *)32 -#define EECONFIG_RGBLIGHT_EXTENDED (uint8_t *)36 +#define EECONFIG_MAGIC (uint16_t *)(offsetof(eeprom_core_t, magic)) +#define EECONFIG_DEBUG (uint8_t *)(offsetof(eeprom_core_t, debug)) +#define EECONFIG_DEFAULT_LAYER (uint8_t *)(offsetof(eeprom_core_t, default_layer)) +#define EECONFIG_KEYMAP (uint16_t *)(offsetof(eeprom_core_t, keymap)) +#define EECONFIG_BACKLIGHT (uint8_t *)(offsetof(eeprom_core_t, backlight)) +#define EECONFIG_AUDIO (uint8_t *)(offsetof(eeprom_core_t, audio)) +#define EECONFIG_RGBLIGHT (uint32_t *)(offsetof(eeprom_core_t, rgblight)) +#define EECONFIG_UNICODEMODE (uint8_t *)(offsetof(eeprom_core_t, unicode)) +#define EECONFIG_STENOMODE (uint8_t *)(offsetof(eeprom_core_t, steno)) +#define EECONFIG_HANDEDNESS (uint8_t *)(offsetof(eeprom_core_t, handedness)) +#define EECONFIG_KEYBOARD (uint32_t *)(offsetof(eeprom_core_t, keyboard)) +#define EECONFIG_USER (uint32_t *)(offsetof(eeprom_core_t, user)) +#define EECONFIG_LED_MATRIX (uint32_t *)(offsetof(eeprom_core_t, led_matrix)) +#define EECONFIG_RGB_MATRIX (uint64_t *)(offsetof(eeprom_core_t, rgb_matrix)) +#define EECONFIG_HAPTIC (uint32_t *)(offsetof(eeprom_core_t, haptic)) +#define EECONFIG_RGBLIGHT_EXTENDED (uint8_t *)(offsetof(eeprom_core_t, rgblight_ext)) // Size of EEPROM being used for core data storage -#define EECONFIG_BASE_SIZE 37 +#define EECONFIG_BASE_SIZE ((uint8_t)sizeof(eeprom_core_t)) // Size of EEPROM dedicated to keyboard- and user-specific data #ifndef EECONFIG_KB_DATA_SIZE diff --git a/quantum/main.c b/quantum/main.c index 3b101c522c..3159c55850 100644 --- a/quantum/main.c +++ b/quantum/main.c @@ -25,22 +25,9 @@ void protocol_pre_task(void); void protocol_post_task(void); // Bodge as refactoring this area sucks.... -void protocol_init(void) __attribute__((weak)); -void protocol_init(void) { - protocol_pre_init(); - - keyboard_init(); - - protocol_post_init(); -} - -void protocol_task(void) __attribute__((weak)); -void protocol_task(void) { - protocol_pre_task(); - +void protocol_keyboard_task(void) __attribute__((weak)); +void protocol_keyboard_task(void) { keyboard_task(); - - protocol_post_task(); } /** \brief Main @@ -53,11 +40,25 @@ int main(void) { protocol_setup(); keyboard_setup(); - protocol_init(); + protocol_pre_init(); + keyboard_init(); + protocol_post_init(); /* Main loop */ while (true) { - protocol_task(); + protocol_pre_task(); + protocol_keyboard_task(); + protocol_post_task(); + +#ifdef RAW_ENABLE + void raw_hid_task(void); + raw_hid_task(); +#endif + +#ifdef CONSOLE_ENABLE + void console_task(void); + console_task(); +#endif #ifdef QUANTUM_PAINTER_ENABLE // Run Quantum Painter task diff --git a/quantum/pointing_device/pointing_device_auto_mouse.c b/quantum/pointing_device/pointing_device_auto_mouse.c index 1b11fffedb..d9f924e258 100644 --- a/quantum/pointing_device/pointing_device_auto_mouse.c +++ b/quantum/pointing_device/pointing_device_auto_mouse.c @@ -45,7 +45,7 @@ static inline bool layer_hold_check(void) { } /* check all layer activation criteria */ -static inline bool is_auto_mouse_active(void) { +bool is_auto_mouse_active(void) { return auto_mouse_context.status.is_activated || auto_mouse_context.status.mouse_key_tracker || layer_hold_check(); } @@ -99,6 +99,15 @@ bool get_auto_mouse_toggle(void) { } /** + * @brief get key tracker value + * + * @return bool of current layer_toggled state + */ +int8_t get_auto_mouse_key_tracker(void) { + return auto_mouse_context.status.mouse_key_tracker; +} + +/** * @brief Reset auto mouse context * * Clear timers and status @@ -164,6 +173,15 @@ void set_auto_mouse_debounce(uint8_t debounce) { } /** + * @brief Changes the timeout for the mouse auto layer to be disabled + * + * @param key_tracker + */ +void set_auto_mouse_key_tracker(int8_t key_tracker) { + auto_mouse_context.status.mouse_key_tracker = key_tracker; +} + +/** * @brief toggle mouse layer setting * * Change state of local layer_toggled bool meant to track when the mouse layer is toggled on by other means diff --git a/quantum/pointing_device/pointing_device_auto_mouse.h b/quantum/pointing_device/pointing_device_auto_mouse.h index 904f18b68e..a596c065a3 100644 --- a/quantum/pointing_device/pointing_device_auto_mouse.h +++ b/quantum/pointing_device/pointing_device_auto_mouse.h @@ -81,9 +81,11 @@ void set_auto_mouse_timeout(uint16_t timeout); // set l uint16_t get_auto_mouse_timeout(void); // get layer timeout void set_auto_mouse_debounce(uint8_t debounce); // set debounce uint8_t get_auto_mouse_debounce(void); // get debounce +void set_auto_mouse_key_tracker(int8_t key_tracker); // set key tracker +int8_t get_auto_mouse_key_tracker(void); // get key tracker void auto_mouse_layer_off(void); // disable target layer if appropriate (DO NOT USE in layer_state_set stack!!) layer_state_t remove_auto_mouse_layer(layer_state_t state, bool force); // remove auto mouse target layer from state if appropriate (can be forced) - +bool is_auto_mouse_active(void); // check if target layer is active /* ----------For custom pointing device activation----------------------------------------------------------- */ bool auto_mouse_activation(report_mouse_t mouse_report); // handles pointing device trigger conditions for target layer activation (overwritable) |