diff --git a/idzio/config.c b/idzio/config.c index 2b18ede..2422d1a 100644 --- a/idzio/config.c +++ b/idzio/config.c @@ -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); } - diff --git a/idzio/config.h b/idzio/config.h index d91b5f3..0c2b9f3 100644 --- a/idzio/config.h +++ b/idzio/config.h @@ -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; }; diff --git a/idzio/dllmain.c b/idzio/dllmain.c index 3ced7fe..ee97ba0 100644 --- a/idzio/dllmain.c +++ b/idzio/dllmain.c @@ -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)