idac: first segatools support

This commit is contained in:
2023-06-29 11:24:34 +02:00
parent ee6675dd73
commit da97d23b51
25 changed files with 351 additions and 441 deletions

View File

@ -13,16 +13,16 @@
#include "util/dprintf.h"
static void idac_xi_jvs_read_buttons(uint8_t *gamebtn_out);
static void idac_xi_jvs_read_shifter(uint8_t *gear);
static void idac_xi_jvs_read_analogs(struct idac_io_analog_state *out);
static void idac_xi_get_gamebtns(uint8_t *gamebtn_out);
static void idac_xi_get_shifter(uint8_t *gear);
static void idac_xi_get_analogs(struct idac_io_analog_state *out);
static HRESULT idac_xi_config_apply(const struct idac_xi_config *cfg);
static const struct idac_io_backend idac_xi_backend = {
.jvs_read_buttons = idac_xi_jvs_read_buttons,
.jvs_read_shifter = idac_xi_jvs_read_shifter,
.jvs_read_analogs = idac_xi_jvs_read_analogs,
.get_gamebtns = idac_xi_get_gamebtns,
.get_shifter = idac_xi_get_shifter,
.get_analogs = idac_xi_get_analogs,
};
static bool idac_xi_single_stick_steering;
@ -45,6 +45,11 @@ HRESULT idac_xi_init(const struct idac_xi_config *cfg, const struct idac_io_back
return S_OK;
}
HRESULT idac_io_poll(void)
{
return S_OK;
}
static HRESULT idac_xi_config_apply(const struct idac_xi_config *cfg)
{
dprintf("XInput: --- Begin configuration ---\n");
@ -56,7 +61,7 @@ static HRESULT idac_xi_config_apply(const struct idac_xi_config *cfg)
return S_OK;
}
static void idac_xi_jvs_read_buttons(uint8_t *gamebtn_out)
static void idac_xi_get_gamebtns(uint8_t *gamebtn_out)
{
uint8_t gamebtn;
XINPUT_STATE xi;
@ -97,7 +102,7 @@ static void idac_xi_jvs_read_buttons(uint8_t *gamebtn_out)
*gamebtn_out = gamebtn;
}
static void idac_xi_jvs_read_shifter(uint8_t *gear)
static void idac_xi_get_shifter(uint8_t *gear)
{
bool shift_dn;
bool shift_up;
@ -112,9 +117,25 @@ static void idac_xi_jvs_read_shifter(uint8_t *gear)
if (xb & XINPUT_GAMEPAD_START) {
/* Reset to Neutral when start is pressed */
idac_shifter_reset();
idac_shifter_set(0);
}
/*
// Alternative shifting mode
if (xb & XINPUT_GAMEPAD_X) {
// Set to Gear 2 when X is pressed
idac_shifter_set(2);
}
if (xb & XINPUT_GAMEPAD_Y) {
// Set to Gear 3 when Y is pressed
idac_shifter_set(3);
}
shift_dn = xb & XINPUT_GAMEPAD_LEFT_SHOULDER;
shift_up = xb & XINPUT_GAMEPAD_RIGHT_SHOULDER;
*/
shift_dn = xb & (XINPUT_GAMEPAD_Y | XINPUT_GAMEPAD_LEFT_SHOULDER);
shift_up = xb & (XINPUT_GAMEPAD_X | XINPUT_GAMEPAD_RIGHT_SHOULDER);
@ -123,7 +144,7 @@ static void idac_xi_jvs_read_shifter(uint8_t *gear)
*gear = idac_shifter_current_gear();
}
static void idac_xi_jvs_read_analogs(struct idac_io_analog_state *out)
static void idac_xi_get_analogs(struct idac_io_analog_state *out)
{
XINPUT_STATE xi;
int left;
@ -154,7 +175,7 @@ static void idac_xi_jvs_read_analogs(struct idac_io_analog_state *out)
right = 0;
}
if(idac_xi_single_stick_steering) {
if (idac_xi_single_stick_steering) {
out->wheel = left;
} else {
out->wheel = (left + right) / 2;