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

This commit is contained in:
rsn8887 2018-01-05 15:35:05 -06:00
parent b2cf5a30bf
commit e78984147d
3 changed files with 21 additions and 19 deletions

View file

@ -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);
}
}

View file

@ -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;
analogStepX = hiresX / factor;
analogStepY = hiresY / factor;
// hi-res cumulative analog delta for sub-pixel cursor positioning
_hiresX += (analogStepX * 1024) / factor;
_hiresY += (analogStepY * 1024) / factor;
hiresX %= factor;
hiresY %= factor;
analogStepX = (_hiresX / 1024);
analogStepY = (_hiresY / 1024);
// keep track of remainder for true sub-pixel cursor position
_hiresX %= 1024;
_hiresY %= 1024;
int32 oldX = _cursor->getX();
int32 oldY = _cursor->getY();

View file

@ -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; }