forked from TeamTofuShop/segatools
added code for auto scanning, but it crashes...
This commit is contained in:
@ -2,13 +2,18 @@
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <process.h>
|
||||
|
||||
#include "mercuryio/mercuryio.h"
|
||||
#include "mercuryio/config.h"
|
||||
|
||||
static unsigned int __stdcall mercury_io_touch_thread_proc(void *ctx);
|
||||
|
||||
static uint8_t mercury_opbtn;
|
||||
static uint8_t mercury_gamebtn;
|
||||
static struct mercury_io_config mercury_io_cfg;
|
||||
static bool mercury_io_touch_stop_flag;
|
||||
static HANDLE mercury_io_touch_thread;
|
||||
|
||||
uint16_t mercury_io_get_api_version(void)
|
||||
{
|
||||
@ -65,7 +70,42 @@ HRESULT mercury_io_touch_init(void)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT mercury_io_touch_start(void)
|
||||
void mercury_io_touch_start(mercury_io_touch_callback_t callback)
|
||||
{
|
||||
return S_OK;
|
||||
if (mercury_io_touch_thread != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
mercury_io_touch_thread = (HANDLE) _beginthreadex(
|
||||
NULL,
|
||||
0,
|
||||
mercury_io_touch_thread_proc,
|
||||
callback,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
static unsigned int __stdcall mercury_io_touch_thread_proc(void *ctx)
|
||||
{
|
||||
mercury_io_touch_callback_t callback;
|
||||
uint8_t pressure[240];
|
||||
size_t i;
|
||||
|
||||
callback = ctx;
|
||||
|
||||
while (!mercury_io_touch_stop_flag) {
|
||||
for (i = 0 ; i < _countof(pressure) ; i++) {
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_cell[i]) & 0x8000) {
|
||||
pressure[i] = 128;
|
||||
} else {
|
||||
pressure[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
callback(pressure);
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ enum {
|
||||
MERCURY_IO_GAMEBTN_VOL_DOWN = 0x02,
|
||||
};
|
||||
|
||||
typedef void (*mercury_io_touch_callback_t)(const uint8_t *state);
|
||||
/* Get the version of the Wacca IO API that this DLL supports. This
|
||||
function should return a positive 16-bit integer, where the high byte is
|
||||
the major version and the low byte is the minor version (as defined by the
|
||||
@ -61,4 +62,4 @@ void mercury_io_get_gamebtns(uint8_t *gamebtn);
|
||||
|
||||
HRESULT mercury_io_touch_init(void);
|
||||
|
||||
HRESULT mercury_io_touch_start(void);
|
||||
void mercury_io_touch_start(mercury_io_touch_callback_t callback);
|
||||
|
Reference in New Issue
Block a user