[Scummvm-cvs-logs] SF.net SVN: scummvm: [29629] scummvm/trunk/backends/platform/iphone
vinterstum at users.sourceforge.net
vinterstum at users.sourceforge.net
Sat Nov 24 22:45:39 CET 2007
Revision: 29629
http://scummvm.svn.sourceforge.net/scummvm/?rev=29629&view=rev
Author: vinterstum
Date: 2007-11-24 13:45:39 -0800 (Sat, 24 Nov 2007)
Log Message:
-----------
Now always sending a mouse-moved event before a click (some engines don't update the mouse position on click events, it seems). Also added a workaround for an event not always being received when the secondary finger is lifted from the touchscreen.
Modified Paths:
--------------
scummvm/trunk/backends/platform/iphone/iphone_common.h
scummvm/trunk/backends/platform/iphone/iphone_video.h
scummvm/trunk/backends/platform/iphone/iphone_video.m
scummvm/trunk/backends/platform/iphone/osys_iphone.cpp
Modified: scummvm/trunk/backends/platform/iphone/iphone_common.h
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_common.h 2007-11-24 18:10:27 UTC (rev 29628)
+++ scummvm/trunk/backends/platform/iphone/iphone_common.h 2007-11-24 21:45:39 UTC (rev 29629)
@@ -43,6 +43,7 @@
// On the ObjC side
void iPhone_updateScreen();
+void iPhone_updateScreenRect(int x1, int y1, int x2, int y2);
unsigned short* iPhone_getSurface();
void iPhone_lockSurface();
void iPhone_unlockSurface();
Modified: scummvm/trunk/backends/platform/iphone/iphone_video.h
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_video.h 2007-11-24 18:10:27 UTC (rev 29628)
+++ scummvm/trunk/backends/platform/iphone/iphone_video.h 2007-11-24 21:45:39 UTC (rev 29629)
@@ -35,6 +35,14 @@
#import "iphone_keyboard.h"
+typedef enum
+{
+ kUIViewSwipeUp = 1,
+ kUIViewSwipeDown = 2,
+ kUIViewSwipeLeft = 4,
+ kUIViewSwipeRight = 8
+} UIViewSwipeDirection;
+
@interface iPhoneView : UIView
{
CoreSurfaceBufferRef _screenSurface;
@@ -57,7 +65,7 @@
- (void)initSurface;
-- (void)updateScreen;
+- (void)updateScreenRect:(id)rect;
- (id)getEvent;
Modified: scummvm/trunk/backends/platform/iphone/iphone_video.m
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_video.m 2007-11-24 18:10:27 UTC (rev 29628)
+++ scummvm/trunk/backends/platform/iphone/iphone_video.m 2007-11-24 21:45:39 UTC (rev 29629)
@@ -49,9 +49,14 @@
}
void iPhone_updateScreen() {
- [sharedInstance performSelectorOnMainThread:@selector(updateScreen) withObject:nil waitUntilDone: NO];
+ [sharedInstance performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone: NO];
}
+void iPhone_updateScreenRect(int x1, int y1, int x2, int y2) {
+ NSRect rect = NSMakeRect(x1, y1, x2, y2);
+ [sharedInstance performSelectorOnMainThread:@selector(updateScreenRect:) withObject: [NSValue valueWithRect:rect] waitUntilDone: NO];
+}
+
void iPhone_lockSurface() {
CoreSurfaceBufferLock([sharedInstance getSurface], 3);
}
@@ -110,6 +115,7 @@
sharedInstance = self;
_keyboardView = nil;
+ //[super setTapDelegate: self];
return self;
}
@@ -139,8 +145,10 @@
// }
}
-- (void)updateScreen {
- [sharedInstance setNeedsDisplay];
+- (void)updateScreenRect:(id)rect {
+ NSRect nsRect = [rect rectValue];
+ CGRect cgRect = CGRectMake(nsRect.origin.x, nsRect.origin.y, nsRect.size.width, nsRect.size.height);
+ [sharedInstance setNeedsDisplayInRect: cgRect];
}
- (void)initSurface {
@@ -324,7 +332,7 @@
}
- (void)mouseEntered:(GSEvent*)event {
- printf("mouseEntered()\n");
+ //printf("mouseEntered()\n");
// struct CGPoint point = GSEventGetLocationInWindow(event);
//
// if (!getLocalMouseCoords(&point))
@@ -341,7 +349,7 @@
}
- (void)mouseExited:(GSEvent*)event {
- printf("mouseExited().\n");
+ //printf("mouseExited().\n");
// [self addEvent:
// [[NSDictionary alloc] initWithObjectsAndKeys:
// @"mouseExited", @"type",
@@ -352,7 +360,7 @@
- (void)mouseMoved:(GSEvent*)event
{
- printf("mouseMoved()\n");
+ //printf("mouseMoved()\n");
struct CGPoint point = GSEventGetLocationInWindow(event);
if (!getLocalMouseCoords(&point))
@@ -379,5 +387,17 @@
];
}
+- (BOOL)canHandleSwipes {
+ return FALSE;
+}
+
+- (int)swipe:(UIViewSwipeDirection)num withEvent:(GSEvent*)event {
+ //printf("swipe: %i\n", num);
+}
+
+- (void)view:(UIView *)view handleTapWithCount:(int)count event:(GSEvent *)event fingerCount:(int)fingerCount{
+ //printf("handleTapWithCount(%i, %i)\n", count, fingerCount);
+}
+
@end
Modified: scummvm/trunk/backends/platform/iphone/osys_iphone.cpp
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_iphone.cpp 2007-11-24 18:10:27 UTC (rev 29628)
+++ scummvm/trunk/backends/platform/iphone/osys_iphone.cpp 2007-11-24 21:45:39 UTC (rev 29629)
@@ -366,6 +366,8 @@
}
}
}
+
+ //iPhone_updateScreenRect(dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom );
}
}
@@ -561,19 +563,25 @@
case kInputMouseDown:
//printf("Mouse down at (%u, %u)\n", x, y);
+ // Workaround: kInputMouseSecondToggled isn't always sent when the
+ // secondary finger is lifted. Need to make sure we get out of that mode.
+ _secondaryTapped = false;
+
warpMouse(x, y);
+ event.type = Common::EVENT_MOUSEMOVE;
+ event.mouse.x = _mouseX;
+ event.mouse.y = _mouseY;
+
if (_mouseClickAndDragEnabled) {
- event.type = Common::EVENT_LBUTTONDOWN;
- event.mouse.x = _mouseX;
- event.mouse.y = _mouseY;
- } else {
+ _queuedInputEvent.type = Common::EVENT_LBUTTONDOWN;
+ _queuedInputEvent.mouse.x = _mouseX;
+ _queuedInputEvent.mouse.y = _mouseY;
+ } else {
_lastMouseDown = curTime;
- return false;
}
break;
case kInputMouseUp:
//printf("Mouse up at (%u, %u)\n", x, y);
-
if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_LBUTTONUP;
event.mouse.x = _mouseX;
@@ -628,8 +636,14 @@
} else if (vecXNorm > -0.50 && vecXNorm < 0.50 && vecYNorm < -0.75) {
// Swipe up
_mouseClickAndDragEnabled = !_mouseClickAndDragEnabled;
- GUI::TimedMessageDialog dialog("Toggling mouse-click-and-drag mode.", 1500);
+ const char *dialogMsg;
+ if (_mouseClickAndDragEnabled)
+ dialogMsg = "Mouse-click-and-drag mode enabled.";
+ else
+ dialogMsg = "Mouse-click-and-drag mode disabled.";
+ GUI::TimedMessageDialog dialog(dialogMsg, 1500);
dialog.runModal();
+
} else if (vecXNorm > 0.75 && vecYNorm > -0.5 && vecYNorm < 0.5) {
// Swipe right
// _secondaryTapped = !_secondaryTapped;
@@ -655,7 +669,7 @@
break;
case kInputMouseSecondToggled:
_secondaryTapped = !_secondaryTapped;
- printf("Mouse second at (%u, %u). State now %s.\n", x, y, _secondaryTapped ? "on" : "off");
+ //printf("Mouse second at (%u, %u). State now %s.\n", x, y, _secondaryTapped ? "on" : "off");
if (_secondaryTapped) {
_lastSecondaryDown = curTime;
_gestureStartX = x;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list