Skip to content

Commit 3f32093

Browse files
author
icex2
committed
refact(vigem-iidxio): Use new config api
Summary: Test Plan:
1 parent 35bd596 commit 3f32093

7 files changed

Lines changed: 82 additions & 281 deletions

File tree

Module.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ $(zipdir)/iidx-hwio-x86.zip: \
494494
build/bin/indep-32/vigem-iidxio.exe \
495495
dist/iidx/eamio-icca.xml \
496496
dist/iidx/iidxio-bio2.xml \
497-
dist/iidx/vigem-iidxio.conf \
497+
dist/iidx/vigem-iidxio.xml \
498498
| $(zipdir)/
499499
$(V)echo ... $@
500500
$(V)zip -j $@ $^
@@ -508,7 +508,7 @@ $(zipdir)/iidx-hwio-x64.zip: \
508508
build/bin/indep-64/vigem-iidxio.exe \
509509
dist/iidx/eamio-icca.xml \
510510
dist/iidx/iidxio-bio2.xml \
511-
dist/iidx/vigem-iidxio.conf \
511+
dist/iidx/vigem-iidxio.xml \
512512
| $(zipdir)/
513513
$(V)echo ... $@
514514
$(V)zip -j $@ $^

dist/iidx/vigem-iidxio.conf

Lines changed: 0 additions & 26 deletions
This file was deleted.

dist/iidx/vigem-iidxio.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="Shift-JIS"?>
2+
<vigem-iidxio>
3+
<tt>
4+
<analog>
5+
<!-- Use relative mode analog mapping instead of absolute analog values -->
6+
<relative __type="bool">0</relative>
7+
<!-- Sensitivity value for relative mode (1 to 32767). Tweak if you are having issues with jittering/misfiring/unresponsiveness -->
8+
<relative_sensitivity __type="s32">1024</relative_sensitivity>
9+
</analog>
10+
<button>
11+
<!-- Button turntable: "debounce" value (1 to 50, recommend 20). Tweak if you are having issues with TT button misfiring/unresponsiveness -->
12+
<debounce __type="s32">20</debounce>
13+
<!-- 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 -->
14+
<threshold __type="s32">2</threshold>
15+
</button>
16+
<!-- Print verbose debug output to the console for debugging turntable sensitivity issues -->
17+
<debug_output __type="bool">0</debug_output>
18+
</tt>
19+
<cab_light>
20+
<!-- Enable input based key lighting -->
21+
<enable_keylight __type="bool">1</enable_keylight>
22+
<!-- Different cabinet light modes: 0 = off, 1 = neons sequence, 2 = neons flash on TT spin -->
23+
<light_mode __type="s32">0</light_mode>
24+
<!-- Display text on 16seg. If text exceeds 9 char display limit, it will scroll + cycle -->
25+
<text_16seg __type="str"></text_16seg>
26+
<!-- Cycle time/scroll speed for text exceeding 16seg display length (9) to scroll from right -->
27+
<text_scroll_cycle_time_ms __type="s32">500</text_scroll_cycle_time_ms>
28+
</cab_light>
29+
</vigem-iidxio>

src/main/vigem-iidxio/Module.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ cppflags_vigem-iidxio := \
88

99
ldflags_vigem-iidxio := \
1010
-lsetupapi \
11+
-lws2_32 \
1112

1213
libs_vigem-iidxio := \
1314
core \
14-
cconfig \
15-
util \
1615
vigemstub \
1716
module \
1817
ezusb \
1918
iface \
2019
iface-io \
2120
iface-core \
21+
security \
22+
util \
2223

2324
src_vigem-iidxio := \
2425
cab-16seg-sequencer.c \
2526
cab-light-sequencer.c \
26-
main.c \
2727
config.c \
28+
main.c \

src/main/vigem-iidxio/config.c

Lines changed: 12 additions & 239 deletions
Original file line numberDiff line numberDiff line change
@@ -1,243 +1,16 @@
1-
#include "cconfig/cconfig-main.h"
2-
#include "cconfig/cconfig-util.h"
3-
4-
#include "iface-core/log.h"
1+
#include "core/config-ext.h"
52

63
#include "vigem-iidxio/config.h"
74

8-
#define VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_KEY \
9-
"vigem.iidxio.tt.anlog.relative"
10-
#define VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_SENSITIVITY_KEY \
11-
"vigem.iidxio.tt.anlog.relative_sensitivity"
12-
#define VIGEM_IIDXIO_CONFIG_TT_BUTTON_DEBOUNCE_KEY \
13-
"vigem.iidxio.tt.button.debounce"
14-
#define VIGEM_IIDXIO_CONFIG_TT_BUTTON_THRESHOLD_KEY \
15-
"vigem.iidxio.tt.button.threshold"
16-
#define VIGEM_IIDXIO_CONFIG_TT_DEBUG_OUTPUT_KEY "vigem.iidxio.tt.debug_output"
17-
#define VIGEM_IIDXIO_CONFIG_CAB_LIGHT_ENABLE_KEYLIGHT_KEY \
18-
"vigem.iidxio.cab_light.enable_keylight"
19-
#define VIGEM_IIDXIO_CONFIG_CAB_LIGHT_LIGHT_MODE_KEY \
20-
"vigem.iidxio.cab_light.light_mode"
21-
#define VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_16SEG_KEY \
22-
"vigem.iidxio.cab_light.text_16seg"
23-
#define VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_KEY \
24-
"vigem.iidxio.cab_light.text_scroll_cycle_time_ms"
25-
26-
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_VALUE false
27-
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_SENSITIVITY_VALUE 1024
28-
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_DEBOUNCE_VALUE 20
29-
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_THRESHOLD_VALUE 2
30-
#define VIGEM_IIDXIO_CONFIG_DEFAULT_TT_DEBUG_OUTPUT_VALUE false
31-
#define VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_ENABLE_KEYLIGHT_VALUE true
32-
#define VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_LIGHT_MODE_VALUE 0
33-
#define VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_16SEG_VALUE ""
34-
#define VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE \
35-
500
36-
37-
static void _vigem_iidxio_config_init(struct cconfig *config)
5+
void vigem_iidxio_config_get(const bt_core_config_t *config, vigem_iidxio_config_t *config_out)
386
{
39-
cconfig_util_set_bool(
40-
config,
41-
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_KEY,
42-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_VALUE,
43-
"Use relative mode analog mapping instead of absolute analog values");
44-
45-
cconfig_util_set_int(
46-
config,
47-
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_SENSITIVITY_KEY,
48-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_SENSITIVITY_VALUE,
49-
"Sensitivity value for relative mode (1 to 32767). Tweak if you are "
50-
"having issues with "
51-
"jittering/misfiring/unresponsiveness");
52-
53-
cconfig_util_set_int(
54-
config,
55-
VIGEM_IIDXIO_CONFIG_TT_BUTTON_DEBOUNCE_KEY,
56-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_DEBOUNCE_VALUE,
57-
"Button turntable: \"debounce\" value (1 to 50, recommend 20). Tweak "
58-
"if you are having "
59-
"issues with TT button misfiring/unresponsiveness");
60-
61-
cconfig_util_set_int(
62-
config,
63-
VIGEM_IIDXIO_CONFIG_TT_BUTTON_THRESHOLD_KEY,
64-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_THRESHOLD_VALUE,
65-
"Button turntable: minimum ticks required within (debounce * 2) ms to "
66-
"register movement "
67-
"(1 to 4, recommend 2). Tweak if you button input is too (un-) "
68-
"responsive");
69-
70-
cconfig_util_set_bool(
71-
config,
72-
VIGEM_IIDXIO_CONFIG_TT_DEBUG_OUTPUT_KEY,
73-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_DEBUG_OUTPUT_VALUE,
74-
"Print verbose debug output to the console for debugging turntable "
75-
"sensitivity issues");
76-
77-
cconfig_util_set_bool(
78-
config,
79-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_ENABLE_KEYLIGHT_KEY,
80-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_ENABLE_KEYLIGHT_VALUE,
81-
"Enable input based key lighting");
82-
83-
cconfig_util_set_int(
84-
config,
85-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_LIGHT_MODE_KEY,
86-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_LIGHT_MODE_VALUE,
87-
"Different cabinet light modes: 0 = off, 1 = neons sequence, 2 = neons "
88-
"flash on TT spin");
89-
90-
cconfig_util_set_str(
91-
config,
92-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_16SEG_KEY,
93-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_16SEG_VALUE,
94-
"Display text on 16seg. If text exceeds 9 char display limit, it will "
95-
"scroll + cycle");
96-
97-
cconfig_util_set_int(
98-
config,
99-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_KEY,
100-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE,
101-
"Cycle time/scroll speed for text exceeding 16seg display length (9) "
102-
"to scroll from right");
103-
}
104-
105-
static void _vigem_iidxio_config_get(
106-
struct vigem_iidxio_config *vigem_config, struct cconfig *config)
107-
{
108-
if (!cconfig_util_get_bool(
109-
config,
110-
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_KEY,
111-
&vigem_config->tt.analog.relative,
112-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_VALUE)) {
113-
log_warning(
114-
"Invalid value for key '%s' specified, fallback "
115-
"to default '%d'",
116-
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_KEY,
117-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_VALUE);
118-
}
119-
120-
if (!cconfig_util_get_int(
121-
config,
122-
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_SENSITIVITY_KEY,
123-
&vigem_config->tt.analog.relative_sensitivity,
124-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_SENSITIVITY_VALUE)) {
125-
log_warning(
126-
"Invalid value for key '%s' specified, fallback "
127-
"to default '%d'",
128-
VIGEM_IIDXIO_CONFIG_TT_ANALOG_RELATIVE_SENSITIVITY_KEY,
129-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_ANALOG_RELATIVE_SENSITIVITY_VALUE);
130-
}
131-
132-
if (!cconfig_util_get_int(
133-
config,
134-
VIGEM_IIDXIO_CONFIG_TT_BUTTON_DEBOUNCE_KEY,
135-
&vigem_config->tt.button.debounce,
136-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_DEBOUNCE_VALUE)) {
137-
log_warning(
138-
"Invalid value for key '%s' specified, fallback "
139-
"to default '%d'",
140-
VIGEM_IIDXIO_CONFIG_TT_BUTTON_DEBOUNCE_KEY,
141-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_DEBOUNCE_VALUE);
142-
}
143-
144-
if (!cconfig_util_get_int(
145-
config,
146-
VIGEM_IIDXIO_CONFIG_TT_BUTTON_THRESHOLD_KEY,
147-
&vigem_config->tt.button.threshold,
148-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_THRESHOLD_VALUE)) {
149-
log_warning(
150-
"Invalid value for key '%s' specified, fallback "
151-
"to default '%d'",
152-
VIGEM_IIDXIO_CONFIG_TT_BUTTON_THRESHOLD_KEY,
153-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_BUTTON_THRESHOLD_VALUE);
154-
}
155-
156-
if (!cconfig_util_get_bool(
157-
config,
158-
VIGEM_IIDXIO_CONFIG_TT_DEBUG_OUTPUT_KEY,
159-
&vigem_config->tt.debug_output,
160-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_DEBUG_OUTPUT_VALUE)) {
161-
log_warning(
162-
"Invalid value for key '%s' specified, fallback "
163-
"to default '%d'",
164-
VIGEM_IIDXIO_CONFIG_TT_DEBUG_OUTPUT_KEY,
165-
VIGEM_IIDXIO_CONFIG_DEFAULT_TT_DEBUG_OUTPUT_VALUE);
166-
}
167-
168-
if (!cconfig_util_get_bool(
169-
config,
170-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_ENABLE_KEYLIGHT_KEY,
171-
&vigem_config->cab_light.enable_keylight,
172-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_ENABLE_KEYLIGHT_VALUE)) {
173-
log_warning(
174-
"Invalid value for key '%s' specified, fallback "
175-
"to default '%d'",
176-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_ENABLE_KEYLIGHT_KEY,
177-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_ENABLE_KEYLIGHT_VALUE);
178-
}
179-
180-
if (!cconfig_util_get_int(
181-
config,
182-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_LIGHT_MODE_KEY,
183-
&vigem_config->cab_light.light_mode,
184-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_LIGHT_MODE_VALUE)) {
185-
log_warning(
186-
"Invalid value for key '%s' specified, fallback "
187-
"to default '%d'",
188-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_LIGHT_MODE_KEY,
189-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_LIGHT_MODE_VALUE);
190-
}
191-
192-
if (!cconfig_util_get_str(
193-
config,
194-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_16SEG_KEY,
195-
vigem_config->cab_light.text_16seg,
196-
sizeof(vigem_config->cab_light.text_16seg),
197-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_16SEG_VALUE)) {
198-
log_warning(
199-
"Invalid value for key '%s' specified, fallback "
200-
"to default '%s'",
201-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_16SEG_KEY,
202-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_16SEG_VALUE);
203-
}
204-
205-
if (!cconfig_util_get_int(
206-
config,
207-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_KEY,
208-
&vigem_config->cab_light.text_scroll_cycle_time_ms,
209-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE)) {
210-
log_warning(
211-
"Invalid value for key '%s' specified, fallback "
212-
"to default '%d'",
213-
VIGEM_IIDXIO_CONFIG_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_KEY,
214-
VIGEM_IIDXIO_CONFIG_DEFAULT_CAB_LIGHT_TEXT_SCROLL_CYCLE_TIME_MS_VALUE);
215-
}
216-
}
217-
218-
bool vigem_iidxio_config_get(struct vigem_iidxio_config *config_out)
219-
{
220-
struct cconfig *config;
221-
222-
config = cconfig_init();
223-
224-
_vigem_iidxio_config_init(config);
225-
226-
if (!cconfig_main_config_init(
227-
config,
228-
"--config",
229-
"vigem-iidxio.conf",
230-
"--help",
231-
"-h",
232-
"vigem-iidxio",
233-
CCONFIG_CMD_USAGE_OUT_STDOUT)) {
234-
cconfig_finit(config);
235-
return false;
236-
}
237-
238-
_vigem_iidxio_config_get(config_out, config);
239-
240-
cconfig_finit(config);
241-
242-
return true;
243-
}
7+
bt_core_config_ext_bool_get(config, "tt/anlog/relative", &config_out->tt.analog.relative);
8+
bt_core_config_ext_s32_get(config, "tt/anlog/relative_sensitivity", &config_out->tt.analog.relative_sensitivity);
9+
bt_core_config_ext_s32_get(config, "tt/button/debounce", &config_out->tt.button.debounce);
10+
bt_core_config_ext_s32_get(config, "tt/button/threshold", &config_out->tt.button.threshold);
11+
bt_core_config_ext_bool_get(config, "tt/debug_output", &config_out->tt.debug_output);
12+
bt_core_config_ext_bool_get(config, "cab_light/enable_keylight", &config_out->cab_light.enable_keylight);
13+
bt_core_config_ext_s32_get(config, "cab_light/light_mode", &config_out->cab_light.light_mode);
14+
bt_core_config_ext_str_get(config, "cab_light/text_16seg", config_out->cab_light.text_16seg, sizeof(config_out->cab_light.text_16seg));
15+
bt_core_config_ext_s32_get(config, "cab_light/text_scroll_cycle_time_ms", &config_out->cab_light.text_scroll_cycle_time_ms);
16+
}

src/main/vigem-iidxio/config.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#ifndef VIGEM_IIDXIO_CONFIG_H
22
#define VIGEM_IIDXIO_CONFIG_H
33

4-
#include <windows.h>
4+
#include <stdbool.h>
5+
#include <stdint.h>
56

6-
#include "cconfig/cconfig.h"
7+
#include "api/core/config.h"
78

8-
struct vigem_iidxio_config {
9+
typedef struct vigem_iidxio_config {
910
struct tt {
1011
struct analog {
1112
bool relative;
@@ -26,8 +27,8 @@ struct vigem_iidxio_config {
2627
char text_16seg[1024 + 1];
2728
int32_t text_scroll_cycle_time_ms;
2829
} cab_light;
29-
};
30+
} vigem_iidxio_config_t;
3031

31-
bool vigem_iidxio_config_get(struct vigem_iidxio_config *config_out);
32+
void vigem_iidxio_config_get(const bt_core_config_t *config, vigem_iidxio_config_t *config_out);
3233

3334
#endif

0 commit comments

Comments
 (0)