Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2006-08-03 16:23:00 +0400
committerMatt Ebb <matt@mke3.net>2006-08-03 16:23:00 +0400
commitc85de34c267983bfc5dca388d5bcf6f092cf60ee (patch)
tree1fe782d1a1691de1814758d52bf9ed72fa3850e3 /intern/ghost/intern/GHOST_SystemCarbon.cpp
parent454fceb5f51809974be2ba3620c24d4eff7cf3a3 (diff)
* Tablet Pressure support in GHOST
This is 'ported' from Nicholas Bishop's sculpting GSoC tree. I'm bringing it over now so a) it can be there for when lukep does his GHOST refactor b) it's something that GHOST should have anyway, particularly now there's interest in painting tools and c) it's missing support in Windows, so hopefully now some enterprising Windows coder can add that more easily in the main bf tree. Right now X11 and Mac OS X are supported. I added and can maintain the Mac OS X part, but I'm not familiar with the Xinput stuff, which Nicholas wrote. Both X11 and Mac are collecting active device and pressure, and Mac is also collecting x and y tilt data. Up to coders how they want to use this info! :) Although the data's coming in, I haven't actually made this do anything. I thought it best to leave it to brecht to figure out what he wants to do with the painting stuff, and I wonder what other interesting uses there could be for it (proportional edit?). I'll write implementation details in a separate mail to the committers list.
Diffstat (limited to 'intern/ghost/intern/GHOST_SystemCarbon.cpp')
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.cpp90
1 files changed, 85 insertions, 5 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp
index ef9e91ec3df..9e790154eb9 100644
--- a/intern/ghost/intern/GHOST_SystemCarbon.cpp
+++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp
@@ -688,6 +688,79 @@ OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event)
return err;
}
+OSStatus GHOST_SystemCarbon::handleTabletEvent(EventRef event)
+{
+ GHOST_IWindow* window = m_windowManager->getActiveWindow();
+ TabletPointRec tabletPointRecord;
+ TabletProximityRec tabletProximityRecord;
+ UInt32 anInt32;
+ GHOST_TabletData& ct=((GHOST_WindowCarbon*)window)->GetCarbonTabletData();
+ OSStatus err = eventNotHandledErr;
+
+ ct.Pressure = 0;
+ ct.Xtilt = 0;
+ ct.Ytilt = 0;
+
+ // is there an embedded tablet event inside this mouse event?
+ if(noErr == GetEventParameter(event, kEventParamTabletEventType, typeUInt32, NULL, sizeof(UInt32), NULL, (void *)&anInt32))
+ {
+ // yes there is one!
+ // Embedded tablet events can either be a proximity or pointer event.
+ if(anInt32 == kEventTabletPoint)
+ {
+ //GHOST_PRINT("Embedded pointer event!\n");
+
+ // Extract the tablet Pointer Event. If there is no Tablet Pointer data
+ // in this event, then this call will return an error. Just ignore the
+ // error and go on. This can occur when a proximity event is embedded in
+ // a mouse event and you did not check the mouse event to see which type
+ // of tablet event was embedded.
+ if(noErr == GetEventParameter(event, kEventParamTabletPointRec,
+ typeTabletPointRec, NULL,
+ sizeof(TabletPointRec),
+ NULL, (void *)&tabletPointRecord))
+ {
+ ct.Pressure = tabletPointRecord.pressure / 65535.0f;
+ ct.Xtilt = tabletPointRecord.tiltX / 32767.0f; /* can be positive or negative */
+ ct.Ytilt = tabletPointRecord.tiltY / 32767.0f; /* can be positive or negative */
+ }
+ } else {
+ //GHOST_PRINT("Embedded proximity event\n");
+
+ // Extract the Tablet Proximity record from the event.
+ if(noErr == GetEventParameter(event, kEventParamTabletProximityRec,
+ typeTabletProximityRec, NULL,
+ sizeof(TabletProximityRec),
+ NULL, (void *)&tabletProximityRecord))
+ {
+ if (tabletProximityRecord.enterProximity) {
+ //pointer is entering tablet area proximity
+
+ switch(tabletProximityRecord.pointerType)
+ {
+ case 1: /* stylus */
+ ct.Active = 1;
+ break;
+ case 2: /* puck, not supported so far */
+ ct.Active = 0;
+ break;
+ case 3: /* eraser */
+ ct.Active = 2;
+ break;
+ default:
+ ct.Active = 0;
+ break;
+ }
+ } else {
+ // pointer is leaving - return to mouse
+ ct.Active = 0;
+ }
+ }
+ }
+ err = noErr;
+ }
+}
+
OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event)
{
OSStatus err = eventNotHandledErr;
@@ -708,6 +781,9 @@ OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event)
/* Window still gets mouse up after command-H */
if (m_windowManager->getActiveWindow()) {
+ // handle any tablet events that may have come with the mouse event (optional)
+ handleTabletEvent(event);
+
::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button);
pushEvent(new GHOST_EventButton(getMilliSeconds(), type, window, convertButton(button)));
err = noErr;
@@ -716,15 +792,19 @@ OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event)
break;
case kEventMouseMoved:
- case kEventMouseDragged:
- Point mousePos;
+ case kEventMouseDragged: {
+ Point mousePos;
+
if (window) {
+ //handle any tablet events that may have come with the mouse event (optional)
+ handleTabletEvent(event);
+
::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos);
pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, mousePos.h, mousePos.v));
err = noErr;
- }
- break;
-
+ }
+ break;
+ }
case kEventMouseWheelMoved:
{
OSStatus status;