Permalink
Browse files

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

  • Loading branch information...
rsn8887 committed Jan 5, 2018
1 parent b2cf5a3 commit e78984147d06dbbc1e1c373c90a8bdd02bc0d1e0
Showing with 21 additions and 19 deletions.
  1. +5 −5 backends/platform/psp/cursor.cpp
  2. +13 −13 backends/platform/psp/input.cpp
  3. +3 −1 backends/platform/psp/input.h
@@ -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);
}
}
@@ -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();
@@ -139,14 +139,16 @@ class Nub {
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
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; }

0 comments on commit e789841

Please sign in to comment.