mirror of
https://github.com/whowechina/mai_pico.git
synced 2025-01-19 01:34:03 +01:00
Default touch map when update from old version
This commit is contained in:
parent
ccf9fd547d
commit
92e93451f9
Binary file not shown.
@ -6,6 +6,8 @@
|
||||
* Runtime is something to share between files.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "save.h"
|
||||
#include "touch.h"
|
||||
@ -47,6 +49,23 @@ static inline bool in_range(int val, int min, int max)
|
||||
return (val >= min) && (val <= max);
|
||||
}
|
||||
|
||||
static bool touch_map_valid()
|
||||
{
|
||||
uint64_t mask = 0;
|
||||
for (int i = 0; i < sizeof(mai_cfg->alt.touch); i++) {
|
||||
if (mai_cfg->alt.touch[i] < 34) {
|
||||
mask |= 1ULL << mai_cfg->alt.touch[i];
|
||||
}
|
||||
}
|
||||
int keys = 0;
|
||||
for (int i = 0; i < 34; i++) {
|
||||
if (mask & (1ULL << i)) {
|
||||
keys++;
|
||||
}
|
||||
}
|
||||
return keys > 10; // bad data results in low touch key coverage
|
||||
}
|
||||
|
||||
static void config_loaded()
|
||||
{
|
||||
if ((mai_cfg->sense.filter & 0x0f) > 3 ||
|
||||
@ -76,6 +95,12 @@ static void config_loaded()
|
||||
mai_cfg->rgb = default_cfg.rgb;
|
||||
config_changed();
|
||||
}
|
||||
|
||||
if (!touch_map_valid()) {
|
||||
memcpy(mai_cfg->alt.touch, default_cfg.alt.touch,
|
||||
sizeof(mai_cfg->alt.touch));
|
||||
config_changed();
|
||||
}
|
||||
}
|
||||
|
||||
void config_changed()
|
||||
|
Loading…
x
Reference in New Issue
Block a user