Skip to content

Improved Mouse mapping to analog stick - #7885

Closed
sideprojectslab wants to merge 8 commits into
PCSX2:masterfrom
sideprojectslab:master
Closed

Improved Mouse mapping to analog stick#7885
sideprojectslab wants to merge 8 commits into
PCSX2:masterfrom
sideprojectslab:master

Conversation

@sideprojectslab

@sideprojectslab sideprojectslab commented Jan 14, 2023

Copy link
Copy Markdown
Contributor

Description of Changes

Added a dead-zone compensation when mapping an analog stick to mouse movement. One can configure the amount of dead-zone that a game inherently has for the desired analog stick. When the mouse is moved, the stick position will immediately skip over the stick's dead zone. This prevents the previous situation in which the mouse becomes unresponsive for small movements that don't move the stick past the game's default dead-zone

Added an "inertia" control that allows the stick to briefly continue "moving" after the mouse has stopped moving IF AND ONLY IF the mouse movement speed has exceded the maximum speed of the analog stick. Changed

Rationale behind Changes

This PR should make FPS games a lot easier to play with mouse and keyboard. Small cursor movements now behave nearly identical to a true PC FPS game controlled with the mouse, while larger movements are still limited to the maximum stick speed, though the "inertia" control slightly masks this limitation

Suggested Testing Steps

I added controller configuration for debug, I would suggest to play FPS games with it like Killzone, Halflife, Black, Battlefield and so on and "see how it feels.

@JordanTheToaster

Copy link
Copy Markdown
Member

Currently I cannot get any mouse movement to work at all when binding the stick myself to the mouse or using the input profile provided.

@refractionpcsx2

Copy link
Copy Markdown
Member

I will say, once this PR is complete, I will ask you to remove your input profile. I appreciate offering a preconfigured setup, but you could overwrite somebody elses profile, if they happen to name it the same, and we don't want to overwrite users custom configs.

@RedDevilus

Copy link
Copy Markdown
Contributor

Would be nice to have multiple automatic configs per device, like how steam looks at device IDs and give multiple options. Though that would be low priority.

@refractionpcsx2

refractionpcsx2 commented Jan 17, 2023

Copy link
Copy Markdown
Member

Some kind of automatic mapping thing down the line might be good, but we'd need to decide on some "standard" config for games, taking in to account things like 10-keyless and hey board keyboards, then we can bake it in to the emulator as an "Automatic mapping" kind of thing.

But then it's also a minefield of dealing with AZERTY,QWERTZ and DVORAK etc.

So yeah, that kinda feature would need a lot of thought.

Anyway, out of scope of this PR.

@RedDevilus

Copy link
Copy Markdown
Contributor

Im using azerty and the current default keyboard layout kinda sucks in my case so I get it.

@Dreadmoth

Dreadmoth commented Jan 17, 2023

Copy link
Copy Markdown
Contributor

Currently I cannot get any mouse movement to work at all when binding the stick myself to the mouse or using the input profile provided.

If I start the PR build fresh, then:

  • a) bind controls on the shared profile - mouse movement works.
  • b) immediately select the provided profile - mouse movement works.

If I copy in existing PCSX2.ini from my regular PCSX2 install, then:

  • a) make no changes - mouse movement does not work.
  • b) immediately select the provided profile - mouse movement works.
  • c) adjust each of the new sliders once (shared profile selected) - mouse movement works.

Edited - I was not selecting the provided profile correctly, sorry for any confusion.

@refractionpcsx2

Copy link
Copy Markdown
Member

That needs to be considered, as everybody will be upgrading from an existing install. So any out of bounds values (assuming that's what's going on here?) Are handled.

@sideprojectslab

Copy link
Copy Markdown
Contributor Author

of course the default ini file was just to facilitate testing, I will remove it when I get the greenlight. Regarding out of bound values, I will check again but the new implementation should be robust against those.

@sideprojectslab

Copy link
Copy Markdown
Contributor Author

how do I resolve conflicts in the .ui file without completely ditching my changes and re-doing everything?

@refractionpcsx2

Copy link
Copy Markdown
Member

For me I usually look at the layout of the XML and try and work out how to piece my bit back in.

I don't know an easy way, personally. The main thing is trying to fix the conflicting part from HEAD in your current code.

@sideprojectslab

Copy link
Copy Markdown
Contributor Author

I have already seen that I'll have to do it more or less from scratch. Perhaps we could decide a time window in which that file is locked? otherwise by the time it is tested it will have changed again :D

@refractionpcsx2

Copy link
Copy Markdown
Member

tbh that doesn't change very often, I think it was just unfortunate timing :P

@sideprojectslab

Copy link
Copy Markdown
Contributor Author

on it

# Conflicts:
#	pcsx2-qt/Settings/ControllerGlobalSettingsWidget.cpp
#	pcsx2-qt/Settings/ControllerGlobalSettingsWidget.ui
@github-actions github-actions Bot added the Dependencies Pull requests that update a dependency file label Jan 17, 2023
PointerAxisState& state = s_pointer_state[device][axis];
const float delta = static_cast<float>(state.delta.exchange(0, std::memory_order_acquire)) / 65536.0f;
const float unclamped_value = delta * s_pointer_axis_scale[axis];
delta = static_cast<float>(state.delta.exchange(0, std::memory_order_acquire)) / 65536.0f;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could possibly declare delta here and make it const

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dependencies Pull requests that update a dependency file GUI/Qt Needs Rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants