1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2025-01-19 07:17:23 +01:00

feat: Add bi2a-iidx support for aciotest (#263)

This commit is contained in:
MatryoshkaLJY 2023-10-19 05:06:10 +08:00 committed by GitHub
parent f8d394e124
commit 13c87eaf8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 164 additions and 8 deletions

View File

@ -11,5 +11,6 @@ src_aciotest := \
kfca.c \
panb.c \
rvol.c \
bi2a-iidx.c \
bi2a-sdvx.c \
main.c \

View File

@ -0,0 +1,109 @@
#include "aciotest/bi2a-iidx.h"
#include "acio/acio.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bio2drv/bi2a-iidx.h"
bool aciotest_bi2a_iidx_handler_init(
struct aciodrv_device_ctx *device, uint8_t node_id, void **ctx)
{
*ctx = malloc(sizeof(uint32_t));
*((uint32_t *) *ctx) = 0;
return bio2drv_bi2a_iidx_init(device, node_id);
}
bool aciotest_bi2a_iidx_handler_update(
struct aciodrv_device_ctx *device, uint8_t node_id, void *ctx)
{
struct bi2a_iidx_state_in pin;
struct bi2a_iidx_state_out pout;
memset(&pout, 0, sizeof(pout));
if (!bio2drv_bi2a_iidx_poll(device, node_id, &pout, &pin)) {
return false;
}
printf(
"|---------------------------------------|\n"
"| R Y G B Neons B G Y R |\n"
"| %d %d %d %d %d %d %d %d %d |\n"
"|---------------------------------------|\n"
"| NOW PLAYING: %c%c%c%c%c%c%c%c%c |\n"
"|---------------------------------------|\n"
"| Effect %d S1 S2 S3 S4 S5 Test %d|\n"
"|StartP1 %d %02d %02d %02d %02d %02d StartP2 %d|\n"
"| VEFX %d Service %d|\n"
"_________________________________________\n"
"| __ __ |\n"
"| / \\ _ / \\ |\n"
"| | %03d| %d %d %d |%d| %d %d %d | %03d| |\n"
"| \\___/ %d %d %d %d |_| %d %d %d %d \\___/ |\n"
"| |\n"
"|---------------------------------------|\n"
"|---------------------------------------|\n",
pout.SPOTLIGHT2[0].l_state,
pout.SPOTLIGHT2[1].l_state,
pout.SPOTLIGHT2[2].l_state,
pout.SPOTLIGHT2[3].l_state,
pout.NEONLAMP.l_state,
pout.SPOTLIGHT1[0].l_state,
pout.SPOTLIGHT1[1].l_state,
pout.SPOTLIGHT1[2].l_state,
pout.SPOTLIGHT1[3].l_state,
pout.SEG16[0],
pout.SEG16[1],
pout.SEG16[2],
pout.SEG16[3],
pout.SEG16[4],
pout.SEG16[5],
pout.SEG16[6],
pout.SEG16[7],
pout.SEG16[8],
pin.PANEL.y_effect,
pin.SYSTEM.v_test,
pin.PANEL.y_start1,
pin.SLIDER1.s_val,
pin.SLIDER2.s_val,
pin.SLIDER3.s_val,
pin.SLIDER4.s_val,
pin.SLIDER5.s_val,
pin.PANEL.y_start2,
pin.PANEL.y_vefx,
pin.SYSTEM.v_service,
pin.TURNTABLE1,
pin.P1SW2.b_val,
pin.P1SW4.b_val,
pin.P1SW6.b_val,
pin.SYSTEM.v_coin,
pin.P2SW2.b_val,
pin.P2SW4.b_val,
pin.P2SW6.b_val,
pin.TURNTABLE2,
pin.P1SW1.b_val,
pin.P1SW3.b_val,
pin.P1SW5.b_val,
pin.P1SW7.b_val,
pin.P2SW1.b_val,
pin.P2SW3.b_val,
pin.P2SW5.b_val,
pin.P2SW7.b_val
);
return true;
}

View File

@ -0,0 +1,14 @@
#ifndef ACIOTEST_BI2A_IIDX_H
#define ACIOTEST_BI2A_IIDX_H
#include <stdbool.h>
#include <stdint.h>
#include "aciodrv/device.h"
bool aciotest_bi2a_iidx_handler_init(
struct aciodrv_device_ctx *device, uint8_t node_id, void **ctx);
bool aciotest_bi2a_iidx_handler_update(
struct aciodrv_device_ctx *device, uint8_t node_id, void *ctx);
#endif

View File

@ -1,5 +1,6 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
@ -7,6 +8,7 @@
#include "aciodrv/device.h"
#include "aciotest/bi2a-sdvx.h"
#include "aciotest/bi2a-iidx.h"
#include "aciotest/handler.h"
#include "aciotest/icca.h"
#include "aciotest/kfca.h"
@ -16,7 +18,7 @@
#include "util/log.h"
static uint8_t aciotest_cnt = 0;
static uint8_t bi2a_mode = 0;
static uint8_t bi2a_mode = 255;
/**
* Enumerate supported ACIO nodes based on their product id.
@ -53,14 +55,30 @@ static bool aciotest_assign_handler(
}
if (product_type == AC_IO_NODE_TYPE_BI2A) {
if (bi2a_mode == 0) {
if (bi2a_mode == 255) {
printf(
"Unknown BI2A mode specified, please check your command.\n"
"Using bi2a-sdvx mode as default, press ENTER to continue\n"
);
bi2a_mode = 0;
getchar();
}
switch (bi2a_mode)
{
case 0:
handler->init = aciotest_bi2a_sdvx_handler_init;
handler->update = aciotest_bi2a_sdvx_handler_update;
break;
case 1:
handler->init = aciotest_bi2a_iidx_handler_init;
handler->update = aciotest_bi2a_iidx_handler_update;
break;
return true;
} else {
printf("Unknown BI2A device specified");
default:
break;
}
return true;
}
return false;
@ -76,13 +94,26 @@ int main(int argc, char **argv)
"aciotest, build "__DATE__
" " __TIME__
"\n"
"Usage: %s <com port str> <baud rate>\n"
"Example for two slotted readers: %s COM1 57600\n",
"Usage: %s <com port str> <baud rate> <bi2a mode(optional)>\n"
"Example:\n"
"\"%s COM1 57600\" for generic acio device\n"
"\"%s COM1 57600 bi2a-iidx\" for the iidx BI2A mode\n"
"\"%s COM1 57600 bi2a-sdvx\" for the sdvx BI2A mode\n",
argv[0],
argv[0],
argv[0],
argv[0]);
return -1;
}
if (argc == 4) {
if(!strcmp(argv[3],"bi2a-iidx")) {
bi2a_mode = 1;
} else if(!strcmp(argv[3],"bi2a-sdvx")) {
bi2a_mode = 0;
}
}
log_to_writer(log_writer_stdout, NULL);
struct aciodrv_device_ctx *device =
@ -93,7 +124,8 @@ int main(int argc, char **argv)
return -1;
}
printf("Opening acio device successful\n");
printf("Opening acio device successful, press ENTER to continue\n");
getchar();
uint8_t node_count = aciodrv_device_get_node_count(device);
printf("Enumerated %d nodes\n", node_count);