1
0
mirror of https://github.com/whowechina/iidx_pico.git synced 2025-02-20 04:21:01 +01:00

Remove deadzone setting

This commit is contained in:
whowechina 2024-12-19 09:36:23 +08:00
parent 9806b9906f
commit 2dcff302be
3 changed files with 706 additions and 720 deletions

View File

@ -1,74 +1,69 @@
/*
* Controller Config Data
* WHowe <github.com/whowechina>
*
* Config is a global data structure that stores all the configuration
*/
#include "config.h"
#include "save.h"
iidx_cfg_t *iidx_cfg;
static iidx_cfg_t default_cfg = {
.key_off = { {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}},
.key_on = { {40,40,40}, {40,40,40}, {40,40,40}, {40,40,40}, {40,40,40}, {40,40,40},
{40,40,40}, {40,40,40}, {40,40,40}, {40,40,40}, {40,40,40},
},
.tt_led = {
.start = 0,
.num = 24,
.effect = 0,
.param = 0,
.mode = 0,
},
.tt_sensor = {
.reversed = false,
.deadzone = 1,
.ppr = 1,
},
.level = 128,
.konami = false,
};
static void config_loaded()
{
if (iidx_cfg->tt_led.num == 0) {
iidx_cfg->tt_led.num = 24;
config_changed();
}
if ((iidx_cfg->tt_led.start > 8) ||
(iidx_cfg->tt_led.start + iidx_cfg->tt_led.num > 128)) {
iidx_cfg->tt_led.start = 0;
iidx_cfg->tt_led.num = 24;
config_changed();
}
if (iidx_cfg->tt_sensor.deadzone > 2) {
iidx_cfg->tt_sensor.deadzone = 0;
config_changed();
}
if (iidx_cfg->tt_led.mode > 2) {
iidx_cfg->tt_led.mode = 0;
config_changed();
}
if (iidx_cfg->tt_sensor.ppr > 3) {
iidx_cfg->tt_sensor.ppr = 1;
config_changed();
}
}
void config_changed()
{
save_request(false);
}
void config_factory_reset()
{
*iidx_cfg = default_cfg;
save_request(true);
}
void config_init()
{
iidx_cfg = (iidx_cfg_t *)save_alloc(sizeof(*iidx_cfg), &default_cfg, config_loaded);
}
/*
* Controller Config Data
* WHowe <github.com/whowechina>
*
* Config is a global data structure that stores all the configuration
*/
#include "config.h"
#include "save.h"
iidx_cfg_t *iidx_cfg;
static iidx_cfg_t default_cfg = {
.key_off = { {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}},
.key_on = { {40,40,40}, {40,40,40}, {40,40,40}, {40,40,40}, {40,40,40}, {40,40,40},
{40,40,40}, {40,40,40}, {40,40,40}, {40,40,40}, {40,40,40},
},
.tt_led = {
.start = 0,
.num = 24,
.effect = 0,
.param = 0,
.mode = 0,
},
.tt_sensor = {
.reversed = false,
.ppr = 1,
},
.level = 128,
.konami = false,
};
static void config_loaded()
{
if (iidx_cfg->tt_led.num == 0) {
iidx_cfg->tt_led.num = 24;
config_changed();
}
if ((iidx_cfg->tt_led.start > 8) ||
(iidx_cfg->tt_led.start + iidx_cfg->tt_led.num > 128)) {
iidx_cfg->tt_led.start = 0;
iidx_cfg->tt_led.num = 24;
config_changed();
}
if (iidx_cfg->tt_led.mode > 2) {
iidx_cfg->tt_led.mode = 0;
config_changed();
}
if (iidx_cfg->tt_sensor.ppr > 3) {
iidx_cfg->tt_sensor.ppr = 1;
config_changed();
}
}
void config_changed()
{
save_request(false);
}
void config_factory_reset()
{
*iidx_cfg = default_cfg;
save_request(true);
}
void config_init()
{
iidx_cfg = (iidx_cfg_t *)save_alloc(sizeof(*iidx_cfg), &default_cfg, config_loaded);
}

View File

@ -1,43 +1,43 @@
/*
* Controller Config
* WHowe <github.com/whowechina>
*/
#ifndef CONFIG_H
#define CONFIG_H
#include <stdint.h>
#include <stdbool.h>
typedef struct __attribute ((packed)) {
uint8_t h; // hue;
uint8_t s; // saturation;
uint8_t v; // value;
} hsv_t;
typedef struct __attribute ((packed)) {
hsv_t key_off[11];
hsv_t key_on[11];
struct {
uint8_t start;
uint8_t num;
uint8_t effect;
uint8_t param;
uint8_t mode; /* 0: on, 1: reversed, 2: off */
} tt_led;
struct {
bool reversed;
uint8_t deadzone; /* only for analog */
uint8_t ppr; /* 0: 256, 1: 128, 2: 96, 3: 64, other: 256 */
} tt_sensor;
uint8_t level; /* led brightness limit */
bool konami; /* konami spoof */
} iidx_cfg_t;
extern iidx_cfg_t *iidx_cfg;
void config_init();
void config_changed(); // Notify the config has changed
void config_factory_reset(); // Reset the config to factory default
#endif
/*
* Controller Config
* WHowe <github.com/whowechina>
*/
#ifndef CONFIG_H
#define CONFIG_H
#include <stdint.h>
#include <stdbool.h>
typedef struct __attribute ((packed)) {
uint8_t h; // hue;
uint8_t s; // saturation;
uint8_t v; // value;
} hsv_t;
typedef struct __attribute ((packed)) {
hsv_t key_off[11];
hsv_t key_on[11];
struct {
uint8_t start;
uint8_t num;
uint8_t effect;
uint8_t param;
uint8_t mode; /* 0: on, 1: reversed, 2: off */
} tt_led;
struct {
bool reversed;
uint8_t ppr; /* 0: 256, 1: 128, 2: 96, 3: 64, other: 256 */
uint8_t reserved;
} tt_sensor;
uint8_t level; /* led brightness limit */
bool konami; /* konami spoof */
} iidx_cfg_t;
extern iidx_cfg_t *iidx_cfg;
void config_init();
void config_changed(); // Notify the config has changed
void config_factory_reset(); // Reset the config to factory default
#endif

File diff suppressed because it is too large Load Diff