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

Mouse jump glitchy problem with Chrome Win10 360 spin keep moving mouse to right. #37

Open
LiamKarlMitchell opened this issue Dec 23, 2018 · 3 comments

Comments

@LiamKarlMitchell
Copy link

LiamKarlMitchell commented Dec 23, 2018

A problem that can happen when spinning around is that the position suddenly jumps a lot in Chrome.
There may be a fix for this that they have not pushed into Chrome yet.

I am only listing this issue here because I noticed it in WebQuake in-case others have this problem and think WebQuake is to blame, it is not related to WebQuake.

Possible work around, lerp the delta by some constant not ideal.

function lerp(v0, v1, t) {
	return (1 - t) * v0 + t * v1;
}

function getChromeVersion () {
    var pieces = navigator.userAgent.match(/Chrom(?:e|ium)\/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/);
    if (pieces == null || pieces.length != 5) {
        return undefined;
    }
    pieces = pieces.map(piece => parseInt(piece, 10));
    return {
        major: pieces[1],
        minor: pieces[2],
        build: pieces[3],
        patch: pieces[4]
    };
}

var usePointerLock360BugWorkaround = false;
var chromeVersion = getChromeVersion();
if (chromeVersion) {
	usePointerLock360BugWorkaround = true;
	IN.mouse_delta_x = 0;
	IN.mouse_delta_y = 0;
}

IN.onmousemove = function(e)
{
	if (document[IN.pointerLockElement] !== VID.mainwindow)
		return;
	if (usePointerLock360BugWorkaround === false) {
		IN.mouse_x += e[IN.movementX];
		IN.mouse_y += e[IN.movementY];
	} else {
		// Workaround Chrome mouseMove "sudden jump" bug.
		IN.mouse_delta_x = lerp(IN.mouse_delta_x, e[IN.movementX], 0.75);
		IN.mouse_delta_y = lerp(IN.mouse_delta_y, e[IN.movementY], 0.75);
		IN.mouse_x += IN.mouse_delta_x;
		IN.mouse_y += IN.mouse_delta_y;
	}
};

Related links:
http://www.html5gamedevs.com/topic/34516-pointer-lock-bug-on-chrome-with-windows-10/
https://bugs.chromium.org/p/chromium/issues/detail?id=781182
https://bugs.chromium.org/p/chromium/issues/detail?id=461373
https://bugs.chromium.org/p/chromium/issues/detail?id=411634
https://bugs.chromium.org/p/chromium/issues/detail?id=784122

Possible work around to lerp the delta values found here, going to try adding this as a work-around.
mrdoob/three.js#12757

@efess
Copy link

efess commented May 5, 2019

What kind of mouse are you using? If it's wireless, is it RF or Bluetooth?

@LiamKarlMitchell
Copy link
Author

LiamKarlMitchell commented May 9, 2019

Hi @efess , Wired steelseries.
Also I have a 4k screen if that matters any.
Still happening on Version 73.0.3683.103 (Official Build) (64-bit) with the same WebQuake code from back when I posted this just wanted to check if browser updates had fixed it but sadly has not.

@efess
Copy link

efess commented Oct 17, 2022

Apparently this is a bug with how windows is "adjusting" the x/y values when provided to chromium. This behavior can be bypassed by using the chrome specific option unadjustedMovement when requesting pointer lock.
Details here:
https://chromestatus.com/feature/5723553087356928

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

No branches or pull requests

2 participants