1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2024-11-24 14:50:10 +01:00

vigem-iidxio: Refactor configuration

Add more properties from Grim's implementation to support the
additional features. Re-structure struct to be less repetitive
on variable names.
This commit is contained in:
icex2 2020-12-31 15:55:56 +01:00
parent 9a5418f6a3
commit 78e7c05876
2 changed files with 156 additions and 57 deletions

View File

@ -5,48 +5,83 @@
#include "util/log.h"
#define VIGEM_IIDXIO_CONFIG_ENABLE_KEYLIGHT_KEY "vigem.iidxio.enable_keylight"
#define VIGEM_IIDXIO_CONFIG_RELATIVE_ANALOG_KEY "vigem.iidxio.use_relative_analog"
#define VIGEM_IIDXIO_CONFIG_ENABLE_CAB_LIGHT_MODE_KEY "vigem.iidxio.cab_light_mode"
#define VIGEM_IIDXIO_CONFIG_TEXT_16SEG_KEY "vigem.iidxio.text_16seg"
#define VIGEM_IIDXIO_CONFIG_TEXT_SCROLL_CYCLE_TIME_MS_KEY "vigem.iidxio.text_scroll_cycle_time_ms"
#define VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_KEY "vigem.iidxio.tt.anlog.relative"
#define VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_SENSITIVITY_KEY "vigem.iidxio.tt.anlog.relative_sensitivity"
#define VIGEM_IIDXIO_CONFIG_TT_BUTTON_DEBOUNCE_KEY "vigem.iidxio.tt.button.debounce"
#define VIGEM_IIDXIO_CONFIG_TT_BUTTON_THRESHOLD_KEY "vigem.iidxio.tt.button.threshold"
#define VIGEM_IIDXIO_CONFIG_TT_DEBUG_OUTPUT_KEY "vigem.iidxio.tt.debug_output"
#define VIGEM_IIDXIO_CONFIG_CAB_LIGHT_ENABLE_KEYLIGHT_KEY "vigem.iidxio.cab_light.enable_keylight"
#define VIGEM_IIDXIO_CONFIG_CAB_LIGHT_LIGHT_MODE_KEY "vigem.iidxio.cab_light.light_mode"
#define VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_16SEG_KEY "vigem.iidxio.cab_light.text_16seg"
#define VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_KEY "vigem.iidxio.cab_light.text_scroll_cycle_time_ms"
#define VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_KEYLIGHT_VALUE true
#define VIGEM_IIDXIO_CONFIG_DEFAULT_RELATIVE_ANALOG_VALUE false
#define VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_MODE_VALUE 0
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TEXT_16SEG_VALUE ""
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE 500
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_VALUE false
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_SENSITIVITY_VALUE 1024
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_DEBOUNCE_VALUE 20
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_THRESHOLD_VALUE 2
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TT_DEBUG_OUTPUT_VALUE false
#define VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_ENABLE_KEYLIGHT_VALUE true
#define VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_LIGHT_MODE_VALUE 0
#define VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_16SEG_VALUE ""
#define VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE 500
static void _vigem_iidxio_config_init(struct cconfig *config)
{
cconfig_util_set_bool(
config,
VIGEM_IIDXIO_CONFIG_ENABLE_KEYLIGHT_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_KEYLIGHT_VALUE,
"Enable input based key lighting");
cconfig_util_set_bool(
config,
VIGEM_IIDXIO_CONFIG_RELATIVE_ANALOG_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_RELATIVE_ANALOG_VALUE,
"Use relative mode analog mapping");
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_VALUE,
"Use relative mode analog mapping instead of absolute analog values");
cconfig_util_set_int(
config,
VIGEM_IIDXIO_CONFIG_ENABLE_CAB_LIGHT_MODE_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_MODE_VALUE,
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_SENSITIVITY_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_SENSITIVITY_VALUE,
"Sensitivity value for relative mode (1 to 32767). Tweak if you are having issues with "
"jittering/misfiring/unresponsiveness");
cconfig_util_set_int(
config,
VIGEM_IIDXIO_CONFIG_TT_BUTTON_DEBOUNCE_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_DEBOUNCE_VALUE,
"Button turntable: \"debounce\" value (1 to 50, recommend 20). Tweak if you are having "\
"issues with TT button misfiring/unresponsiveness");
cconfig_util_set_int(
config,
VIGEM_IIDXIO_CONFIG_TT_BUTTON_THRESHOLD_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_THRESHOLD_VALUE,
"Button turntable: minimum ticks required within (debounce * 2) ms to register movement "
"(1 to 4, recommend 2). Tweak if you button input is too (un-) responsive");
cconfig_util_set_bool(
config,
VIGEM_IIDXIO_CONFIG_TT_DEBUG_OUTPUT_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_DEBUG_OUTPUT_VALUE,
"Print verbose debug output to the console for debugging turntable sensitivity issues");
cconfig_util_set_bool(
config,
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_ENABLE_KEYLIGHT_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_ENABLE_KEYLIGHT_VALUE,
"Enable input based key lighting");
cconfig_util_set_int(
config,
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_LIGHT_MODE_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_LIGHT_MODE_VALUE,
"Different cabinet light modes: 0 = off, 1 = neons sequence, 2 = neons flash on TT spin");
cconfig_util_set_str(
config,
VIGEM_IIDXIO_CONFIG_TEXT_16SEG_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TEXT_16SEG_VALUE,
"Display text on 16seg. If text exceeds 9 char display limit, it will scroll");
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_16SEG_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_16SEG_VALUE,
"Display text on 16seg. If text exceeds 9 char display limit, it will scroll + cycle");
cconfig_util_set_int(
config,
VIGEM_IIDXIO_CONFIG_TEXT_SCROLL_CYCLE_TIME_MS_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE,
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE,
"Cycle time/scroll speed for text exceeding 16seg display length (9) to scroll from right");
}
@ -55,63 +90,112 @@ static void _vigem_iidxio_config_get(
{
if (!cconfig_util_get_bool(
config,
VIGEM_IIDXIO_CONFIG_ENABLE_KEYLIGHT_KEY,
&vigem_config->enable_keylight,
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_KEYLIGHT_VALUE)) {
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_KEY,
&vigem_config->tt.analog.relative,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
VIGEM_IIDXIO_CONFIG_ENABLE_KEYLIGHT_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_KEYLIGHT_VALUE);
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_VALUE);
}
if (!cconfig_util_get_int(
config,
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_SENSITIVITY_KEY,
&vigem_config->tt.analog.relative_sensitivity,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_SENSITIVITY_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_SENSITIVITY_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_SENSITIVITY_VALUE);
}
if (!cconfig_util_get_int(
config,
VIGEM_IIDXIO_CONFIG_TT_BUTTON_DEBOUNCE_KEY,
&vigem_config->tt.button.debounce,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_DEBOUNCE_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
VIGEM_IIDXIO_CONFIG_TT_BUTTON_DEBOUNCE_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_DEBOUNCE_VALUE);
}
if (!cconfig_util_get_int(
config,
VIGEM_IIDXIO_CONFIG_TT_BUTTON_THRESHOLD_KEY,
&vigem_config->tt.button.threshold,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_THRESHOLD_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
VIGEM_IIDXIO_CONFIG_TT_BUTTON_THRESHOLD_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_THRESHOLD_VALUE);
}
if (!cconfig_util_get_bool(
config,
VIGEM_IIDXIO_CONFIG_RELATIVE_ANALOG_KEY,
&vigem_config->relative_analog,
VIGEM_IIDXIO_CONFIG_DEFAULT_RELATIVE_ANALOG_VALUE)) {
VIGEM_IIDXIO_CONFIG_TT_DEBUG_OUTPUT_KEY,
&vigem_config->tt.debug_output,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_DEBUG_OUTPUT_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
VIGEM_IIDXIO_CONFIG_RELATIVE_ANALOG_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_RELATIVE_ANALOG_VALUE);
VIGEM_IIDXIO_CONFIG_TT_DEBUG_OUTPUT_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_DEBUG_OUTPUT_VALUE);
}
if (!cconfig_util_get_bool(
config,
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_ENABLE_KEYLIGHT_KEY,
&vigem_config->cab_light.enable_keylight,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_ENABLE_KEYLIGHT_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_ENABLE_KEYLIGHT_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_ENABLE_KEYLIGHT_VALUE);
}
if (!cconfig_util_get_int(
config,
VIGEM_IIDXIO_CONFIG_ENABLE_CAB_LIGHT_MODE_KEY,
&vigem_config->cab_light_mode,
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_MODE_VALUE)) {
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_LIGHT_MODE_KEY,
&vigem_config->cab_light.light_mode,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_LIGHT_MODE_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
VIGEM_IIDXIO_CONFIG_ENABLE_CAB_LIGHT_MODE_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_MODE_VALUE);
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_LIGHT_MODE_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_LIGHT_MODE_VALUE);
}
if (!cconfig_util_get_str(
config,
VIGEM_IIDXIO_CONFIG_TEXT_16SEG_KEY,
vigem_config->text_16seg,
sizeof(vigem_config->text_16seg),
VIGEM_IIDXIO_CONFIG_DEFAULT_TEXT_16SEG_VALUE)) {
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_16SEG_KEY,
vigem_config->cab_light.text_16seg,
sizeof(vigem_config->cab_light.text_16seg),
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_16SEG_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
VIGEM_IIDXIO_CONFIG_TEXT_16SEG_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TEXT_16SEG_VALUE);
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_16SEG_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_16SEG_VALUE);
}
if (!cconfig_util_get_int(
config,
VIGEM_IIDXIO_CONFIG_TEXT_SCROLL_CYCLE_TIME_MS_KEY,
&vigem_config->text_scroll_cycle_time_ms,
VIGEM_IIDXIO_CONFIG_DEFAULT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE)) {
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_KEY,
&vigem_config->cab_light.text_scroll_cycle_time_ms,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
VIGEM_IIDXIO_CONFIG_TEXT_SCROLL_CYCLE_TIME_MS_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE);
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_KEY,
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE);
}
}

View File

@ -6,11 +6,26 @@
#include "cconfig/cconfig.h"
struct vigem_iidxio_config {
bool enable_keylight;
bool relative_analog;
int32_t cab_light_mode;
char text_16seg[1024 + 1];
int32_t text_scroll_cycle_time_ms;
struct tt {
struct analog {
bool relative;
int32_t relative_sensitivity;
} analog;
struct button {
int32_t debounce;
int32_t threshold;
} button;
bool debug_output;
} tt;
struct cab_light {
bool enable_keylight;
int32_t light_mode;
char text_16seg[1024 + 1];
int32_t text_scroll_cycle_time_ms;
} cab_light;
};
bool vigem_iidxio_config_get(struct vigem_iidxio_config *config_out);