KrossX / Durazno

XInput wrapper that allows controller customization
MIT License
202 stars 21 forks source link

Add offset option to thumbsticks #48

Closed kocergins closed 4 years ago

kocergins commented 4 years ago

Maybe it's just me, but I like sticks perfectly centred. With antideadzone it makes aiming a breeze. Here's the code:

static void transform_offset(SHORT thumb, SHORT offset) { SHORT rangeMax = (thumb < offset) ? SHRT_MIN : SHRT_MAX; float fThumb = thumb; thumb = (fThumb - offset) / (rangeMax - offset) * rangeMax; }

static void transform_get_state(struct settings set, XINPUT_STATE state) { transform_offset(&state->Gamepad.sThumbLX, set->stick_l.offsetX); transform_offset(&state->Gamepad.sThumbLY, set->stick_l.offsetY); transform_offset(&state->Gamepad.sThumbRX, set->stick_r.offsetX); transform_offset(&state->Gamepad.sThumbRY, set->stick_r.offsetY);

KrossX commented 4 years ago

Looks like you're moving the center and rescaling. What would this be solving?

kocergins commented 4 years ago

It allows matching physical and digital centres, so that stick movement resistance matches camera movement acceleration. Scaling is to preserve min and max range. All of my 5 controllers have ~5% physical and digital centre mismatch which makes it really annoying to aim. With this fix aiming is a pleasure.

kocergins commented 4 years ago

Essentially that's what Windows controller calibration is supposed to do, but it doesn't affect xinput.

KrossX commented 4 years ago

AFAIK, X360 controllers don't rest at zero. Around zero, but never at zero like other controllers would do which would seem to be from a lack of controller deadzone. In contrast, the cheap USB one I'm using has a builtin deadzone of around 25%. Anyhow, when the controller ain't resting properly at the center you usually just increase the deadzone. I would assume the affected controller would end up resting at zero or near zero after this? Otherwise it could be problematic without deadzone.

Since you mention the feature should be similar to the usual controller calibration, have you considered turing this into a controller calibration feature? A dialog where you do the usual steps and it sets the values.

I'm afraid I won't be adding this feature, but I would suggest to make the repository on github so your changes are visible in case someone is interested in your feature. Usually that's what you do to suggest changes though, through a Pull Request from your clone.

kocergins commented 4 years ago

Physical stick edges are misaligned too so the usual calibration won't solve the problem. In my case the offset is the middle of the resting range. Automating this would require non C++ skills which I don't have. Anyway, thanks for your work.