[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34351] branches/merwin-tablet-2/intern/ ghost/intern: minor hacking on Mac tablet

Mike Erwin significant.bit at gmail.com
Sun Jan 16 13:11:10 CET 2011


Revision: 34351
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34351
Author:   merwin
Date:     2011-01-16 12:11:09 +0000 (Sun, 16 Jan 2011)
Log Message:
-----------
minor hacking on Mac tablet

Modified Paths:
--------------
    branches/merwin-tablet-2/intern/ghost/intern/GHOST_SystemCocoa.mm
    branches/merwin-tablet-2/intern/ghost/intern/GHOST_WindowCocoa.mm

Modified: branches/merwin-tablet-2/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- branches/merwin-tablet-2/intern/ghost/intern/GHOST_SystemCocoa.mm	2011-01-16 11:26:01 UTC (rev 34350)
+++ branches/merwin-tablet-2/intern/ghost/intern/GHOST_SystemCocoa.mm	2011-01-16 12:11:09 UTC (rev 34351)
@@ -1453,12 +1453,12 @@
 	tablet.Xtilt = tilt.x;
 	tablet.Ytilt = tilt.y;
 
-	printf("   pressure = %.3f   tilt = %+.2f %+.2f\n", tablet.Pressure, tablet.Xtilt, tablet.Ytilt);
+//	printf("   pressure = %.3f   tilt = %+.2f %+.2f\n", tablet.Pressure, tablet.Xtilt, tablet.Ytilt);
 	}
 
 GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr)
 {
-	printf("tablet point ");
+//	printf("tablet point ");
 	NSEvent *event = (NSEvent*)eventPtr;
 	GHOST_WindowCocoa* window = (GHOST_WindowCocoa*)
 		m_windowManager->getWindowAssociatedWithOSWindow((void*)[event window]);
@@ -1471,8 +1471,10 @@
 	switch ([event type])
 		{
 		case NSLeftMouseDown:
+		case NSRightMouseDown:
+		case NSOtherMouseDown:
 			{
-			printf("down");
+			printf("tool button %d down\n", [event buttonNumber]);
 			[NSEvent setMouseCoalescingEnabled:NO];
 
 			GHOST_EventButton* e = new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonDown, window, convertButton([event buttonNumber]));
@@ -1483,8 +1485,10 @@
 			break;
 			}
 		case NSLeftMouseUp:
+		case NSRightMouseUp:
+		case NSOtherMouseUp:
 			{
-			printf("up");
+			printf("tool button %d up\n", [event buttonNumber]);
 			[NSEvent setMouseCoalescingEnabled:YES];
 
 			// no tablet data needed for 'pen up'
@@ -1501,9 +1505,9 @@
 			}
 		default:
 			{
-			printf("move ");
+//			printf("move ");
 			NSPoint pos = [event locationInWindow];
-			if (true) { // display some useful pen info
+			if (false) { // display some useful pen info
 				float event_dx = [event deltaX];
 				float event_dy = [event deltaY];
 				bool coalesced = [NSEvent isMouseCoalescingEnabled];
@@ -1525,7 +1529,6 @@
 
 GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
 {
-	printf("mouse ");
 	NSEvent *event = (NSEvent *)eventPtr;
 	GHOST_Window* window;
 
@@ -1540,7 +1543,7 @@
 		case NSLeftMouseDown:
 		case NSRightMouseDown:
 		case NSOtherMouseDown:
-			printf("button down\n");
+			printf("mouse button %d down\n", [event buttonNumber]);
 			[NSEvent setMouseCoalescingEnabled:NO];
 			pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonDown, window, convertButton([event buttonNumber])));
 			break;
@@ -1548,7 +1551,7 @@
 		case NSLeftMouseUp:
 		case NSRightMouseUp:
 		case NSOtherMouseUp:
-			printf("button up\n");
+			printf("mouse button %d up\n", [event buttonNumber]);
 			[NSEvent setMouseCoalescingEnabled:YES];
 			pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonUp, window, convertButton([event buttonNumber])));
 			break;
@@ -1557,8 +1560,8 @@
 		case NSRightMouseDragged:
 		case NSOtherMouseDragged:
 		case NSMouseMoved:
-			printf("move ");
-			if (true) { // display some useful mouse info
+//			printf("move ");
+			if (false) { // display some useful mouse info
 				NSPoint mousePos = [event locationInWindow];
 				float event_dx = [event deltaX];
 				float event_dy = [event deltaY];
@@ -1571,14 +1574,13 @@
 				case GHOST_kGrabHide: //Cursor hidden grab operation : no cursor move
 				{
 					GHOST_TInt32 x_warp, y_warp, x_accum, y_accum;
-					
+
 					window->getCursorGrabInitPos(x_warp, y_warp);
-					
 					window->getCursorGrabAccum(x_accum, y_accum);
 					x_accum += [event deltaX];
 					y_accum += -[event deltaY]; //Strange Apple implementation (inverted coordinates for the deltaY) ...
 					window->setCursorGrabAccum(x_accum, y_accum);
-					
+
 					pushEvent(new GHOST_EventCursor([event timestamp]*1000, GHOST_kEventCursorMove, window, x_warp+x_accum, y_warp+y_accum));
 				}
 					break;
@@ -1589,41 +1591,46 @@
 					GHOST_TInt32 y_mouse= mousePos.y;
 					GHOST_TInt32 x_accum, y_accum, x_cur, y_cur;
 					GHOST_Rect bounds, windowBounds, correctedBounds;
-					
+
 					/* fallback to window bounds */
 					if(window->getCursorGrabBounds(bounds)==GHOST_kFailure)
 						window->getClientBounds(bounds);
-					
+
 					//Switch back to Cocoa coordinates orientation (y=0 at bottom,the same as blender internal btw!), and to client coordinates
 					window->getClientBounds(windowBounds);
 					window->screenToClient(bounds.m_l,bounds.m_b, correctedBounds.m_l, correctedBounds.m_t);
 					window->screenToClient(bounds.m_r, bounds.m_t, correctedBounds.m_r, correctedBounds.m_b);
 					correctedBounds.m_b = (windowBounds.m_b - windowBounds.m_t) - correctedBounds.m_b;
 					correctedBounds.m_t = (windowBounds.m_b - windowBounds.m_t) - correctedBounds.m_t;
-					
+
 					//Update accumulation counts
 					window->getCursorGrabAccum(x_accum, y_accum);
 					x_accum += [event deltaX]-m_cursorDelta_x;
 					y_accum += -[event deltaY]-m_cursorDelta_y; //Strange Apple implementation (inverted coordinates for the deltaY) ...
 					window->setCursorGrabAccum(x_accum, y_accum);
-					
-					
+
 					//Warp mouse cursor if needed
 					x_mouse += [event deltaX]-m_cursorDelta_x;
 					y_mouse += -[event deltaY]-m_cursorDelta_y;
 					correctedBounds.wrapPoint(x_mouse, y_mouse, 2);
-					
+
 					//Compensate for mouse moved event taking cursor position set into account
 					m_cursorDelta_x = x_mouse-mousePos.x;
 					m_cursorDelta_y = y_mouse-mousePos.y;
-					
+
 					//Set new cursor position
 					window->clientToScreen(x_mouse, y_mouse, x_cur, y_cur);
 					setMouseCursorPosition(x_cur, y_cur); /* wrap */
-					
+
 					//Post event
 					window->getCursorGrabInitPos(x_cur, y_cur);
 					pushEvent(new GHOST_EventCursor([event timestamp]*1000, GHOST_kEventCursorMove, window, x_cur + x_accum, y_cur + y_accum));
+
+					printf("-- gangsta wrap --\n");
+					printf("position: %.2f %.2f\n", mousePos.x, mousePos.y);
+					printf("mouse: %d %d\n", x_mouse, y_mouse);
+					printf("delta: %.2f %.2f\n", [event deltaX], [event deltaY]);
+					printf("wrapped: %d %d\n", x_cur + x_accum, y_cur + y_accum);
 				}
 					break;
 				default:

Modified: branches/merwin-tablet-2/intern/ghost/intern/GHOST_WindowCocoa.mm
===================================================================
--- branches/merwin-tablet-2/intern/ghost/intern/GHOST_WindowCocoa.mm	2011-01-16 11:26:01 UTC (rev 34350)
+++ branches/merwin-tablet-2/intern/ghost/intern/GHOST_WindowCocoa.mm	2011-01-16 12:11:09 UTC (rev 34351)
@@ -305,7 +305,7 @@
 NSOpenGLContext* GHOST_WindowCocoa::s_firstOpenGLcontext = nil;
 
 GHOST_WindowCocoa::GHOST_WindowCocoa(
-	GHOST_SystemCocoa *systemCocoa,
+	GHOST_SystemCocoa *sys,
 	const STR_String& title,
 	GHOST_TInt32 left,
 	GHOST_TInt32 top,
@@ -322,7 +322,7 @@
 	NSOpenGLPixelFormat *pixelFormat = nil;
 	int i;
 		
-	m_ghostSystem = systemCocoa;
+	m_ghostSystem = sys;
 	m_fullScreen = false;
 	
 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -330,7 +330,7 @@
 
 	//Creates the window
 	NSRect rect;
-	NSSize	minSize;
+	NSSize minSize;
 	
 	rect.origin.x = left;
 	rect.origin.y = top;
@@ -345,7 +345,7 @@
 		return;
 	}
 	
-	[m_window setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
+	[m_window setSystemAndWindowCocoa:sys windowCocoa:this];
 	
 	//Forbid to resize the window below the blender defined minimum one
 	minSize.width = 320;
@@ -410,7 +410,6 @@
 		pixelFormatAttrsWindow[i] = (NSOpenGLPixelFormatAttribute) 0;
 		
 		pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttrsWindow];
-		
 	}
 	
 	if (numOfAASamples>0) { //Set m_numOfAASamples to the actual value
@@ -435,7 +434,7 @@
 	
 	[m_window setReleasedWhenClosed:NO]; //To avoid bad pointer exception in case of user closing the window
 	
-	[m_window makeKeyAndOrderFront:nil];
+	[m_window makeKeyAndOrderFront:nil]; // [mce] this doesn't seem to work when launched from command-line!
 	
 	setDrawingContextType(type);
 	updateDrawingContext();
@@ -1208,11 +1207,11 @@
 			screenToClient(x_old, y_old, m_cursorGrabInitPos[0], m_cursorGrabInitPos[1]);
 			//Warp position is stored in client (window base) coordinates
 			setCursorGrabAccum(0, 0);
-			
+
 			if(mode == GHOST_kGrabHide) {
 				setWindowCursorVisibility(false);
 			}
-			
+
 			//Make window key if it wasn't to get the mouse move events
 			[m_window makeKeyWindow];
 			




More information about the Bf-blender-cvs mailing list