|
|
@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
// chuniio_air - chuniio.c
|
|
|
|
|
|
|
|
// project air modified version
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// based on code by esterTion
|
|
|
|
|
|
|
|
// modified by astelle nightshade (lostkagamine)
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// music game never die
|
|
|
|
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <process.h>
|
|
|
|
#include <process.h>
|
|
|
@ -11,38 +19,80 @@ static unsigned int __stdcall chuni_io_slider_thread_proc(void* ctx);
|
|
|
|
|
|
|
|
|
|
|
|
static bool chuni_io_coin;
|
|
|
|
static bool chuni_io_coin;
|
|
|
|
static uint16_t chuni_io_coins;
|
|
|
|
static uint16_t chuni_io_coins;
|
|
|
|
static uint8_t chuni_io_hand_pos;
|
|
|
|
|
|
|
|
static HANDLE chuni_io_slider_thread;
|
|
|
|
static HANDLE chuni_io_slider_thread;
|
|
|
|
static bool chuni_io_slider_stop_flag;
|
|
|
|
static bool chuni_io_slider_stop_flag;
|
|
|
|
static struct chuni_io_config chuni_io_cfg;
|
|
|
|
static struct chuni_io_config chuni_io_cfg;
|
|
|
|
|
|
|
|
|
|
|
|
API uint16_t chuni_io_get_api_version(void)
|
|
|
|
struct IPCMemoryInfo
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint8_t airIoStatus[6];
|
|
|
|
|
|
|
|
uint8_t sliderIoStatus[32];
|
|
|
|
|
|
|
|
uint8_t ledRgbData[32 * 3];
|
|
|
|
|
|
|
|
uint8_t testBtn;
|
|
|
|
|
|
|
|
uint8_t serviceBtn;
|
|
|
|
|
|
|
|
uint8_t coinInsertion;
|
|
|
|
|
|
|
|
uint8_t cardRead;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct IPCMemoryInfo IPCMemoryInfo;
|
|
|
|
|
|
|
|
static HANDLE FileMappingHandle;
|
|
|
|
|
|
|
|
IPCMemoryInfo* FileMapping;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void initSharedMemory()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return 0x0101;
|
|
|
|
if (FileMapping)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((FileMappingHandle = CreateFileMappingA(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, sizeof(IPCMemoryInfo), "Local\\BROKENITHM_SHARED_BUFFER")) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((FileMapping = (IPCMemoryInfo*)MapViewOfFile(FileMappingHandle, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(IPCMemoryInfo))) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(FileMapping, 0, sizeof(IPCMemoryInfo));
|
|
|
|
|
|
|
|
SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
API HRESULT chuni_io_jvs_init(void)
|
|
|
|
API HRESULT chuni_io_jvs_init(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
chuni_io_config_load(&chuni_io_cfg, L".\\segatools.ini");
|
|
|
|
chuni_io_config_load(&chuni_io_cfg, L".\\segatools.ini");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initSharedMemory();
|
|
|
|
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
API void chuni_io_jvs_read_coin_counter(uint16_t* out)
|
|
|
|
API void chuni_io_jvs_read_coin_counter(uint16_t* out)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (out == NULL) {
|
|
|
|
if (out == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (GetAsyncKeyState(chuni_io_cfg.vk_coin)) {
|
|
|
|
if (FileMapping && FileMapping->coinInsertion)
|
|
|
|
if (!chuni_io_coin) {
|
|
|
|
{
|
|
|
|
|
|
|
|
chuni_io_coins++;
|
|
|
|
|
|
|
|
FileMapping->coinInsertion = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (GetAsyncKeyState(chuni_io_cfg.vk_coin))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!chuni_io_coin)
|
|
|
|
|
|
|
|
{
|
|
|
|
chuni_io_coin = true;
|
|
|
|
chuni_io_coin = true;
|
|
|
|
chuni_io_coins++;
|
|
|
|
chuni_io_coins++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
chuni_io_coin = false;
|
|
|
|
chuni_io_coin = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
*out = chuni_io_coins;
|
|
|
|
*out = chuni_io_coins;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -51,32 +101,29 @@ API void chuni_io_jvs_poll(uint8_t* opbtn, uint8_t* beams)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
|
|
if (GetAsyncKeyState(chuni_io_cfg.vk_test)) {
|
|
|
|
if ((FileMapping && FileMapping->testBtn) || GetAsyncKeyState(chuni_io_cfg.vk_test))
|
|
|
|
|
|
|
|
{
|
|
|
|
*opbtn |= 0x01; /* Test */
|
|
|
|
*opbtn |= 0x01; /* Test */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (GetAsyncKeyState(chuni_io_cfg.vk_service)) {
|
|
|
|
if ((FileMapping && FileMapping->serviceBtn) || GetAsyncKeyState(chuni_io_cfg.vk_service))
|
|
|
|
|
|
|
|
{
|
|
|
|
*opbtn |= 0x02; /* Service */
|
|
|
|
*opbtn |= 0x02; /* Service */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (GetAsyncKeyState(chuni_io_cfg.vk_ir)) {
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
if (chuni_io_hand_pos < 6) {
|
|
|
|
{
|
|
|
|
chuni_io_hand_pos++;
|
|
|
|
if (FileMapping && FileMapping->airIoStatus[i])
|
|
|
|
}
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (chuni_io_hand_pos > 0) {
|
|
|
|
|
|
|
|
chuni_io_hand_pos--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
|
|
|
|
if (chuni_io_hand_pos > i) {
|
|
|
|
|
|
|
|
*beams |= (1 << i);
|
|
|
|
*beams |= (1 << i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
API void chuni_io_jvs_set_coin_blocker(bool open)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
API HRESULT chuni_io_slider_init(void)
|
|
|
|
API HRESULT chuni_io_slider_init(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
return S_OK;
|
|
|
@ -84,7 +131,8 @@ API HRESULT chuni_io_slider_init(void)
|
|
|
|
|
|
|
|
|
|
|
|
API void chuni_io_slider_start(chuni_io_slider_callback_t callback)
|
|
|
|
API void chuni_io_slider_start(chuni_io_slider_callback_t callback)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (chuni_io_slider_thread != NULL) {
|
|
|
|
if (chuni_io_slider_thread != NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -97,9 +145,10 @@ API void chuni_io_slider_start(chuni_io_slider_callback_t callback)
|
|
|
|
NULL);
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void chuni_io_slider_stop(void)
|
|
|
|
API void chuni_io_slider_stop(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (chuni_io_slider_thread == NULL) {
|
|
|
|
if (chuni_io_slider_thread == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -113,24 +162,24 @@ void chuni_io_slider_stop(void)
|
|
|
|
|
|
|
|
|
|
|
|
API void chuni_io_slider_set_leds(const uint8_t* rgb)
|
|
|
|
API void chuni_io_slider_set_leds(const uint8_t* rgb)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (FileMapping)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
memcpy(FileMapping->ledRgbData, rgb, 32 * 3);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static unsigned int __stdcall chuni_io_slider_thread_proc(void* ctx)
|
|
|
|
static unsigned int __stdcall chuni_io_slider_thread_proc(void* ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
chuni_io_slider_callback_t callback;
|
|
|
|
chuni_io_slider_callback_t callback;
|
|
|
|
uint8_t pressure[32];
|
|
|
|
uint8_t pressure[32] = { 0 };
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback = ctx;
|
|
|
|
callback = ctx;
|
|
|
|
|
|
|
|
|
|
|
|
while (!chuni_io_slider_stop_flag) {
|
|
|
|
while (!chuni_io_slider_stop_flag)
|
|
|
|
for (i = 0; i < _countof(pressure); i++) {
|
|
|
|
{
|
|
|
|
if (GetAsyncKeyState(chuni_io_cfg.vk_cell[i]) & 0x8000) {
|
|
|
|
if (FileMapping)
|
|
|
|
pressure[i] = 128;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
memcpy(pressure, FileMapping->sliderIoStatus, 32);
|
|
|
|
else {
|
|
|
|
|
|
|
|
pressure[i] = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
callback(pressure);
|
|
|
|
callback(pressure);
|
|
|
|