aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/psp
diff options
context:
space:
mode:
authorrsn88872018-01-04 06:02:19 -0600
committerrsn88872018-01-04 06:07:34 -0600
commit4e4a5892c81992ea1aa68a5867903cd87223b4f9 (patch)
tree4ebe2d614d422376fb5b03714ad856b8da1d8f18 /backends/platform/psp
parent231407206d91829980da18bfab2d0ae28b3fc9ad (diff)
downloadscummvm-rg350-4e4a5892c81992ea1aa68a5867903cd87223b4f9.tar.gz
scummvm-rg350-4e4a5892c81992ea1aa68a5867903cd87223b4f9.tar.bz2
scummvm-rg350-4e4a5892c81992ea1aa68a5867903cd87223b4f9.zip
PSP: support mouse speed/joy deadzone options and smooth cursor motion
Diffstat (limited to 'backends/platform/psp')
-rw-r--r--backends/platform/psp/cursor.cpp16
-rw-r--r--backends/platform/psp/display_manager.cpp2
-rw-r--r--backends/platform/psp/input.cpp91
-rw-r--r--backends/platform/psp/osys_psp.cpp5
4 files changed, 73 insertions, 41 deletions
diff --git a/backends/platform/psp/cursor.cpp b/backends/platform/psp/cursor.cpp
index 0760bd1354..376e7eb3e5 100644
--- a/backends/platform/psp/cursor.cpp
+++ b/backends/platform/psp/cursor.cpp
@@ -162,7 +162,7 @@ bool Cursor::increaseXY(int32 incX, int32 incY) {
int32 oldX = _x, oldY = _y;
- // adjust for differences in X and Y
+ // adjust for screen resolution
adjustXYForScreenSize(incX, incY);
_x += incX;
@@ -207,10 +207,6 @@ inline void Cursor::adjustXYForScreenSize(int32 &x, int32 &y) {
// resolutions and for x, which is wider.
int32 newX = x, newY = y;
- // adjust width movement to match height (usually around 1.5)
- if (_mouseLimitWidth >= _mouseLimitHeight + (_mouseLimitHeight >> 1))
- newX = newX + (newX >> 1);
-
if (_mouseLimitWidth >= 600) { // multiply by 2
newX <<= 1;
newY <<= 1;
@@ -218,16 +214,6 @@ inline void Cursor::adjustXYForScreenSize(int32 &x, int32 &y) {
newX = newX + (newX >> 1);
newY = newY + (newY >> 1);
}
-
- // Divide all movements by 8
- newX >>= 3;
- newY >>= 3;
-
- // Make sure we didn't destroy minimum movement
- if (!((x && !newX) || (y && !newY))) {
- x = newX;
- y = newY;
- }
}
// This is only called when we have a new screen
diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp
index 3476e9f848..33bf190d70 100644
--- a/backends/platform/psp/display_manager.cpp
+++ b/backends/platform/psp/display_manager.cpp
@@ -466,7 +466,7 @@ bool DisplayManager::renderAll() {
inline bool DisplayManager::isTimeToUpdate() {
-#define MAX_FPS 30
+#define MAX_FPS 60 // was 30
uint32 now = g_system->getMillis();
if (now - _lastUpdateTime < (1000 / MAX_FPS))
diff --git a/backends/platform/psp/input.cpp b/backends/platform/psp/input.cpp
index 4d7577eb94..b5d90803d6 100644
--- a/backends/platform/psp/input.cpp
+++ b/backends/platform/psp/input.cpp
@@ -23,6 +23,7 @@
#include <pspctrl.h>
#include "gui/message.h"
#include "backends/platform/psp/input.h"
+#include "common/config-manager.h"
//#define __PSP_DEBUG_FUNCS__ /* Uncomment for debugging the stack */
//#define __PSP_DEBUG_PRINT__ /* Uncomment for debug prints */
@@ -36,7 +37,7 @@
#define PSP_TRIGGERS (PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER)
#define PSP_ALL_BUTTONS (PSP_DPAD | PSP_4BUTTONS | PSP_TRIGGERS | PSP_CTRL_START | PSP_CTRL_SELECT)
-#define PAD_CHECK_TIME 53
+#define PAD_CHECK_TIME 14 // was 53
Button::Button() {
clear();
@@ -273,39 +274,77 @@ bool Nub::getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad) {
return _buttonPad.getEventFromButtonState(event, pspEvent, buttonState);
}
- int32 analogStepX = pad.Lx; // Goes up to 255.
+ int32 analogStepX = pad.Lx; // Goes up to 255.
int32 analogStepY = pad.Ly;
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
+ case 0:
+ speedFactor = 100;
+ break;
+ // 0.5 speed
+ case 1:
+ speedFactor = 50;
+ break;
+ // 0.75 speed
+ case 2:
+ speedFactor = 33;
+ break;
+ // 1.0 speed
+ case 3:
+ speedFactor = 25;
+ break;
+ // 1.25 speed
+ case 4:
+ speedFactor = 20;
+ break;
+ // 1.5 speed
+ case 5:
+ speedFactor = 17;
+ break;
+ // 1.75 speed
+ case 6:
+ speedFactor = 14;
+ break;
+ // 2.0 speed
+ case 7:
+ speedFactor = 12;
+ break;
+ default:
+ speedFactor = 25;
+ }
+
+ int32 additionalFactor = 32;
+ if (_shifted) {
+ additionalFactor = 256;
+ }
+
+ int32 factor = speedFactor * additionalFactor / 25;
+
+ analogStepX = hiresX / factor;
+ analogStepY = hiresY / factor;
+
+ hiresX %= factor;
+ hiresY %= factor;
+
int32 oldX = _cursor->getX();
int32 oldY = _cursor->getY();
if (analogStepX != 0 || analogStepY != 0) {
PSP_DEBUG_PRINT("raw x[%d], y[%d]\n", analogStepX, analogStepY);
-
- // If no movement then this has no effect
- if (_shifted) {
- // Fine control mode for analog
- if (analogStepX != 0) {
- if (analogStepX > 0)
- _cursor->increaseXY(2, 0);
- else
- _cursor->increaseXY(-2, 0);
- }
-
- if (analogStepY != 0) {
- if (analogStepY > 0)
- _cursor->increaseXY(0, 2);
- else
- _cursor->increaseXY(0, -2);
- }
- } else { // Regular speed movement
- _cursor->increaseXY(analogStepX, 0);
- _cursor->increaseXY(0, analogStepY);
- }
+ _cursor->increaseXY(analogStepX, 0);
+ _cursor->increaseXY(0, analogStepY);
int32 newX = _cursor->getX();
int32 newY = _cursor->getY();
@@ -338,7 +377,8 @@ void Nub::translateToDpadState(int dpadX, int dpadY, uint32 &buttonState) {
inline int32 Nub::modifyNubAxisMotion(int32 input) {
DEBUG_ENTER_FUNC();
- const int MIN_NUB_MOTION = 30;
+
+ int MIN_NUB_MOTION = 10 * ConfMan.getInt("joystick_deadzone");
input -= 128; // Center on 0.
@@ -349,6 +389,9 @@ inline int32 Nub::modifyNubAxisMotion(int32 input) {
else // between these points, dampen the response to 0
input = 0;
+ if (input != 0) { // scaled deadzone
+ input = (input * 128)/(128 - MIN_NUB_MOTION);
+ }
return input;
}
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 7812f7df28..314580fd37 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -66,6 +66,8 @@ void OSystem_PSP::initBackend() {
ConfMan.registerDefault("aspect_ratio", false);
ConfMan.registerDefault("gfx_mode", "Fit to Screen");
+ ConfMan.registerDefault("kbdmouse_speed", 3);
+ ConfMan.registerDefault("joystick_deadzone", 3);
// Instantiate real time clock
PspRtc::instance();
@@ -112,7 +114,8 @@ void OSystem_PSP::engineDone() {
}
bool OSystem_PSP::hasFeature(Feature f) {
- return (f == kFeatureOverlaySupportsAlpha || f == kFeatureCursorPalette);
+ return (f == kFeatureOverlaySupportsAlpha || f == kFeatureCursorPalette ||
+ f == kFeatureKbdMouseSpeed || f == kFeatureJoystickDeadzone);
}
void OSystem_PSP::setFeatureState(Feature f, bool enable) {