mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2025-02-20 20:41:10 +01:00
vigem-iidxio: Support multiple different light sequence modes
Add new one suggested and implemented by Grim to flash the neons when spinning the turntables
This commit is contained in:
parent
edbbe5ae67
commit
2363498f73
@ -3,36 +3,22 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "vigem-iidxio/cab-light-sequencer.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/time.h"
|
||||
|
||||
static const uint32_t _SEQ_CYCLE_TIME_MS = 2000;
|
||||
|
||||
static bool _enabled;
|
||||
static enum vigem_iidxio_cab_light_sequencer_mode _light_seq_mode;
|
||||
|
||||
static bool _first_update;
|
||||
static uint64_t _time_counter;
|
||||
|
||||
void vigem_iidxio_cab_light_sequencer_init()
|
||||
static uint8_t _tt_prev[2];
|
||||
|
||||
void _update_neons_seq_flash(bool* out_neon)
|
||||
{
|
||||
_time_counter = time_get_counter();
|
||||
_enabled = true;
|
||||
|
||||
if (_enabled) {
|
||||
log_info("Initialized");
|
||||
}
|
||||
}
|
||||
|
||||
void vigem_iidxio_cab_light_sequencer_update(bool* out_neon, uint8_t* out_spots)
|
||||
{
|
||||
log_assert(out_neon);
|
||||
log_assert(out_spots);
|
||||
|
||||
if (!_enabled) {
|
||||
*out_neon = false;
|
||||
*out_spots = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t counter_now = time_get_counter();
|
||||
uint32_t cycle_time_elapsed_ms = time_get_elapsed_ms(counter_now - _time_counter);
|
||||
|
||||
@ -45,4 +31,61 @@ void vigem_iidxio_cab_light_sequencer_update(bool* out_neon, uint8_t* out_spots)
|
||||
if (cycle_time_elapsed_ms >= _SEQ_CYCLE_TIME_MS) {
|
||||
_time_counter = counter_now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _update_neons_flash_tt_input(uint8_t tt_p1, uint8_t tt_p2, bool* out_neon)
|
||||
{
|
||||
if (_first_update) {
|
||||
_tt_prev[0] = tt_p1;
|
||||
_tt_prev[1] = tt_p2;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_tt_prev[0] != tt_p1 || _tt_prev[1] != tt_p2) {
|
||||
*out_neon = true;
|
||||
} else {
|
||||
*out_neon = false;
|
||||
}
|
||||
}
|
||||
|
||||
void vigem_iidxio_cab_light_sequencer_init(
|
||||
enum vigem_iidxio_cab_light_sequencer_mode light_seq_mode)
|
||||
{
|
||||
_time_counter = time_get_counter();
|
||||
_light_seq_mode = light_seq_mode;
|
||||
|
||||
_first_update = true;
|
||||
|
||||
if (_light_seq_mode != LIGHT_SEQ_MODE_OFF) {
|
||||
log_info("Initialized");
|
||||
}
|
||||
}
|
||||
|
||||
void vigem_iidxio_cab_light_sequencer_update(
|
||||
uint16_t keys,
|
||||
uint8_t tt_p1,
|
||||
uint8_t tt_p2,
|
||||
bool* out_neon,
|
||||
uint8_t* out_spots)
|
||||
{
|
||||
log_assert(out_neon);
|
||||
log_assert(out_spots);
|
||||
|
||||
switch (_light_seq_mode) {
|
||||
case LIGHT_SEQ_MODE_NEONS_FLASH:
|
||||
_update_neons_seq_flash(out_neon);
|
||||
|
||||
case LIGHT_SEQ_MODE_NEONS_FLASH_TT_INPUT:
|
||||
_update_neons_flash_tt_input(tt_p1, tt_p2, out_neon);
|
||||
break;
|
||||
|
||||
case LIGHT_SEQ_MODE_OFF:
|
||||
// fallthrough
|
||||
default:
|
||||
*out_neon = false;
|
||||
*out_spots = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
_first_update = false;
|
||||
}
|
||||
|
@ -4,8 +4,20 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void vigem_iidxio_cab_light_sequencer_init();
|
||||
enum vigem_iidxio_cab_light_sequencer_mode {
|
||||
LIGHT_SEQ_MODE_OFF = 0,
|
||||
LIGHT_SEQ_MODE_NEONS_FLASH = 1,
|
||||
LIGHT_SEQ_MODE_NEONS_FLASH_TT_INPUT = 2,
|
||||
};
|
||||
|
||||
void vigem_iidxio_cab_light_sequencer_update(bool* out_neon, uint8_t* out_spots);
|
||||
void vigem_iidxio_cab_light_sequencer_init(
|
||||
enum vigem_iidxio_cab_light_sequencer_mode light_seq_mode);
|
||||
|
||||
void vigem_iidxio_cab_light_sequencer_update(
|
||||
uint16_t keys,
|
||||
uint8_t tt_p1,
|
||||
uint8_t tt_p2,
|
||||
bool* out_neon,
|
||||
uint8_t* out_spots);
|
||||
|
||||
#endif
|
@ -7,13 +7,13 @@
|
||||
|
||||
#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_SEQ_KEY "vigem.iidxio.enable_cab_light_seq"
|
||||
#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_DEFAULT_ENABLE_KEYLIGHT_VALUE true
|
||||
#define VIGEM_IIDXIO_CONFIG_DEFAULT_RELATIVE_ANALOG_VALUE false
|
||||
#define VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_SEQ_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
|
||||
|
||||
@ -31,11 +31,11 @@ static void _vigem_iidxio_config_init(struct cconfig *config)
|
||||
VIGEM_IIDXIO_CONFIG_DEFAULT_RELATIVE_ANALOG_VALUE,
|
||||
"Use relative mode analog mapping");
|
||||
|
||||
cconfig_util_set_bool(
|
||||
cconfig_util_set_int(
|
||||
config,
|
||||
VIGEM_IIDXIO_CONFIG_ENABLE_CAB_LIGHT_SEQ_KEY,
|
||||
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_SEQ_VALUE,
|
||||
"Enable built in cabinet light sequence");
|
||||
VIGEM_IIDXIO_CONFIG_ENABLE_CAB_LIGHT_MODE_KEY,
|
||||
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_MODE_VALUE,
|
||||
"Different cabinet light modes: 0 = off, 1 = neons sequence, 2 = neons flash on TT spin");
|
||||
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
@ -77,16 +77,16 @@ static void _vigem_iidxio_config_get(
|
||||
VIGEM_IIDXIO_CONFIG_DEFAULT_RELATIVE_ANALOG_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_bool(
|
||||
if (!cconfig_util_get_int(
|
||||
config,
|
||||
VIGEM_IIDXIO_CONFIG_ENABLE_CAB_LIGHT_SEQ_KEY,
|
||||
&vigem_config->enable_cab_light_seq,
|
||||
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_SEQ_VALUE)) {
|
||||
VIGEM_IIDXIO_CONFIG_ENABLE_CAB_LIGHT_MODE_KEY,
|
||||
&vigem_config->cab_light_mode,
|
||||
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_MODE_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
VIGEM_IIDXIO_CONFIG_ENABLE_CAB_LIGHT_SEQ_KEY,
|
||||
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_SEQ_VALUE);
|
||||
VIGEM_IIDXIO_CONFIG_ENABLE_CAB_LIGHT_MODE_KEY,
|
||||
VIGEM_IIDXIO_CONFIG_DEFAULT_ENABLE_CAB_LIGHT_MODE_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_str(
|
||||
|
@ -8,7 +8,7 @@
|
||||
struct vigem_iidxio_config {
|
||||
bool enable_keylight;
|
||||
bool relative_analog;
|
||||
bool enable_cab_light_seq;
|
||||
int32_t cab_light_mode;
|
||||
char text_16seg[1024 + 1];
|
||||
int32_t text_scroll_cycle_time_ms;
|
||||
};
|
||||
|
@ -145,9 +145,7 @@ int main(int argc, char **argv)
|
||||
iidx_io_ep1_set_top_lamps(0);
|
||||
iidx_io_ep1_set_top_neons(false);
|
||||
|
||||
if (config.enable_cab_light_seq) {
|
||||
vigem_iidxio_cab_light_sequencer_init();
|
||||
}
|
||||
vigem_iidxio_cab_light_sequencer_init(config.cab_light_mode);
|
||||
|
||||
if (config.text_16seg[0] != '\0') {
|
||||
vigem_iidxio_cab_16seg_sequencer_init(config.text_16seg, config.text_scroll_cycle_time_ms);
|
||||
@ -254,14 +252,19 @@ int main(int argc, char **argv)
|
||||
iidx_io_ep1_set_panel_lights(panel);
|
||||
}
|
||||
|
||||
if (config.enable_cab_light_seq) {
|
||||
if (config.cab_light_mode != LIGHT_SEQ_MODE_OFF) {
|
||||
bool neon;
|
||||
uint8_t spots;
|
||||
|
||||
neon = false;
|
||||
spots = 0;
|
||||
|
||||
vigem_iidxio_cab_light_sequencer_update(&neon, &spots);
|
||||
vigem_iidxio_cab_light_sequencer_update(
|
||||
keys,
|
||||
turntable[0],
|
||||
turntable[1],
|
||||
&neon,
|
||||
&spots);
|
||||
|
||||
iidx_io_ep1_set_top_neons(neon);
|
||||
iidx_io_ep1_set_top_lamps(spots);
|
||||
|
Loading…
x
Reference in New Issue
Block a user