forked from Hay1tsme/segatools
mu3: coin input added
This commit is contained in:
parent
ec072667b3
commit
90a6f1be7c
10
dist/mu3/segatools.ini
vendored
10
dist/mu3/segatools.ini
vendored
@ -1,11 +1,11 @@
|
||||
[vfs]
|
||||
; Insert the path to the game AMFS directory here (contains ICF1 and ICF2)
|
||||
amfs=amfs
|
||||
amfs=
|
||||
; Create an empty directory somewhere and insert the path here.
|
||||
; This directory may be shared between multiple SEGA games.
|
||||
; NOTE: This has nothing to do with Windows %APPDATA%.
|
||||
appdata=appdata
|
||||
option=option
|
||||
appdata=
|
||||
option=
|
||||
|
||||
[dns]
|
||||
; Insert the hostname or IP address of the server you wish to use here.
|
||||
@ -40,8 +40,12 @@ enable=1
|
||||
; Set "1" to use a xinput gamepad and set "2" to use keyboard.
|
||||
mode=2
|
||||
|
||||
; Test button virtual-key code. Default is the 1 key.
|
||||
test=0x31
|
||||
; Service button virtual-key code. Default is the 2 key.
|
||||
service=0x32
|
||||
; Keyboard button to increment coin counter. Default is the 3 key.
|
||||
coin=0x33
|
||||
|
||||
[dinput]
|
||||
LEFT_A=0x53
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "util/dprintf.h"
|
||||
|
||||
static HRESULT mu3_io4_poll(void *ctx, struct io4_state *state);
|
||||
static uint16_t coins;
|
||||
|
||||
static const struct io4_ops mu3_io4_ops = {
|
||||
.poll = mu3_io4_poll,
|
||||
@ -69,6 +70,11 @@ static HRESULT mu3_io4_poll(void *ctx, struct io4_state *state)
|
||||
state->buttons[0] |= IO4_BUTTON_SERVICE;
|
||||
}
|
||||
|
||||
if (opbtn & MU3_IO_OPBTN_COIN) {
|
||||
coins++;
|
||||
}
|
||||
state->chutes[0] = coins << 8;
|
||||
|
||||
if (left & MU3_IO_GAMEBTN_1) {
|
||||
state->buttons[0] |= 1 << 0;
|
||||
}
|
||||
|
22
mu3io/config.c
Normal file
22
mu3io/config.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mu3io/config.h"
|
||||
|
||||
void mu3_io_config_load(
|
||||
struct mu3_io_config *cfg,
|
||||
const wchar_t *filename)
|
||||
{
|
||||
wchar_t key[16];
|
||||
int i;
|
||||
|
||||
assert(cfg != NULL);
|
||||
assert(filename != NULL);
|
||||
|
||||
cfg->vk_test = GetPrivateProfileIntW(L"io4", L"test", '1', filename);
|
||||
cfg->vk_service = GetPrivateProfileIntW(L"io4", L"service", '2', filename);
|
||||
cfg->vk_coin = GetPrivateProfileIntW(L"io4", L"coin", '3', filename);
|
||||
}
|
16
mu3io/config.h
Normal file
16
mu3io/config.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct mu3_io_config {
|
||||
uint8_t vk_test;
|
||||
uint8_t vk_service;
|
||||
uint8_t vk_coin;
|
||||
};
|
||||
|
||||
void mu3_io_config_load(
|
||||
struct mu3_io_config *cfg,
|
||||
const wchar_t *filename);
|
@ -10,5 +10,7 @@ mu3io_lib = static_library(
|
||||
sources : [
|
||||
'mu3io.c',
|
||||
'mu3io.h',
|
||||
'config.c',
|
||||
'config.h',
|
||||
],
|
||||
)
|
||||
|
@ -5,12 +5,15 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mu3io/mu3io.h"
|
||||
#include "mu3io/config.h"
|
||||
|
||||
static uint8_t mu3_opbtn;
|
||||
static uint8_t mu3_left_btn;
|
||||
static uint8_t mu3_right_btn;
|
||||
static int16_t mu3_lever_pos;
|
||||
static int16_t mu3_lever_xpos;
|
||||
static struct mu3_io_config mu3_io_cfg;
|
||||
static bool mu3_io_coin;
|
||||
|
||||
uint16_t mu3_io_get_api_version(void)
|
||||
{
|
||||
@ -19,6 +22,7 @@ uint16_t mu3_io_get_api_version(void)
|
||||
|
||||
HRESULT mu3_io_init(void)
|
||||
{
|
||||
mu3_io_config_load(&mu3_io_cfg, L".\\segatools.ini");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -33,14 +37,23 @@ HRESULT mu3_io_poll(void)
|
||||
mu3_left_btn = 0;
|
||||
mu3_right_btn = 0;
|
||||
|
||||
if (GetAsyncKeyState('1') & 0x8000) {
|
||||
if (GetAsyncKeyState(mu3_io_cfg.vk_test) & 0x8000) {
|
||||
mu3_opbtn |= MU3_IO_OPBTN_TEST;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState('2') & 0x8000) {
|
||||
if (GetAsyncKeyState(mu3_io_cfg.vk_service) & 0x8000) {
|
||||
mu3_opbtn |= MU3_IO_OPBTN_SERVICE;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mu3_io_cfg.vk_coin) & 0x8000) {
|
||||
if (!mu3_io_coin) {
|
||||
mu3_io_coin = true;
|
||||
mu3_opbtn |= MU3_IO_OPBTN_COIN;
|
||||
}
|
||||
} else {
|
||||
mu3_io_coin = false;
|
||||
}
|
||||
|
||||
memset(&xi, 0, sizeof(xi));
|
||||
XInputGetState(0, &xi);
|
||||
xb = xi.Gamepad.wButtons;
|
||||
|
@ -7,6 +7,7 @@
|
||||
enum {
|
||||
MU3_IO_OPBTN_TEST = 0x01,
|
||||
MU3_IO_OPBTN_SERVICE = 0x02,
|
||||
MU3_IO_OPBTN_COIN = 0x04,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
Loading…
Reference in New Issue
Block a user