1
0
mirror of https://gitea.tendokyu.moe/Dniel97/segatools.git synced 2024-12-11 03:55:58 +01:00
segatools-dniel97/idacio/idacio.h
2024-06-23 21:21:57 +02:00

163 lines
4.8 KiB
C

#pragma once
#include <windows.h>
#include <stdint.h>
enum {
IDAC_IO_OPBTN_TEST = 0x01,
IDAC_IO_OPBTN_SERVICE = 0x02,
IDAC_IO_OPBTN_COIN = 0x04,
};
enum {
IDAC_IO_GAMEBTN_UP = 0x01,
IDAC_IO_GAMEBTN_DOWN = 0x02,
IDAC_IO_GAMEBTN_LEFT = 0x04,
IDAC_IO_GAMEBTN_RIGHT = 0x08,
IDAC_IO_GAMEBTN_START = 0x10,
IDAC_IO_GAMEBTN_VIEW_CHANGE = 0x20,
};
enum {
/* These are the bitmasks to use when checking which
lights are triggered on incoming IO4 GPIO writes. */
IDAC_IO_LED_START = 1 << 31,
IDAC_IO_LED_VIEW_CHANGE = 1 << 30,
IDAC_IO_LED_UP = 1 << 25,
IDAC_IO_LED_DOWN = 1 << 24,
IDAC_IO_LED_LEFT = 1 << 23,
IDAC_IO_LED_RIGHT = 1 << 22,
};
struct idac_io_analog_state {
/* Current steering wheel position, where zero is the centered position.
The game will accept any signed 16-bit position value, however a real
cabinet will report a value of approximately +/- 25230 when the wheel
is at full lock. Steering wheel positions of a magnitude greater than
this value are not possible on a real cabinet. */
int16_t wheel;
/* Current position of the accelerator pedal, where 0 is released. */
uint16_t accel;
/* Current position of the brake pedal, where 0 is released. */
uint16_t brake;
};
/* Get the version of the IDAC 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
Semantic Versioning standard).
The latest API version as of this writing is 0x0100. */
uint16_t idac_io_get_api_version(void);
/* Initialize the IO DLL. This is the second function that will be called on
your DLL, after mu3_io_get_api_version.
All subsequent calls to this API may originate from arbitrary threads.
Minimum API version: 0x0100 */
HRESULT idac_io_init(void);
/* Get the state of the cabinet's operator buttons as of the last poll. See
IDAC_IO_OPBTN enum above: this contains bit mask definitions for button
states returned in *opbtn. All buttons are active-high.
Minimum API version: 0x0100 */
void idac_io_get_opbtns(uint8_t *opbtn);
/* Get the state of the cabinet's gameplay buttons as of the last poll. See
IDAC_IO_GAMEBTN enum above for bit mask definitions. Inputs are split into
a left hand side set of inputs and a right hand side set of inputs: the bit
mappings are the same in both cases.
All buttons are active-high, even though some buttons' electrical signals
on a real cabinet are active-low.
Minimum API version: 0x0100 */
void idac_io_get_gamebtns(uint8_t *gamebtn);
/* Poll the current state of the cabinet's IO4 analog inputs. See structure
definition above for details.
Minimum API version: 0x0100 */
void idac_io_get_analogs(struct idac_io_analog_state *out);
/* Poll the current position of the six-speed shifter and return it via the
gear out parameter. Valid values are 0 for neutral and 1-6 for gears 1-6.
idachook internally translates this gear position value into the correct
combination of Gear Left, Gear Right, Gear Up, Gear Down buttons that the
game will then interpret as the current position of the gear lever.
Minimum API version: 0x0100 */
void idac_io_get_shifter(uint8_t *gear);
/* Initialize LED emulation. This function will be called before any
other idac_io_led_*() function calls.
All subsequent calls may originate from arbitrary threads and some may
overlap with each other. Ensuring synchronization inside your IO DLL is
your responsibility.
Minimum API version: 0x0101 */
HRESULT idac_io_led_init(void);
/* Update the FET outputs. rgb is a pointer to an array up to 3 bytes.
The following bits are used to control the FET outputs:
[0]: LEFT SEAT LED
[1]: RIGHT SEAT LED
The LED is truned on when the byte is 255 and turned off when the byte is 0.
Minimum API version: 0x0101 */
void idac_io_led_set_fet_output(const uint8_t *rgb);
/* Update the RGB LEDs. rgb is a pointer to an array up to 32 * 4 = 128 bytes.
The LEDs are laid out as follows:
[0]: LEFT UP LED
[1-2]: LEFT CENTER LED
[3]: LEFT DOWN LED
[5]: RIGHT UP LED
[6-7]: RIGHT CENTER LED
[8]: RIGHT DOWN LED
Each rgb value is comprised for 4 bytes in the order of R, G, B, Speed.
Speed is a value from 0 to 255, where 0 is the fastest speed and 255 is the slowest.
Minimum API version: 0x0101 */
void idac_io_led_gs_update(const uint8_t *rgb);
/* Update the cabinet button LEDs. rgb is a pointer to an array up to 6 bytes.
The LEDs are laid out as follows:
[0]: START LED
[1]: VIEW CHANGE LED
[2]: UP LED
[3]: DOWN LED
[4]: RIGHT LED
[5]: LEFT LED
The LED is turned on when the byte is 255 and turned off when the byte is 0.
Minimum API version: 0x0101 */
void idac_io_led_set_leds(const uint8_t *rgb);