convert api to structs/unions

This commit is contained in:
Nick Brassel 2024-09-03 19:16:12 +10:00
parent 2c3af2bfa8
commit d9ae8048d9
No known key found for this signature in database
28 changed files with 68 additions and 62 deletions

View File

@ -164,7 +164,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
if (record->event.pressed) {
set_single_persistent_default_layer(MAC_B);
keymap_config.no_gui = 0;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
return false;
case RGB_TOG:

View File

@ -240,9 +240,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
keymap_config.raw = eeconfig_read_keymap();
eeconfig_read_keymap(&keymap_config);
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
return false;
break;

View File

@ -329,9 +329,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
keymap_config.raw = eeconfig_read_keymap();
eeconfig_read_keymap(&keymap_config);
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
return false;
break;

View File

@ -199,9 +199,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
keymap_config.raw = eeconfig_read_keymap();
eeconfig_read_keymap(&keymap_config);
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
return false;
break;

View File

@ -32,7 +32,7 @@ void set_mac_mode_kb(bool macmode) {
* https://github.com/qmk/qmk_firmware/blob/fb4a6ad30ea7a648acd59793ed4a30c3a8d8dc32/quantum/process_keycode/process_magic.c#L80-L81
*/
keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = !macmode;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
void matrix_init_kb(void) {

View File

@ -27,7 +27,7 @@ void set_mac_mode(bool macmode) {
* https://github.com/qmk/qmk_firmware/blob/fb4a6ad30ea7a648acd59793ed4a30c3a8d8dc32/quantum/process_keycode/process_magic.c#L80-L81
*/
keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = !macmode;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
#ifdef DIP_SWITCH_ENABLE

View File

@ -27,7 +27,7 @@ void set_mac_mode(bool macmode) {
* https://github.com/qmk/qmk_firmware/blob/fb4a6ad30ea7a648acd59793ed4a30c3a8d8dc32/quantum/process_keycode/process_magic.c#L80-L81
*/
keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = !macmode;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
#ifdef DIP_SWITCH_ENABLE

View File

@ -317,7 +317,7 @@ bool dip_switch_update_kb(uint8_t index, bool active) {
}
if(active){
keymap_config.no_gui = 0;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
return true;
}

View File

@ -472,9 +472,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
keymap_config.raw = eeconfig_read_keymap();
eeconfig_read_keymap(&keymap_config);
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
return false;
case EXT_PLV:

View File

@ -190,7 +190,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
set_single_persistent_default_layer(MAC_B);
layer_state_set(1<<MAC_B);
keymap_config.no_gui = 0;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
return false;
case RGB_TOG:

View File

@ -163,7 +163,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
if (record->event.pressed) {
set_single_persistent_default_layer(MAC_B);
keymap_config.no_gui = 0;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
return false;
case GU_TOGG:

View File

@ -233,9 +233,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
keymap_config.raw = eeconfig_read_keymap();
eeconfig_read_keymap(&keymap_config);
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
return false;
break;

View File

@ -270,9 +270,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
keymap_config.raw = eeconfig_read_keymap();
eeconfig_read_keymap(&keymap_config);
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
return false;
break;

View File

@ -214,9 +214,9 @@ void plover(keyrecord_t *record) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
keymap_config.raw = eeconfig_read_keymap();
eeconfig_read_keymap(&keymap_config);
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
}

View File

@ -214,9 +214,9 @@ void plover(keyrecord_t *record) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
keymap_config.raw = eeconfig_read_keymap();
eeconfig_read_keymap(&keymap_config);
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
}

View File

@ -214,9 +214,9 @@ void plover(keyrecord_t *record) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
keymap_config.raw = eeconfig_read_keymap();
eeconfig_read_keymap(&keymap_config);
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
}

View File

@ -245,7 +245,7 @@ static void print_eeconfig(void) {
xprintf("eeconfig:\ndefault_layer: %u\n", eeconfig_read_default_layer());
debug_config_t dc;
dc.raw = eeconfig_read_debug();
eeconfig_read_debug(&dc);
xprintf(/* clang-format off */
"debug_config.raw: %02X\n"
@ -262,7 +262,7 @@ static void print_eeconfig(void) {
); /* clang-format on */
keymap_config_t kc;
kc.raw = eeconfig_read_keymap();
eeconfig_read_keymap(&kc);
xprintf(/* clang-format off */
"keymap_config.raw: %02X\n"

View File

@ -258,11 +258,11 @@ void eeconfig_update_user(uint32_t val) {
#endif // (EECONFIG_USER_DATA_SIZE) == 0
#ifdef HAPTIC_ENABLE
uint32_t eeconfig_read_haptic(void) {
return nvm_eeconfig_read_haptic();
void eeconfig_read_haptic(haptic_config_t *haptic_config) {
nvm_eeconfig_read_haptic(haptic_config);
}
void eeconfig_update_haptic(uint32_t val) {
nvm_eeconfig_update_haptic(val);
void eeconfig_update_haptic(const haptic_config_t *haptic_config) {
nvm_eeconfig_update_haptic(haptic_config);
}
#endif // HAPTIC_ENABLE

View File

@ -125,8 +125,9 @@ void eeconfig_update_user(uint32_t val);
#endif // (EECONFIG_USER_DATA_SIZE) == 0
#ifdef HAPTIC_ENABLE
uint32_t eeconfig_read_haptic(void);
void eeconfig_update_haptic(uint32_t val);
typedef union haptic_config_t haptic_config_t;
void eeconfig_read_haptic(haptic_config_t *haptic_config);
void eeconfig_update_haptic(const haptic_config_t *haptic_config);
#endif
bool eeconfig_read_handedness(void);

View File

@ -67,7 +67,7 @@ void haptic_init(void) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
haptic_config.raw = eeconfig_read_haptic();
eeconfig_read_haptic(&haptic_config);
#ifdef HAPTIC_SOLENOID
solenoid_set_dwell(haptic_config.dwell);
#endif
@ -122,13 +122,13 @@ void eeconfig_debug_haptic(void) {
void haptic_enable(void) {
set_haptic_config_enable(true);
dprintf("haptic_config.enable = %u\n", haptic_config.enable);
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
}
void haptic_disable(void) {
set_haptic_config_enable(false);
dprintf("haptic_config.enable = %u\n", haptic_config.enable);
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
}
void haptic_toggle(void) {
@ -137,14 +137,14 @@ void haptic_toggle(void) {
} else {
haptic_enable();
}
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
}
void haptic_feedback_toggle(void) {
haptic_config.feedback++;
if (haptic_config.feedback >= HAPTIC_FEEDBACK_MAX) haptic_config.feedback = KEY_PRESS;
dprintf("haptic_config.feedback = %u\n", !haptic_config.feedback);
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
}
void haptic_buzz_toggle(void) {
@ -225,26 +225,26 @@ void haptic_reset(void) {
haptic_config.dwell = 0;
haptic_config.buzz = 0;
#endif
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
dprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
dprintf("haptic_config.mode = %u\n", haptic_config.mode);
}
void haptic_set_feedback(uint8_t feedback) {
haptic_config.feedback = feedback;
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
dprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
}
void haptic_set_mode(uint8_t mode) {
haptic_config.mode = mode;
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
dprintf("haptic_config.mode = %u\n", haptic_config.mode);
}
void haptic_set_amplitude(uint8_t amp) {
haptic_config.amplitude = amp;
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
dprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude);
#ifdef HAPTIC_DRV2605L
drv2605l_amplitude(amp);
@ -253,13 +253,13 @@ void haptic_set_amplitude(uint8_t amp) {
void haptic_set_buzz(uint8_t buzz) {
haptic_config.buzz = buzz;
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
dprintf("haptic_config.buzz = %u\n", haptic_config.buzz);
}
void haptic_set_dwell(uint8_t dwell) {
haptic_config.dwell = dwell;
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
dprintf("haptic_config.dwell = %u\n", haptic_config.dwell);
}
@ -291,7 +291,7 @@ uint8_t haptic_get_dwell(void) {
void haptic_enable_continuous(void) {
haptic_config.cont = 1;
dprintf("haptic_config.cont = %u\n", haptic_config.cont);
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
#ifdef HAPTIC_DRV2605L
drv2605l_rtp_init();
#endif
@ -300,7 +300,7 @@ void haptic_enable_continuous(void) {
void haptic_disable_continuous(void) {
haptic_config.cont = 0;
dprintf("haptic_config.cont = %u\n", haptic_config.cont);
eeconfig_update_haptic(haptic_config.raw);
eeconfig_update_haptic(&haptic_config);
#ifdef HAPTIC_DRV2605L
drv2605l_write(DRV2605L_REG_MODE, 0x00);
#endif

View File

@ -28,7 +28,7 @@
#endif
/* EEPROM config settings */
typedef union {
typedef union haptic_config_t {
uint32_t raw;
struct {
bool enable : 1;

View File

@ -458,7 +458,7 @@ void keyboard_init(void) {
#endif
#if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
#endif
#ifdef DIP_SWITCH_ENABLE
dip_switch_init();

View File

@ -37,6 +37,10 @@
# include "unicode.h"
#endif
#ifdef HAPTIC_ENABLE
# include "haptic.h"
#endif
bool nvm_eeconfig_is_enabled(void) {
return eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER;
}
@ -164,11 +168,11 @@ void nvm_eeconfig_update_user(uint32_t val) {
#endif // (EECONFIG_USER_DATA_SIZE) == 0
#ifdef HAPTIC_ENABLE
uint32_t nvm_eeconfig_read_haptic(void) {
return eeprom_read_dword(EECONFIG_HAPTIC);
void nvm_eeconfig_read_haptic(haptic_config_t *haptic_config) {
haptic_config->raw = eeprom_read_dword(EECONFIG_HAPTIC);
}
void nvm_eeconfig_update_haptic(uint32_t val) {
eeprom_update_dword(EECONFIG_HAPTIC, val);
void nvm_eeconfig_update_haptic(const haptic_config_t *haptic_config) {
eeprom_update_dword(EECONFIG_HAPTIC, haptic_config->raw);
}
#endif // HAPTIC_ENABLE

View File

@ -74,8 +74,9 @@ void nvm_eeconfig_update_user(uint32_t val);
#endif // (EECONFIG_USER_DATA_SIZE) == 0
#ifdef HAPTIC_ENABLE
uint32_t nvm_eeconfig_read_haptic(void);
void nvm_eeconfig_update_haptic(uint32_t val);
typedef union haptic_config_t haptic_config_t;
void nvm_eeconfig_read_haptic(haptic_config_t *haptic_config);
void nvm_eeconfig_update_haptic(const haptic_config_t *haptic_config);
#endif // HAPTIC_ENABLE
bool nvm_eeconfig_read_handedness(void);

View File

@ -38,7 +38,7 @@ bool autocorrect_is_enabled(void) {
*/
void autocorrect_enable(void) {
keymap_config.autocorrect_enable = true;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
/**
@ -48,7 +48,7 @@ void autocorrect_enable(void) {
void autocorrect_disable(void) {
keymap_config.autocorrect_enable = false;
typo_buffer_size = 0;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
/**
@ -58,7 +58,7 @@ void autocorrect_disable(void) {
void autocorrect_toggle(void) {
keymap_config.autocorrect_enable = !keymap_config.autocorrect_enable;
typo_buffer_size = 0;
eeconfig_update_keymap(keymap_config.raw);
eeconfig_update_keymap(&keymap_config);
}
/**

View File

@ -66,17 +66,17 @@ void clicky_freq_reset(void) {
void clicky_toggle(void) {
audio_config.clicky_enable ^= 1;
eeconfig_update_audio(audio_config.raw);
eeconfig_update_audio(&audio_config);
}
void clicky_on(void) {
audio_config.clicky_enable = 1;
eeconfig_update_audio(audio_config.raw);
eeconfig_update_audio(&audio_config);
}
void clicky_off(void) {
audio_config.clicky_enable = 0;
eeconfig_update_audio(audio_config.raw);
eeconfig_update_audio(&audio_config);
}
bool is_clicky_on(void) {

View File

@ -136,7 +136,7 @@ static void unicode_play_song(uint8_t mode) {
#endif
void unicode_input_mode_init(void) {
unicode_config.raw = eeconfig_read_unicode_mode();
eeconfig_read_unicode_mode(&unicode_config);
#if UNICODE_SELECTED_MODES != -1
# if UNICODE_CYCLE_PERSIST
// Find input_mode in selected modes

View File

@ -863,7 +863,7 @@ void via_qmk_audio_set_value(uint8_t *data) {
}
void via_qmk_audio_save(void) {
eeconfig_update_audio(audio_config.raw);
eeconfig_update_audio(&audio_config);
}
#endif // QMK_AUDIO_ENABLE