idzio: Restrict maximum wheel ADC abs. value

This commit is contained in:
Tau 2019-10-21 22:12:05 -04:00
parent bd61b3e3d9
commit ff14fd7fac
3 changed files with 18 additions and 4 deletions

View File

@ -57,6 +57,7 @@ void idz_di_config_load(struct idz_di_config *cfg, const wchar_t *filename)
swprintf_s(key, _countof(key), L"gear%i", i + 1);
cfg->gear[i] = GetPrivateProfileIntW(L"dinput", key, i + 1, filename);
}
}
void idz_io_config_load(struct idz_io_config *cfg, const wchar_t *filename)
@ -67,6 +68,7 @@ void idz_io_config_load(struct idz_io_config *cfg, const wchar_t *filename)
cfg->vk_test = GetPrivateProfileIntW(L"io3", L"test", '1', filename);
cfg->vk_service = GetPrivateProfileIntW(L"io3", L"service", '2', filename);
cfg->vk_coin = GetPrivateProfileIntW(L"io3", L"coin", '3', filename);
cfg->restrict_ = GetPrivateProfileIntW(L"io3", L"restrict", 196, filename);
GetPrivateProfileStringW(
L"io3",
@ -93,4 +95,3 @@ void idz_shifter_config_load(
0,
filename);
}

View File

@ -25,6 +25,7 @@ struct idz_io_config {
uint8_t vk_service;
uint8_t vk_coin;
wchar_t mode[8];
int restrict_;
struct idz_shifter_config shifter;
struct idz_di_config di;
};

View File

@ -73,12 +73,24 @@ void idz_io_jvs_read_shifter(uint8_t *gear)
idz_io_backend->jvs_read_shifter(gear);
}
void idz_io_jvs_read_analogs(struct idz_io_analog_state *state)
void idz_io_jvs_read_analogs(struct idz_io_analog_state *out)
{
assert(state != NULL);
struct idz_io_analog_state tmp;
assert(out != NULL);
assert(idz_io_backend != NULL);
idz_io_backend->jvs_read_analogs(state);
idz_io_backend->jvs_read_analogs(&tmp);
/* Apply steering wheel restriction. Real cabs only report about 77% of
the IO-3's max ADC output value when the wheel is turned to either of
its maximum positions. To match this behavior we set the default value
for the wheel restriction config parameter to 196 (out of 256). This
scaling factor is applied using fixed-point arithmetic below. */
out->wheel = (tmp.wheel * idz_io_cfg.restrict_) / 256;
out->accel = tmp.accel;
out->brake = tmp.brake;
}
void idz_io_jvs_read_coin_counter(uint16_t *out)