forked from Hay1tsme/segatools
75 lines
1.5 KiB
C
75 lines
1.5 KiB
C
#include <windows.h>
|
|
#include <xinput.h>
|
|
|
|
#include <limits.h>
|
|
#include <stdint.h>
|
|
|
|
#include "hkbio/hkbio.h"
|
|
#include "hkbio/config.h"
|
|
|
|
static struct hkb_io_config cfg;
|
|
|
|
uint16_t hkb_io_get_api_version(void)
|
|
{
|
|
return 0x0100;
|
|
}
|
|
|
|
HRESULT hkb_io_init(void)
|
|
{
|
|
hkb_io_config_load(&cfg, L".\\segatools.ini");
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT hkb_io_poll(uint8_t *opbtn, uint8_t *gamebtn)
|
|
{
|
|
|
|
*opbtn = 0;
|
|
*gamebtn = 0;
|
|
|
|
if (GetAsyncKeyState(cfg.vk_test) & 0x8000) {
|
|
*opbtn |= HKB_IO_OPBTN_TEST;
|
|
}
|
|
|
|
if (GetAsyncKeyState(cfg.vk_service) & 0x8000) {
|
|
*opbtn |= HKB_IO_OPBTN_SERVICE;
|
|
}
|
|
|
|
if (GetAsyncKeyState(cfg.vk_coin) & 0x8000) {
|
|
*opbtn |= HKB_IO_OPBTN_COIN;
|
|
}
|
|
|
|
if (GetAsyncKeyState(cfg.vk_right) & 0x8000) {
|
|
*gamebtn |= HKB_IO_GAMEBTN_RIGHT;
|
|
}
|
|
|
|
if (GetAsyncKeyState(cfg.vk_left) & 0x8000) {
|
|
*gamebtn |= HKB_IO_GAMEBTN_LEFT;
|
|
}
|
|
|
|
if (GetAsyncKeyState(cfg.vk_up) & 0x8000) {
|
|
*gamebtn |= HKB_IO_GAMEBTN_UP;
|
|
}
|
|
|
|
if (GetAsyncKeyState(cfg.vk_down) & 0x8000) {
|
|
*gamebtn |= HKB_IO_GAMEBTN_DOWN;
|
|
}
|
|
|
|
if (GetAsyncKeyState(cfg.vk_enter) & 0x8000) {
|
|
*gamebtn |= HKB_IO_GAMEBTN_ENTER;
|
|
}
|
|
|
|
if (GetAsyncKeyState(cfg.vk_cancel) & 0x8000) {
|
|
*gamebtn |= HKB_IO_GAMEBTN_CANCEL;
|
|
}
|
|
|
|
if (GetAsyncKeyState(cfg.vk_arr_right) & 0x8000) {
|
|
*gamebtn |= HKB_IO_GAMEBTN_ARR_RIGHT;
|
|
}
|
|
|
|
if (GetAsyncKeyState(cfg.vk_arr_left) & 0x8000) {
|
|
*gamebtn |= HKB_IO_GAMEBTN_ARR_LEFT;
|
|
}
|
|
|
|
return S_OK;
|
|
}
|