[dasher: 8/21] MacOSX Multitouch (on 10.6 only)
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 8/21] MacOSX Multitouch (on 10.6 only)
- Date: Thu, 14 Jul 2011 17:31:49 +0000 (UTC)
commit 381afb879641c15ef81f0d79a08f7e9f31ed99c3
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Tue Jul 12 18:10:48 2011 +0100
MacOSX Multitouch (on 10.6 only)
Fingers after first are treated as extra buttons (101, 102, ...), e.g. for
activating turbo mode!
Src/MacOSX/DasherViewOpenGL.mm | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/Src/MacOSX/DasherViewOpenGL.mm b/Src/MacOSX/DasherViewOpenGL.mm
index 1e46787..4bf73b6 100755
--- a/Src/MacOSX/DasherViewOpenGL.mm
+++ b/Src/MacOSX/DasherViewOpenGL.mm
@@ -133,6 +133,34 @@ protected:
[dasherApp aquaDasherControl]->KeyUp(get_time(), 100+[e buttonNumber]);
}
+///The following gets called on MacOS 10.6 or later, only, for multitouch.
+/// (It won't work on earlier versions, but won't get called, either)
+- (void)touchesBeganWithEvent:(NSEvent *)event {
+ int totalTouches = [[event touchesMatchingPhase:NSUIntegerMax inView:self] count];
+ int newTouches = [[event touchesMatchingPhase:1 inView:self] count];
+ //Call KeyDown with id 101, 102, ... for successive new touches _except_the_first_
+ // (the first finger, id 100, is handled by MouseDown...)
+ for (int i=max(1,totalTouches-newTouches); i<totalTouches; i++)
+ [dasherApp aquaDasherControl]->KeyDown(get_time(), 100+i);
+}
+
+///The following gets called on MacOS 10.6 or later, only, for multitouch.
+/// (It won't work on earlier versions, but won't get called, either)
+-(void)touchesEndedWithEvent:(NSEvent *)event {
+ int totalTouches = [[event touchesMatchingPhase:NSUIntegerMax inView:self] count];
+ //note hardcoding of constant 24 = NSTouchPhaseEnded | NSTouchPhaseCancelled
+ // (allows compilation on pre-10.6 systems)
+ int endingTouches= [[event touchesMatchingPhase:24 inView:self] count];
+ //Call KeyUp with ids 101, 102, ..., highest first, as fingers are lifted from
+ // the touchpad. Not we don't do anything for the last finger to be lifted,
+ // as this is dealt with by MouseUp with id==100.
+ for (int i=totalTouches; i-->max(1,totalTouches-endingTouches);)
+ [dasherApp aquaDasherControl]->KeyUp(get_time(), 100+i);
+}
+
+-(void)touchesCancelledWithEvent:(NSEvent *)event {
+ [self touchesEndedWithEvent:event];
+}
- (void)keyDown:(NSEvent *)e {
[dasherApp handleKeyDown:e];
@@ -169,7 +197,12 @@ protected:
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
-
+
+ //On MacOS 10.6 and on, we'll look out for multitouch...
+ if ([self respondsToSelector:@selector(setAcceptsTouchEvents:)]) {
+ [self setAcceptsTouchEvents:YES];
+ [self setWantsRestingTouches:YES];
+ }
}
return self;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]