Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do axis keymap as well (should replace right stick bind) #2692

Merged
merged 13 commits into from
Jul 8, 2013

Conversation

unknownbrackets
Copy link
Collaborator

Only tested with onscreen controls and DirectInput currently. Made sure keyboard was still usable even with controller mapped to buttons.

It took me a sad amount of time to realize I needed 5f382c5.

Anyway, it should work well, and also allows people to reverse the analog direction. There's still todos:

  • accelerometer should probably be an axis?
  • XInput may not do the mapping right and still has the right stick bind stuff.
  • PSP right stick has no UI for mapping, but the code supports it.

Fixes #2503.

-[Unknown]

@unknownbrackets
Copy link
Collaborator Author

I think it should work with XInput now too.

-[Unknown]

@unknownbrackets
Copy link
Collaborator Author

The accelerometer (allowing any direction) is probably pretty doable too, but would need to be normalized and have gravity removed from the equation.

-[Unknown]

@@ -344,14 +425,9 @@ void EmuScreen::update(InputState &input) {
if (g_Config.bAccelerometerToAnalogHoriz) {
// TODO: Deadzone, etc.
leftstick_x += clamp1(curve1(input.acc.y) * 2.0f);
leftstick_x = clamp1(leftstick_x);
__CtrlSetAnalogX(clamp1(leftstick_x), CTRL_STICK_LEFT);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will override the horizontal axis with the tilt, right, if the option is enabled? Previously, they got added together. Dunno if this is reasonably possible with the mapping system though, and as you say, the accelerometer should simply be two or three additional axes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does add still (leftstick_x += clamp1(curve1(...), since the variable lives the whole time. It will mean it'll jump from the crosspad to the tilt in the worst case. I can improve this but I was figuring it would go away soon anyway.

-[Unknown]

@hrydgard
Copy link
Owner

hrydgard commented Jul 8, 2013

Hm, maybe should add UI to map the right stick too, otherwise this is a (very small) regression. Could also do that later. I might merge without it :)

Anyway, great stuff! Seems pretty complete.

@unknownbrackets
Copy link
Collaborator Author

I'm still not sure the right stick was even working before, since it was always writing 0x80 to the position afaict.

But where do I fit it in the UI? It's already got a lot going on.

-[Unknown]

@thedax
Copy link
Collaborator

thedax commented Jul 8, 2013

@unknownbrackets : The right stick was working on DirectInput when I checked out your commits a few hours ago. It really needs a GUI option though, so it doesn't overwrite other controls..

@unknownbrackets
Copy link
Collaborator Author

To clarify: right stick works great for mapping the right stick to buttons or arrows.

However, it is currently not possible to map anything TO the PSP right stick (which of course does not exist, except in the PS3 and possibly Vita emulator, and a very short list of games support it AFAIU.) I don't have any games to test this with, though.

But, the mapping is possible it's just there's no slot in the UI to actually select to map something TO the PSP right stick.

-[Unknown]

@hrydgard
Copy link
Owner

hrydgard commented Jul 8, 2013

Oh yeah of course, you're right that it can be used as a mapping source as it is. I'm silly.

hrydgard added a commit that referenced this pull request Jul 8, 2013
Do axis keymap as well (should replace right stick bind)
@hrydgard hrydgard merged commit 476382d into hrydgard:master Jul 8, 2013
@unknownbrackets
Copy link
Collaborator Author

Yeah, from a source perspective, this only improves things - for DirectInput, you can now select any of several axes (could add more but I wasn't even sure what some of them were), and also can map more buttons than before for crazy buttony controllers (up to 16.)

For XInput, it doesn't map the triggers as analogs but I figured that wasn't really necessary...

-[Unknown]

@unknownbrackets unknownbrackets deleted the keymap-axis branch July 8, 2013 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to map joystick axes
3 participants