aboutsummaryrefslogtreecommitdiff
path: root/backends/events
diff options
context:
space:
mode:
authorrsn88872018-01-24 12:11:39 -0600
committerrsn88872018-01-24 19:06:22 -0600
commit690d39cc293c6a981bb9bc29fc08fd28a93f3197 (patch)
tree18e17f547384519714e3fc0832c06521b7b32a78 /backends/events
parentb35d5f51651abce3c3ce7929f012129bc1600ce1 (diff)
downloadscummvm-rg350-690d39cc293c6a981bb9bc29fc08fd28a93f3197.tar.gz
scummvm-rg350-690d39cc293c6a981bb9bc29fc08fd28a93f3197.tar.bz2
scummvm-rg350-690d39cc293c6a981bb9bc29fc08fd28a93f3197.zip
PSP2: Increase direct touch accuracy
Diffstat (limited to 'backends/events')
-rw-r--r--backends/events/psp2sdl/psp2sdl-events.cpp47
-rw-r--r--backends/events/psp2sdl/psp2sdl-events.h2
2 files changed, 23 insertions, 26 deletions
diff --git a/backends/events/psp2sdl/psp2sdl-events.cpp b/backends/events/psp2sdl/psp2sdl-events.cpp
index 81f057f2e0..cc72b01ac0 100644
--- a/backends/events/psp2sdl/psp2sdl-events.cpp
+++ b/backends/events/psp2sdl/psp2sdl-events.cpp
@@ -43,8 +43,6 @@ PSP2EventSource::PSP2EventSource() {
_finger[i][j].id = -1;
}
}
- // need specs of front panel for accurate direct touch
- sceTouchGetPanelInfo(0, &panelInfo);
}
void PSP2EventSource::preprocessEvents(SDL_Event *event) {
@@ -117,7 +115,7 @@ void PSP2EventSource::preprocessFingerUp(SDL_Event *event) {
int y = _km.y / MULTIPLIER;
if (!ConfMan.getBool("touchpad_mouse_mode") && port == 0) {
- convertTouchToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
+ convertTouchXYToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
}
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
@@ -164,11 +162,11 @@ void PSP2EventSource::preprocessFingerMotion(SDL_Event *event) {
if (numFingersDown == 1) {
- int x = _km.x / MULTIPLIER;;
+ int x = _km.x / MULTIPLIER;
int y = _km.y / MULTIPLIER;
if (!ConfMan.getBool("touchpad_mouse_mode") && port == 0) {
- convertTouchToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
+ convertTouchXYToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
} else {
// for relative mode, use the pointer speed setting
float speedFactor = 1.0;
@@ -235,34 +233,33 @@ void PSP2EventSource::preprocessFingerMotion(SDL_Event *event) {
}
}
-void PSP2EventSource::convertTouchToGameXY(float touchX, float touchY, int *gameX, int *gameY) {
+void PSP2EventSource::convertTouchXYToGameXY(float touchX, float touchY, int *gameX, int *gameY) {
+ int screenWidth = 960;
+ int screenHeight = 544;
// Find touch coordinates in terms of Vita screen pixels
- float aaTouchX = touchX * (panelInfo.maxAaX - panelInfo.minAaX) + panelInfo.minAaX;
- float aaTouchY = touchY * (panelInfo.maxAaY - panelInfo.minAaY) + panelInfo.minAaY;
-
- float screenTouchX = (aaTouchX - panelInfo.minDispX) * 960 / panelInfo.maxDispX;
- float screenTouchY = (aaTouchY - panelInfo.minDispY) * 544 / panelInfo.maxDispY;
+ int screenTouchX = (int) (touchX * (float)screenWidth);
+ int screenTouchY = (int) (touchY * (float)screenHeight);
// Find four corners of game screen in Vita screen coordinates
// This depends on the fullscreen and aspect ratio correction settings (at least on Vita)
- float gameXMin = 0;
- float gameXMax = 0;
- float gameYMin = 0;
- float gameYMax = 0;
+ int gameXMin = 0;
+ int gameXMax = 0;
+ int gameYMin = 0;
+ int gameYMax = 0;
float aspectRatio = 4.0 / 3.0;
// vertical
if (ConfMan.getBool("fullscreen")) {
- gameYMin = 0.0;
- gameYMax = 544.0;
+ gameYMin = 0;
+ gameYMax = screenHeight;
} else {
if (_km.y_max <= 272) {
- gameYMin = (544.0 - (_km.y_max * 2.0)) / 2.0;
- gameYMax = 544.0 - gameYMin;
+ gameYMin = (screenHeight - (_km.y_max * 2)) / 2;
+ gameYMax = screenHeight - gameYMin;
} else {
- gameYMin = (544.0 - (_km.y_max)) / 2.0;
- gameYMax = 544 - gameYMin;
+ gameYMin = (screenHeight - (_km.y_max)) / 2;
+ gameYMax = screenHeight - gameYMin;
}
}
// horizontal
@@ -271,12 +268,12 @@ void PSP2EventSource::convertTouchToGameXY(float touchX, float touchY, int *game
} else {
aspectRatio = (float)_km.x_max / (float)_km.y_max;
}
- gameXMin = (960 - (gameYMax - gameYMin) * aspectRatio) / 2.0;
- gameXMax = 960.0 - gameXMin;
+ gameXMin = (960 - ((float)(gameYMax - gameYMin) * aspectRatio)) / 2;
+ gameXMax = 960 - gameXMin;
// find game pixel coordinates corresponding to front panel touch coordinates
- int x = (screenTouchX - gameXMin) / (gameXMax - gameXMin) * _km.x_max;
- int y = (screenTouchY - gameYMin) / (gameYMax - gameYMin) * _km.y_max;
+ int x = ((screenTouchX - gameXMin) * _km.x_max) / (gameXMax - gameXMin);
+ int y = ((screenTouchY - gameYMin) * _km.y_max) / (gameYMax - gameYMin);
if (x < 0) {
x = 0;
diff --git a/backends/events/psp2sdl/psp2sdl-events.h b/backends/events/psp2sdl/psp2sdl-events.h
index a4143af157..42101fefe9 100644
--- a/backends/events/psp2sdl/psp2sdl-events.h
+++ b/backends/events/psp2sdl/psp2sdl-events.h
@@ -48,7 +48,7 @@ private:
void preprocessFingerDown(SDL_Event *event);
void preprocessFingerUp(SDL_Event *event);
void preprocessFingerMotion(SDL_Event *event);
- void convertTouchToGameXY(float touchX, float touchY, int *gameX, int *gameY);
+ void convertTouchXYToGameXY(float touchX, float touchY, int *gameX, int *gameY);
SceTouchPanelInfo panelInfo;
};