@@ -14,8 +14,8 @@ struct key_config default_key_config = {
1414 .switch_magnetic_profile_id = 0 ,
1515 },
1616 .deadzones = {
17- .start_offset = 0 ,
18- .end_offset = 0 ,
17+ .top_offset = 0 ,
18+ .bottom_offset = 0 ,
1919 },
2020 .actuation_distance = 128 ,
2121 .release_distance = 50 ,
@@ -34,9 +34,9 @@ struct key_config default_key_config = {
3434 } }
3535};
3636
37- struct user_config config ;
38-
39- uint8_t is_calibrating ;
37+ struct user_config config = {
38+ . key_configs_length = 1 ,
39+ } ;
4040
4141// store it into a matrix ??
4242// store it into a matrix ??
@@ -57,7 +57,11 @@ void init_config() {
5757
5858 for (uint8_t i = 0 ; i < config .key_configs_length ; i ++ ) {
5959 config .key_configs [i ] = default_key_config ;
60- config .key_configs [i ].layers [0 ].keycodes [0 ] = default_keycode ;
60+ for (uint8_t j = 0 ; j < config .key_configs [i ].layers_length ; j ++ ) {
61+ for (uint8_t k = 0 ; k < config .key_configs [i ].layers [j ].keycodes_length ; k ++ ) {
62+ config .key_configs [i ].layers [j ].keycodes [k ] = default_keycode ;
63+ }
64+ }
6165 }
6266};
6367
@@ -77,17 +81,26 @@ void init_key_states() {
7781};
7882
7983void mlev_set_switch_value (uint8_t adc_channel , uint8_t amux_channel , uint32_t value ) {
80-
84+ for (uint8_t i = 0 ; i < config .key_configs_length ; i ++ ) {
85+ if (config .key_configs [i ].hardware .adc_channel == adc_channel && config .key_configs [i ].hardware .mux_channel == amux_channel ) {
86+ key_states [i ].raw_adc_value = value ;
87+ break ;
88+ }
89+ }
8190};
8291
8392void mlev_init () {
8493 // check config present
8594 // check config validity (version ?)
8695 // calibrate switches
96+
97+ init_config ();
98+ init_key_states ();
8799};
88100
89101void mlev_task () {
90102 // tud_task
91103 // update keys states
92104 // send hid reports
105+
93106};
0 commit comments