mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Input Settings: Add Vibro Trigger option
by 956MB & WillyJL
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
#include "input_settings.h"
|
||||
#include "input_settings_filename.h"
|
||||
#include "input.h"
|
||||
|
||||
#include <saved_struct.h>
|
||||
#include <storage/storage.h>
|
||||
|
||||
#define TAG "InputSettings"
|
||||
|
||||
#define INPUT_SETTINGS_VER (1) // version nnumber
|
||||
#define INPUT_SETTINGS_VER (2) // version number
|
||||
|
||||
#define INPUT_SETTINGS_PATH INT_PATH(INPUT_SETTINGS_FILE_NAME)
|
||||
#define INPUT_SETTINGS_MAGIC (0x29)
|
||||
|
||||
#define INPUT_SETTINGS_VIBRO_TOUCH_TRIGGER_MASK_DEFAULT \
|
||||
((1 << InputTypePress) | (1 << InputTypeRelease))
|
||||
|
||||
void input_settings_load(InputSettings* settings) {
|
||||
furi_assert(settings);
|
||||
|
||||
@@ -22,6 +26,18 @@ void input_settings_load(InputSettings* settings) {
|
||||
uint8_t version;
|
||||
if(!saved_struct_get_metadata(INPUT_SETTINGS_PATH, NULL, &version, NULL)) break;
|
||||
|
||||
if(version == 1) {
|
||||
struct {
|
||||
uint8_t vibro_touch_level;
|
||||
} v1;
|
||||
if(!saved_struct_load(INPUT_SETTINGS_PATH, &v1, sizeof(v1), INPUT_SETTINGS_MAGIC, 1))
|
||||
break;
|
||||
settings->vibro_touch_level = v1.vibro_touch_level;
|
||||
settings->vibro_touch_trigger_mask = INPUT_SETTINGS_VIBRO_TOUCH_TRIGGER_MASK_DEFAULT;
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// if config actual version - load it directly
|
||||
if(version == INPUT_SETTINGS_VER) {
|
||||
success = saved_struct_load(
|
||||
@@ -38,7 +54,8 @@ void input_settings_load(InputSettings* settings) {
|
||||
if(!success) {
|
||||
FURI_LOG_W(TAG, "Failed to load file, using defaults");
|
||||
memset(settings, 0, sizeof(InputSettings));
|
||||
input_settings_save(settings);
|
||||
settings->vibro_touch_trigger_mask = INPUT_SETTINGS_VIBRO_TOUCH_TRIGGER_MASK_DEFAULT;
|
||||
// input_settings_save(settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user