aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorJohannes Schickel2012-02-20 00:25:48 +0100
committerJohannes Schickel2012-02-20 00:25:48 +0100
commit438bc50115b7d1faf62c5821514d9941792790d0 (patch)
tree829777272f9b5d5ab27edf6de1cea97ebbac6862 /backends
parent68bbe973bdbf0a455fc416f2c533092d920f5ac7 (diff)
downloadscummvm-rg350-438bc50115b7d1faf62c5821514d9941792790d0.tar.gz
scummvm-rg350-438bc50115b7d1faf62c5821514d9941792790d0.tar.bz2
scummvm-rg350-438bc50115b7d1faf62c5821514d9941792790d0.zip
IPHONE: Fix cursor hotspots.
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/iphone/iphone_common.h2
-rw-r--r--backends/platform/iphone/iphone_video.m17
-rw-r--r--backends/platform/iphone/osys_video.cpp4
3 files changed, 19 insertions, 4 deletions
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index d6d3a3dc6f..98d1244054 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -75,7 +75,7 @@ bool iPhone_isHighResDevice();
int iPhone_getScreenHeight();
int iPhone_getScreenWidth();
void iPhone_enableOverlay(int state);
-void iPhone_setMouseCursor(short *buffer, int width, int height);
+void iPhone_setMouseCursor(short *buffer, int width, int height, int hotspotX, int hotspotY);
uint getSizeNextPOT(uint size);
diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m
index df95b36310..a412945a5e 100644
--- a/backends/platform/iphone/iphone_video.m
+++ b/backends/platform/iphone/iphone_video.m
@@ -51,6 +51,8 @@ static UITouch *_secondTouch = NULL;
static short *_mouseCursor = NULL;
static int _mouseCursorHeight = 0;
static int _mouseCursorWidth = 0;
+static int _mouseCursorHotspotX = 0;
+static int _mouseCursorHotspotY = 0;
static int _mouseX = 0;
static int _mouseY = 0;
@@ -72,12 +74,15 @@ int printOglError(const char *file, int line) {
return retCode;
}
-void iPhone_setMouseCursor(short *buffer, int width, int height) {
+void iPhone_setMouseCursor(short *buffer, int width, int height, int hotspotX, int hotspotY) {
_mouseCursor = buffer;
_mouseCursorWidth = width;
_mouseCursorHeight = height;
+ _mouseCursorHotspotX = hotspotX;
+ _mouseCursorHotspotY = hotspotY;
+
[sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES];
}
@@ -354,21 +359,31 @@ bool getLocalMouseCoords(CGPoint *point) {
int mouseX = _mouseX;
int mouseY = _mouseY;
+ int hotspotX = _mouseCursorHotspotX;
+ int hotspotY = _mouseCursorHotspotY;
+
if (!_overlayIsEnabled) {
const GLint gameWidth = (_visibleHeight - 2 * _widthOffset);
const GLint gameHeight = (_visibleWidth - 2 * _heightOffset);
mouseX = (_width - mouseX) / (float)_width * gameHeight + _heightOffset;
mouseY = mouseY / (float)_height * gameWidth + _widthOffset;
+ hotspotX = hotspotX / (float)_width * gameHeight;
+ hotspotY = hotspotY / (float)_height * gameWidth;
width = width / (float)_width * gameHeight;
height = height / (float)_height * gameWidth;
} else {
mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _backingWidth;
mouseY = mouseY / (float)_overlayHeight * _backingHeight;
+ hotspotX = hotspotX / (float)_overlayWidth * _backingWidth;
+ hotspotY = hotspotY / (float)_overlayHeight * _backingHeight;
width = width / (float)_overlayWidth * _backingWidth;
height = height / (float)_overlayHeight * _backingHeight;
}
+ mouseX -= hotspotX;
+ mouseY -= hotspotY;
+
GLfloat vertices[] = {
mouseX , mouseY,
mouseX + width, mouseY,
diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp
index ad434153ec..4d3d49c552 100644
--- a/backends/platform/iphone/osys_video.cpp
+++ b/backends/platform/iphone/osys_video.cpp
@@ -170,7 +170,7 @@ void OSystem_IPHONE::updateScreen() {
_fullScreenIsDirty = false;
_fullScreenOverlayIsDirty = false;
- iPhone_updateScreen(_mouseX - _mouseHotspotX, _mouseY - _mouseHotspotY);
+ iPhone_updateScreen(_mouseX, _mouseY);
}
void OSystem_IPHONE::internUpdateScreen() {
@@ -380,7 +380,7 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot
}
}
- iPhone_setMouseCursor(mouseBuf, w, h);
+ iPhone_setMouseCursor(mouseBuf, w, h, hotspotX, hotspotY);
if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) {
free(_mouseBuf);