diff options
author | rsn8887 | 2018-01-05 15:35:05 -0600 |
---|---|---|
committer | rsn8887 | 2018-01-05 15:51:39 -0600 |
commit | e78984147d06dbbc1e1c373c90a8bdd02bc0d1e0 (patch) | |
tree | 0c5ba99e1d6364531a53189dcd8a33090c67a795 /backends/platform/psp | |
parent | b2cf5a30bfbb41500a9b81417614d6a9dbb50e6f (diff) | |
download | scummvm-rg350-e78984147d06dbbc1e1c373c90a8bdd02bc0d1e0.tar.gz scummvm-rg350-e78984147d06dbbc1e1c373c90a8bdd02bc0d1e0.tar.bz2 scummvm-rg350-e78984147d06dbbc1e1c373c90a8bdd02bc0d1e0.zip |
PSP: fix bit shifts of cursor x/y, fix too-slow cursor
Diffstat (limited to 'backends/platform/psp')
-rw-r--r-- | backends/platform/psp/cursor.cpp | 10 | ||||
-rw-r--r-- | backends/platform/psp/input.cpp | 26 | ||||
-rw-r--r-- | backends/platform/psp/input.h | 4 |
3 files changed, 21 insertions, 19 deletions
diff --git a/backends/platform/psp/cursor.cpp b/backends/platform/psp/cursor.cpp index 376e7eb3e5..b7c69d5b98 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 e087099585..7a2047f28e 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 05b575e0b0..ff89b9faec 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; } |