[Scummvm-git-logs] scummvm master -> e78984147d06dbbc1e1c373c90a8bdd02bc0d1e0

rsn8887 rsn8887 at users.noreply.github.com
Fri Jan 5 22:52:30 CET 2018


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e78984147d PSP: fix bit shifts of cursor x/y, fix too-slow cursor


Commit: e78984147d06dbbc1e1c373c90a8bdd02bc0d1e0
    https://github.com/scummvm/scummvm/commit/e78984147d06dbbc1e1c373c90a8bdd02bc0d1e0
Author: rsn8887 (rsn8887 at users.noreply.github.com)
Date: 2018-01-05T15:51:39-06:00

Commit Message:
PSP: fix bit shifts of cursor x/y, fix too-slow cursor

Changed paths:
    backends/platform/psp/cursor.cpp
    backends/platform/psp/input.cpp
    backends/platform/psp/input.h


diff --git a/backends/platform/psp/cursor.cpp b/backends/platform/psp/cursor.cpp
index 376e7eb..b7c69d5 100644
--- a/backends/platform/psp/cursor.cpp
+++ b/backends/platform/psp/cursor.cpp
@@ -204,15 +204,15 @@ void Cursor::setLimits(uint32 width, uint32 height) {
 inline void Cursor::adjustXYForScreenSize(int32 &x, int32 &y) {
 	DEBUG_ENTER_FUNC();
 	// We have our speed calibrated for the y axis at 480x272. The idea is to adjust this for other
-	// resolutions and for x, which is wider.
+	// resolutions
 	int32 newX = x, newY = y;
 
 	if (_mouseLimitWidth >= 600) {	// multiply by 2
-		newX <<= 1;
-		newY <<= 1;
+		newX *= 2;
+		newY *= 2;
 	} else if (_mouseLimitWidth >= 480) {	// multiply by 1.5
-		newX = newX + (newX >> 1);
-		newY = newY + (newY >> 1);
+		newX = newX + (newX / 2);
+		newY = newY + (newY / 2);
 	}
 }
 
diff --git a/backends/platform/psp/input.cpp b/backends/platform/psp/input.cpp
index e087099..7a2047f 100644
--- a/backends/platform/psp/input.cpp
+++ b/backends/platform/psp/input.cpp
@@ -280,12 +280,6 @@ bool Nub::getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad) {
 	analogStepX = modifyNubAxisMotion(analogStepX);
 	analogStepY = modifyNubAxisMotion(analogStepY);
 
-	static int32 hiresX = 0;
-	static int32 hiresY = 0;
-
-	hiresX += analogStepX;
-	hiresY += analogStepY;
-
 	int32 speedFactor = 25;
 	switch (ConfMan.getInt("kbdmouse_speed")) {
 	// 0.25 keyboard pointer speed
@@ -324,18 +318,24 @@ bool Nub::getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad) {
 		speedFactor = 25;
 	}
 
-	int32 additionalFactor = 32;
+	// the larger the factor, the slower the cursor will move
+	int32 additionalFactor = 16;
 	if (_shifted) {
-		additionalFactor = 256;
+		additionalFactor = 192;
 	}
 
-	int32 factor = speedFactor * additionalFactor / 25;
+	int32 factor = (speedFactor * additionalFactor) / 25;
+
+	// hi-res cumulative analog delta for sub-pixel cursor positioning
+	_hiresX += (analogStepX * 1024) / factor;
+	_hiresY += (analogStepY * 1024) / factor;
 
-	analogStepX = hiresX / factor;
-	analogStepY = hiresY / factor;
+	analogStepX = (_hiresX / 1024);
+	analogStepY = (_hiresY / 1024);
 
-	hiresX %= factor;
-	hiresY %= factor;
+	// keep track of remainder for true sub-pixel cursor position
+	_hiresX %= 1024;
+	_hiresY %= 1024;
 	
 	int32 oldX = _cursor->getX();
 	int32 oldY = _cursor->getY();
diff --git a/backends/platform/psp/input.h b/backends/platform/psp/input.h
index 05b575e..ff89b9f 100644
--- a/backends/platform/psp/input.h
+++ b/backends/platform/psp/input.h
@@ -139,6 +139,8 @@ private:
 	Cursor *_cursor;		// to enable changing/getting cursor position
 
 	ShiftMode _shifted;
+	int32 _hiresX;			// to accumulate analog X over many frames
+	int32 _hiresY;			// to accumulate analog Y over many frames
 	bool _dpadMode;
 
 	ButtonPad _buttonPad;	// private buttonpad for dpad mode
@@ -146,7 +148,7 @@ private:
 	int32 modifyNubAxisMotion(int32 input);
 	void translateToDpadState(int dpadX, int dpadY, uint32 &buttonState);	// convert nub data to dpad data
 public:
-	Nub() : _shifted(UNSHIFTED), _dpadMode(false) { }
+	Nub() : _shifted(UNSHIFTED), _dpadMode(false), _hiresX(0), _hiresY(0) { }
 	void init() { _buttonPad.initButtons(); }
 
 	void setCursor(Cursor *cursor) { _cursor = cursor; }





More information about the Scummvm-git-logs mailing list