PS4Macro icon indicating copy to clipboard operation
PS4Macro copied to clipboard

[Feature Testing] Mouse input in Remapper

Open komefai opened this issue 7 years ago • 118 comments

This issue is for anyone who want to try the "Mouse input" feature in Remapper. The feature not yet ready, and that is why I decided to delay the release of the next version and release this debug build here instead. You can help me improve this feature by testing it with different games and report the bugs in this issue.

Usage

Open Remapper and check "Enable Mouse", then click on PS4 Remote Play to focus the window. To stop, you can press Alt+Tab to focus other windows.

Mouse Input Settings

NOTE: Default settings are recommended (except for Sensitivity) but feel free to play around with it for different games.

Sensitivity - The amount used to multiply the speed of the mouse Decay Rate - The amount used to divide the speed of the mouse every frame after the mouse stopped moving Decay Threshold - Threshold of the speed (will decay until the speed drops below the threshold) Deadzone - The offset amount from analog stick center to start from (use 0 to start from the center) [Value ranges from 0-127] Makeup Speed - The amount used to multiply AFTER the mouse speed is scaled into analog values to compensate the lost from the decay

Example Deadzone=14.25 (green box represents the deadzone)

Analog stick movement will start at the green line instead of starting from the exact center. remapper_mouse_deadzone


View source: https://github.com/komefai/PS4Macro/blob/master/PS4Macro/Classes/Remapping/Remapper.cs

Screenshot

Screenshot

Download

LATEST (14/04/2018)

-> Multi-monitor support -> Middle click bindings

PS4Macro_cf7ce2c.zip -[commit cf7ce2c]

Previous Builds (oldest first)
  1. PS4Macro_1408820.zip - [commit 1408820]
  2. PS4Macro_2d3d6e2.zip - [commit 2d3d6e2]
  3. PS4Macro_2ec5033.zip - [commit 2ec5033] (Special thanks to Y-T-G)
  4. PS4Macro_c43dbd4.zip - [commit c43dbd4]
  5. PS4Macro_658584b.zip - [commit 658584b] (Special thanks to Y-T-G again!)

komefai avatar Feb 02 '18 21:02 komefai

I would like to try. Will see what I can report.

Y-T-G avatar Feb 03 '18 19:02 Y-T-G

@komefai The sensitivity is so high even at lowest setting. Do I have to tweak the in-game sensitivity? I would also like different sensitivity settings for Aim Down Sight UPDATE- There seems to be a bug: Moving the mouse faster moves the screen slower and moving it slower moves (quickly jerks) the screen faster. I guess the sensitivity issue I am experiencing is due to this.

Y-T-G avatar Feb 04 '18 15:02 Y-T-G

@Y-T-G Thanks for the report! I agree about the sensitivity, probably have to scale it down after calculating the speed. Next build coming soon.

EDIT: Updated [commit 2d3d6e2]

komefai avatar Feb 04 '18 23:02 komefai

@komefai ~~Did you observe anything like the next issue I was having? Slow mouse movements are fast and fast movements are slow. Might be that only the latter is true, and the former is just because the latter is relatively slow, not sure.~~ UPDATE: After some testing, it seems that remapper has not been programmed to consider in game deadzone. For example in RB6, keeping in game deadzone minimum, there is "Right" movement only when ~~scaledX >=160(maybe slightly more or slightly less)~~ rx>= 142.65(that's as precise I could get; movement was extremely minuscle even at 100 sensitivity in game) . So, smaller movements get ignored unless you tweak the sensitivity which does not solve it entirely either.

Y-T-G avatar Feb 05 '18 02:02 Y-T-G

@komefai Using

double rx = ((MouseSpeedX > 0) ? 142.65 : ((MouseSpeedX < 0) ? 113.25 : 128)) + (MouseSpeedX * 127);
double ry = ((MouseSpeedY > 0) ? 142.65 : ((MouseSpeedY < 0) ? 113.25 : 128)) + (MouseSpeedY * 127);

has smoothened things up a lot.

Y-T-G avatar Feb 05 '18 15:02 Y-T-G

Is MouseRecenter interfering with movements? Small movements are occasionally being countered by reverse movements. EDIT: Setting Deadzone 0 solves this.

Y-T-G avatar Feb 05 '18 15:02 Y-T-G

@Y-T-G Hi, thanks for the info, it should save me a lot of time! Sorry for the slow response I've been quite busy with other personal projects lately. I'll try your suggested modifications as soon as I get the chance.

Is MouseRecenter interfering with movements? Small movements are occasionally being countered by reverse movements.

That is very possible actually, I think I might remove the mouse centering entirely because I already implemented mouse overflow which makes recentering unnecessary.

komefai avatar Feb 06 '18 21:02 komefai

@komefai

Sorry for the slow response I've been quite busy with other personal projects lately

No problem. Can you tell me what is the purpose of this ?: MouseSpeedX * 127 & MouseSpeedY * 127

Y-T-G avatar Feb 07 '18 10:02 Y-T-G

@Y-T-G

double rx = 128 + (MouseSpeedX * 127);
double ry = 128 + (MouseSpeedY * 127);

The formula is part of normalizing the values back into the joystick scale. When you substitute 0, 1 and so on, into MouseSpeed this will give:

128 + (-1 * 127) = 1
128 + (0 * 127) = 128
128 + (1 * 127) = 255

Which is the minimum of the analog, the center of the analog (idle), and the maximum of the analog.

The part after that clamps the values between 0 and 255, keeping it in range:

byte scaledX = (byte)((rx < min) ? min : (rx > max) ? max : rx);
byte scaledY = (byte)((ry < min) ? min : (ry > max) ? max : ry);

komefai avatar Feb 07 '18 13:02 komefai

Just wanted to say thank you so much for taking the time to do something this awesome!! If and when you decide to charge for this I have no issue paying for a finished version. I had a few requests I hope you would have time to consider.

  1. Can we remap buttons to keys such as arrow keys on the keyboard? I tried but it seems Remapper only takes letters. Years of using arrow keys instead of WASD. I suppose same question for other keys which I use a lot such as Delete, Page up/down, and number keys on the keyboard number pad, etc.

  2. Can we stretch the Remapper window to be larger? I have a 2nd screen that I put the Remapper screen on so I can remember all the remaps, but I can only see about 1/3 of them. I'd love to stretch the window longer so I can see all the remaps/commands.

In terms of this build, I've been testing out the mouse function in Horizon Zero Dawn and find many of the things YTG has found. There seems to be some kind of bounce back, so if I move the mouse to the right the view bounces back to the left. It's also interesting to watch the right stick key in the remapper screen which shows the emulated stick seems to only be emulating the 4 diagonal corners and not purely up/down. I read through your comments about deadzone and mouse recenter and I hope these fixes make it into the next version. I'm glad to help debug or troubleshoot in any way.

Finally, WTF is this not more popular?!?! I am a long time PC player and only got a PS4 a week ago and already HIGHLY miss aiming with my mouse. Trying to aim with the PS4 controller is horrendously primitive, inaccurate and frustrating. I know the guys who make the Xim4 adapter for connecting keyboard/mouse are most likely making a killing, and they have to manufacture hardware, which you don't! Anyhow keep up the good work and hope word gets out.

SD777x avatar Feb 07 '18 21:02 SD777x

@spinedoc777 Thank you so much for the kind words! My goal is to make this project free and open source so I will definitely keep it this way in the future (though paypal donations are welcome).

  1. Can we remap buttons to keys such as arrow keys on the keyboard? I tried but it seems Remapper only takes letters. Years of using arrow keys instead of WASD. I suppose same question for other keys which I use a lot such as Delete, Page up/down, and number keys on the keyboard number pad, etc.

Yes you can map it to every single key on your keyboard (alt+tab not recommended for obvious reasons). I actually forgot to put this in the README but you can use the Member name from this table provided by Microsoft. So for example the up arrow is just simply "Up" and "PageDown" for the PAGE DOWN key.

  1. Can we stretch the Remapper window to be larger? I have a 2nd screen that I put the Remapper screen on so I can remember all the remaps, but I can only see about 1/3 of them. I'd love to stretch the window longer so I can see all the remaps/commands.

I use multiple monitors and I have this problem as well, I'll see what I can do about that in the next version.

Also thank you for testing the debug build and the reporting your results. Please stay tuned for more updates!

komefai avatar Feb 07 '18 23:02 komefai

@komefai Does MouseSpeed only stay in the range -1 to +1 ? How did you settle on "127" as the factor for multiplication?

Y-T-G avatar Feb 08 '18 07:02 Y-T-G

@Y-T-G MouseSpeed was intended to stay in [-1, 1] range which can be normalized to [0, 255], but since we have to linearly decay the speed over time to smooth the movements (rather than stopping immediately when the mouse stops) the range cannot be limited within [-1, 1] range. This makes [-infinity, infinity] its true range (depending on how fast the mouse moves and the sensitivity factor).

To answer your second question, the number 127 had to be used because of the substitution example I gave you in my previous post. In simple terms, the analog stick has to be centered when MouseSpeed is 0, has to be far left/up when MouseSpeed is <= -1, and has to be far right/down when MouseSpeed is >= 1. As long as these conditions are satisfied, the value could be anything because it will be clamped to [0, 255] range anyway.

I hope that answered your question :D

komefai avatar Feb 08 '18 13:02 komefai

@komefai I found out that the aim bouncing issue is caused by the if statement in this block:

if (Math.Abs(MouseSpeedX) < MouseDeadzone || Math.Abs(MouseSpeedY) < MouseDeadzone)
                        {
                            // Reset mouse speed
                            MouseSpeedX = 0;
                            MouseSpeedY = 0;
                            // Start release timer
                            if (MouseReleaseTimer == null)
                            {
                                MouseReleaseTimer = new System.Timers.Timer(MouseReleaseDelay);
                                MouseReleaseTimer.Start();
                                MouseReleaseTimer.Elapsed += (s, e) =>
                                {
                                    // Recenter cursor
                                    RemapperUtility.SetCursorPosition(500, 500);

                                    // Reset cursor overflow
                                    CursorOverflowX = 0;
                                    CursorOverflowY = 0;

                                    // Stop release timer
                                    MouseReleaseTimer.Stop();
                                    MouseReleaseTimer = null;
                                };

                            }
                        }

because of the OR operator in the condition. So if one of them returns true BOTH MouseSpeedX and MouseSpeedY is reset to 0.

I have tried putting them in seperate if statements and issue dissappears.

Y-T-G avatar Feb 08 '18 18:02 Y-T-G

@Y-T-G Thanks again for your great work! I'll compile all of your suggestions into the next build. Working on some of it now.

komefai avatar Feb 09 '18 20:02 komefai

@Y-T-G In the latest build, I've fixed many of the cursor bouncing/recentering issues. I've also slightly modified your code for calculating rx and ry into a "Deadzone" variable (defaults to 14.25, taken from your values of 142.65 and 113.25). The old deadzone has been renamed to "Decay Threshold" and "Release Delay" has been removed completely. A little messy now but works much smoother thanks to you!

Here's the merged code:

double positiveSpeed = 128 + MouseAnalogDeadzone;
double negativeSpeed = 128 - MouseAnalogDeadzone;
double rx = ((MouseSpeedX > 0) ? positiveSpeed : ((MouseSpeedX < 0) ? negativeSpeed : 128)) + (MouseSpeedX * 127);
double ry = ((MouseSpeedY > 0) ? positiveSpeed : ((MouseSpeedY < 0) ? negativeSpeed : 128)) + (MouseSpeedY * 127);
byte scaledX = (byte)((rx < min) ? min : (rx > max) ? max : rx);
byte scaledY = (byte)((ry < min) ? min : (ry > max) ? max : ry);

komefai avatar Feb 10 '18 00:02 komefai

@komefai Nice. I posted about this project in Wololo.net. Hoping to see more activity in here.

Y-T-G avatar Feb 10 '18 10:02 Y-T-G

@komefai Some kind of a bug in latest build MouseSpeed suddenly jumps to more than 200x EDIT: Looks like it is caused by excluding this line: RemapperUtility.SetCursorPosition(tmpX, tmpY);

Y-T-G avatar Feb 10 '18 13:02 Y-T-G

@komefai Are you planning on implementing an acceleration feature?

Y-T-G avatar Feb 10 '18 17:02 Y-T-G

@Y-T-G I might have to scale the speed down again or use milliseconds instead of seconds for delta time. However, I don't think I will include RemapperUtility.SetCursorPosition(tmpX, tmpY); in future builds because it may cause the cursor to bounce around in opposite directions when reaching the end of the screen. Is it possible for you to scale it back down using the sensitivity setting?

Using acceleration instead of velocity might improve the movements, I'll look into it. Let me know if you have any suggestions on how it should be implemented.

komefai avatar Feb 11 '18 01:02 komefai

@komefai After disabling cursor hiding, I can see that this exponential jump in sensitivity happens as soon as the mouse cursor hits the border of my screen.

because it may cause the cursor to bounce around in opposite directions when reaching the end of the screen.

I am not experiencing aim bouncing with this line included in the latest build. Wasn't the issue due to deadzone threshold which was setting both MouseSpeedX and MouseSpeedY simultaneously to 0 in previous builds?

Y-T-G avatar Feb 11 '18 09:02 Y-T-G

As for acceleration, I tried this:

int signX = Math.Sign(MouseSpeedX);
int signY = Math.Sign(MouseSpeedY);
double rx = ((MouseSpeedX > 0) ? positiveSpeed : ((MouseSpeedX < 0) ? negativeSpeed : 128)) + (signX * (MouseSpeedX * 25) * (MouseSpeedX * 127));
double ry = ((MouseSpeedY > 0) ? positiveSpeed : ((MouseSpeedY < 0) ? negativeSpeed : 128)) + (signY * (MouseSpeedY * 25) * (MouseSpeedY * 127));

I didn't test with many values other than 25. It works but you might have a neater way to do it. I have remapper sensitivity scaled down by 10000 and decay rate at 1.01 with in-game sensitivity maxed out.

Y-T-G avatar Feb 11 '18 11:02 Y-T-G

Testing out the latest build, some weird stuff going on. Firstly I can't get it to work anymore, although I was having this issue with the last build towards the end as well. I start the PS4 remote play program, then I start PS4macro and it seems to inject remote play just fine in that the message changes same as if I connected a controller. I open remapper and press Z to start remote play but that doesn't work anymore so I just press start and nothing gets connected. PS4 remote play starts, my game streams, but I can only use the arrow keys which are used without ps4macro anyway.

Some notes; -in my xml file I have autoinject off because it never worked before when it was on -I don't have a PS4 controller so I say true for emulation, it worked perfectly like this before -I have the issue whether I run a custom settings.xml file or not -When looking at task manager it seems it's using the 32bit injection, my system is fully 64bit

Now some weird stuff, it seems even after closing PS4macro and the remote play program my keyboard is still taken over. I lose most of my keys, where the letter keys for example work as Alt-letter. I can't figure out how to turn this off other than re-logging, although once I simply pressed Alt and a letter and it seemed to fix the keyboard. So somehow it seems PS4macro is remaining in the background and tying up the keyboard, or some other issue.

I'm still trying to get it to work, I was very excited to see the new build and all the new stuff. Thanks also to Y-T-G for providing his input. I wish I was as technical as you 2 guys, but I can at least provide the feedback from a regular joe point of view.

SD777x avatar Feb 12 '18 19:02 SD777x

OK after trying a few times I got it to work, I have no idea how I got it to work though. Some more observations:

-Remapper seems to work when Enable Mouse is NOT checked. If I check Enable Mouse then remapper stops working and mouse look doesn't ever work, I did make sure to click back on the PS4 remote window for focus. If I uncheck Enable mouse then remapper works again.

-With mouse enabled or not enabled the ps4 remote app still sees the mouse as its default, which is to bring up the PS menu and be able to click on the PS menu.

-I'm still getting that issue where my keyboard stays in remapper mode, it seems random so far though although mostly the Enable mouse check seems to make it happen. I can now fix it by hitting Alt-E, although any Alt-letter combo may work, I'm not sure.

SD777x avatar Feb 12 '18 19:02 SD777x

@spinedoc777 I have posted a guide in here: https://github.com/komefai/PS4Macro/issues/8 . Did you try that?

Y-T-G avatar Feb 13 '18 09:02 Y-T-G

Thank you, I did finally get it to work. Not sure how. But mouselook is only going in one direction, no matter where I turn the mouse. Looking at the remapper mouse representation it seems mouselook is only going down and to the right, so my camera just goes around in circles.

SD777x avatar Feb 13 '18 12:02 SD777x

@spinedoc777 Which version are you using?

Y-T-G avatar Feb 13 '18 18:02 Y-T-G

2ec5033

SD777x avatar Feb 13 '18 20:02 SD777x

@Y-T-G Thanks again for your input on acceleration I'll check it out.

@spinedoc777 I can also confirm your issue on mouse input remapping to one direction. It seems to be related to multiple monitor setup, caused by recentering the cursor to x=500, y=500 when remote play is focused. I'll fix it in the next build but a temporary fix for me is to do the entire process in my primary monitor.

komefai avatar Feb 13 '18 23:02 komefai

Yeah I do have multiple monitors. I tried it making sure the ps4macro and remapper were on the same monitor as the ps4remote play, but still the same issue where the mouse doesn't function and when it's checked on remapper stops remapping keys. I'll keep playing with it as time allows.

SD777x avatar Feb 16 '18 16:02 SD777x