mirror of
https://gitea.tendokyu.moe/Dniel97/segatools.git
synced 2024-12-12 04:21:04 +01:00
143 lines
3.2 KiB
C
143 lines
3.2 KiB
C
#include <windows.h>
|
|
|
|
#include <limits.h>
|
|
#include <stdint.h>
|
|
|
|
#include "mai2io/mai2io.h"
|
|
#include "mai2io/config.h"
|
|
|
|
static uint8_t mai2_opbtn;
|
|
static uint16_t mai2_player1_btn;
|
|
static uint16_t mai2_player2_btn;
|
|
static struct mai2_io_config mai2_io_cfg;
|
|
static bool mai2_io_coin;
|
|
|
|
uint16_t mai2_io_get_api_version(void)
|
|
{
|
|
return 0x0100;
|
|
}
|
|
|
|
HRESULT mai2_io_init(void)
|
|
{
|
|
mai2_io_config_load(&mai2_io_cfg, L".\\segatools.ini");
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT mai2_io_poll(void)
|
|
{
|
|
mai2_opbtn = 0;
|
|
mai2_player1_btn = 0;
|
|
mai2_player2_btn = 0;
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_test) & 0x8000) {
|
|
mai2_opbtn |= MAI2_IO_OPBTN_TEST;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_service) & 0x8000) {
|
|
mai2_opbtn |= MAI2_IO_OPBTN_SERVICE;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_coin) & 0x8000) {
|
|
if (!mai2_io_coin) {
|
|
mai2_io_coin = true;
|
|
mai2_opbtn |= MAI2_IO_OPBTN_COIN;
|
|
}
|
|
} else {
|
|
mai2_io_coin = false;
|
|
}
|
|
|
|
//Player 1
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[0])) {
|
|
mai2_player1_btn |= MAI2_IO_GAMEBTN_1;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[1])) {
|
|
mai2_player1_btn |= MAI2_IO_GAMEBTN_2;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[2])) {
|
|
mai2_player1_btn |= MAI2_IO_GAMEBTN_3;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[3])) {
|
|
mai2_player1_btn |= MAI2_IO_GAMEBTN_4;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[4])) {
|
|
mai2_player1_btn |= MAI2_IO_GAMEBTN_5;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[5])) {
|
|
mai2_player1_btn |= MAI2_IO_GAMEBTN_6;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[6])) {
|
|
mai2_player1_btn |= MAI2_IO_GAMEBTN_7;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[7])) {
|
|
mai2_player1_btn |= MAI2_IO_GAMEBTN_8;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[8])) {
|
|
mai2_player1_btn |= MAI2_IO_GAMEBTN_SELECT;
|
|
}
|
|
|
|
//Player 2
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[0])) {
|
|
mai2_player2_btn |= MAI2_IO_GAMEBTN_1;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[1])) {
|
|
mai2_player2_btn |= MAI2_IO_GAMEBTN_2;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[2])) {
|
|
mai2_player2_btn |= MAI2_IO_GAMEBTN_3;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[3])) {
|
|
mai2_player2_btn |= MAI2_IO_GAMEBTN_4;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[4])) {
|
|
mai2_player2_btn |= MAI2_IO_GAMEBTN_5;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[5])) {
|
|
mai2_player2_btn |= MAI2_IO_GAMEBTN_6;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[6])) {
|
|
mai2_player2_btn |= MAI2_IO_GAMEBTN_7;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[7])) {
|
|
mai2_player2_btn |= MAI2_IO_GAMEBTN_8;
|
|
}
|
|
|
|
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[8])) {
|
|
mai2_player2_btn |= MAI2_IO_GAMEBTN_SELECT;
|
|
}
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
void mai2_io_get_opbtns(uint8_t *opbtn)
|
|
{
|
|
if (opbtn != NULL) {
|
|
*opbtn = mai2_opbtn;
|
|
}
|
|
}
|
|
|
|
void mai2_io_get_gamebtns(uint16_t *player1, uint16_t *player2)
|
|
{
|
|
if (player1 != NULL) {
|
|
*player1 = mai2_player1_btn;
|
|
}
|
|
|
|
if (player2 != NULL ){
|
|
*player2 = mai2_player2_btn;
|
|
}
|
|
} |