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:
authorMike Erwin <significant.bit@gmail.com>2010-08-13 04:34:57 +0400
committerMike Erwin <significant.bit@gmail.com>2010-08-13 04:34:57 +0400
commit7428380cc366025ae51f6245a5d0a837a7210c8d (patch)
tree07683cb431e377c150777fa0ef13b056dfdfb826
parentfc5c4d98f4a52b7e405efed307427ace4a593f7b (diff)
still working on tablet for Windows...
-rw-r--r--intern/ghost/intern/GHOST_Buttons.cpp5
-rw-r--r--intern/ghost/intern/GHOST_Buttons.h9
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp11
-rw-r--r--intern/ghost/intern/GHOST_TabletManagerWin32.cpp194
-rw-r--r--intern/ghost/intern/GHOST_TabletManagerWin32.h2
5 files changed, 150 insertions, 71 deletions
diff --git a/intern/ghost/intern/GHOST_Buttons.cpp b/intern/ghost/intern/GHOST_Buttons.cpp
index edccb24d5a1..8b46d777dbb 100644
--- a/intern/ghost/intern/GHOST_Buttons.cpp
+++ b/intern/ghost/intern/GHOST_Buttons.cpp
@@ -71,4 +71,9 @@ void GHOST_Buttons::clear()
m_ButtonRight = false;
}
+bool GHOST_Buttons::anyDown() const
+{
+ return m_ButtonLeft || m_ButtonMiddle || m_ButtonRight;
+}
+
GHOST_Buttons::~GHOST_Buttons() {}
diff --git a/intern/ghost/intern/GHOST_Buttons.h b/intern/ghost/intern/GHOST_Buttons.h
index 3dd10af0112..b35f68e4400 100644
--- a/intern/ghost/intern/GHOST_Buttons.h
+++ b/intern/ghost/intern/GHOST_Buttons.h
@@ -67,8 +67,13 @@ struct GHOST_Buttons {
/**
* Sets the state of all buttons to up.
*/
- virtual void clear();
-
+ virtual void clear();
+
+ /**
+ * Are any buttons currently pressed?
+ */
+ bool anyDown() const;
+
GHOST_TUns8 m_ButtonLeft : 1;
GHOST_TUns8 m_ButtonMiddle : 1;
GHOST_TUns8 m_ButtonRight : 1;
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index ee2484ec1dd..b8673ef3963 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -506,8 +506,9 @@ bool eventIsFromTablet()
GHOST_EventButton* GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TButtonMask mask)
{
- if (eventIsFromTablet())
- return NULL;
+ puts("ghost button event");
+// if (eventIsFromTablet())
+// return NULL;
return new GHOST_EventButton (getSystem()->getMilliSeconds(), type, window, mask);
}
@@ -932,7 +933,7 @@ bool GHOST_SystemWin32::handleEvent(GHOST_WindowWin32* window, UINT msg, WPARAM
// Tablet events, processed
////////////////////////////////////////////////////////////////////////
case WT_PACKET:
- m_tabletManager->processPackets((HCTX)lParam);
+ m_tabletManager->processPackets(window);
break;
case WT_CSRCHANGE:
m_tabletManager->changeTool((HCTX)lParam, wParam);
@@ -1002,10 +1003,10 @@ bool GHOST_SystemWin32::handleEvent(GHOST_WindowWin32* window, UINT msg, WPARAM
if (m_input_fidelity_hint == HI_FI)
{
- int buttons;
+ GHOST_Buttons buttons;
getButtons(buttons);
// don't bother grabbing extra mouse motion unless we're in a stroke
- if (buttons)
+ if (buttons.anyDown())
{
// int n =
getMoreMousePoints(mousePosX, mousePosY, xPrev, yPrev, window);
diff --git a/intern/ghost/intern/GHOST_TabletManagerWin32.cpp b/intern/ghost/intern/GHOST_TabletManagerWin32.cpp
index 864cf632d06..0b69dcb300d 100644
--- a/intern/ghost/intern/GHOST_TabletManagerWin32.cpp
+++ b/intern/ghost/intern/GHOST_TabletManagerWin32.cpp
@@ -3,6 +3,9 @@
#include "GHOST_TabletManagerWin32.h"
#include "GHOST_WindowWin32.h"
+#include "GHOST_System.h"
+#include "GHOST_EventCursor.h"
+#include "GHOST_EventButton.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -162,20 +165,39 @@ void GHOST_TabletManagerWin32::openForWindow(GHOST_WindowWin32* window)
// set up context
LOGCONTEXT archetype;
- func_Info(WTI_DEFSYSCTX, 0, &archetype);
+// func_Info(WTI_DEFSYSCTX, 0, &archetype);
+ func_Info(WTI_DEFCONTEXT, 0, &archetype);
strcpy(archetype.lcName, "blender special");
archetype.lcPktData = PACKETDATA;
archetype.lcPktMode = PACKETMODE;
- archetype.lcOptions |= CXO_MESSAGES | CXO_CSRMESSAGES;
-
-/*
- if (hasTilt)
+// archetype.lcOptions |= CXO_MESSAGES | CXO_CSRMESSAGES;
+ archetype.lcOptions |= CXO_SYSTEM | CXO_MESSAGES | CXO_CSRMESSAGES;
+
+ // we want first 5 buttons
+ archetype.lcBtnDnMask = 0x1f;
+ archetype.lcBtnUpMask = 0x1f;
+
+// BEGIN derived from Wacom's TILTTEST.C:
+ AXIS TabletX, TabletY;
+ func_Info(WTI_DEVICES,DVC_X,&TabletX);
+ func_Info(WTI_DEVICES,DVC_Y,&TabletY);
+ archetype.lcInOrgX = 0;
+ archetype.lcInOrgY = 0;
+ archetype.lcInExtX = TabletX.axMax;
+ archetype.lcInExtY = TabletY.axMax;
+ /* output the data in screen coords */
+ archetype.lcOutOrgX = archetype.lcOutOrgY = 0;
+ archetype.lcOutExtX = GetSystemMetrics(SM_CXSCREEN);
+ /* move origin to upper left */
+ archetype.lcOutExtY = -GetSystemMetrics(SM_CYSCREEN);
+// END
+
+/* if (hasTilt)
{
archetype.lcPktData |= tiltMask;
archetype.lcMoveMask |= tiltMask;
- }
-*/
+ } */
// open the context
HCTX context = func_Open(window->getHWND(), &archetype, TRUE);
@@ -237,71 +259,117 @@ void GHOST_TabletManagerWin32::convertTilt(ORIENTATION const& ort, TabletToolDat
data.tilt_y = sin(M_PI/2.0 - azmRad) * vecLen;
}
-void GHOST_TabletManagerWin32::processPackets(HCTX context)
+void GHOST_TabletManagerWin32::processPackets(GHOST_WindowWin32* window)
{
- PACKET packets[MAX_QUEUE_SIZE];
- int n = func_PacketsGet(context, MAX_QUEUE_SIZE, packets);
-// printf("processing %d packets\n", n);
+ HCTX context = contextForWindow(window);
- for (int i = 0; i < n; ++i)
+ if (context)
{
- PACKET const& packet = packets[i];
- TabletToolData data = {activeTool};
- int x = packet.pkX;
- int y = packet.pkY;
-
- if (activeTool.type == TABLET_MOUSE)
- if (x == prevMouseX && y == prevMouseY)
- // don't send any "mouse hasn't moved" events
- continue;
- else {
- prevMouseX = x;
- prevMouseY = y;
- }
-
- // every packet from a WT_PACKET message comes from the same tool
- switch (activeTool.type)
- {
- case TABLET_MOUSE:
- printf("mouse");
- break;
- case TABLET_PEN:
- printf("pen");
- break;
- case TABLET_ERASER:
- printf("eraser");
- break;
- default:
- printf("???");
- }
-
- printf(" (%d,%d)", x, y);
-
- if (activeTool.hasPressure)
+ PACKET packets[MAX_QUEUE_SIZE];
+ int n = func_PacketsGet(context, MAX_QUEUE_SIZE, packets);
+ // printf("processing %d packets\n", n);
+
+ for (int i = 0; i < n; ++i)
{
- if (packet.pkNormalPressure)
+ PACKET const& packet = packets[i];
+ TabletToolData data = {activeTool};
+ int x = packet.pkX;
+ int y = packet.pkY;
+
+ if (activeTool.type == TABLET_MOUSE)
+ if (x == prevMouseX && y == prevMouseY)
+ // don't send any "mouse hasn't moved" events
+ continue;
+ else {
+ prevMouseX = x;
+ prevMouseY = y;
+ }
+
+ // every packet from a WT_PACKET message comes from the same tool
+ switch (activeTool.type)
{
- data.pressure = pressureScale * packet.pkNormalPressure;
- printf(" %d%%", (int)(100 * data.pressure));
+ case TABLET_MOUSE:
+ printf("mouse");
+ break;
+ case TABLET_PEN:
+ printf("pen");
+ break;
+ case TABLET_ERASER:
+ printf("eraser");
+ break;
+ default:
+ printf("???");
}
- else
- data.tool.hasPressure = false;
- }
+
+ printf(" (%d,%d)", x, y);
+
+ if (activeTool.hasPressure)
+ {
+ if (packet.pkNormalPressure)
+ {
+ data.pressure = pressureScale * packet.pkNormalPressure;
+ printf(" %d%%", (int)(100 * data.pressure));
+ }
+ else
+ data.tool.hasPressure = false;
+ }
+
+ if (activeTool.hasTilt)
+ {
+ // ORIENTATION const& tilt = packet.pkOrientation;
+ // printf(" /%d,%d/", tilt.orAzimuth, tilt.orAltitude);
+ convertTilt(packet.pkOrientation, data);
+
+ // data.tilt_x = tiltScaleX * packet.pkTilt.tiltX;
+ // data.tilt_y = tiltScaleY * packet.pkTilt.tiltY;
+ printf(" /%.2f,%.2f/", data.tilt_x, data.tilt_y);
+ }
+
+ putchar('\n');
- if (activeTool.hasTilt)
- {
- // ORIENTATION const& tilt = packet.pkOrientation;
- // printf(" /%d,%d/", tilt.orAzimuth, tilt.orAltitude);
- convertTilt(packet.pkOrientation, data);
+ // at this point, construct a GHOST event and push it into the queue!
+ // (having trouble with Wacom mouse scaling, so ignore it for now)
- // data.tilt_x = tiltScaleX * packet.pkTilt.tiltX;
- // data.tilt_y = tiltScaleY * packet.pkTilt.tiltY;
- printf(" /%.2f,%.2f/", data.tilt_x, data.tilt_y);
+// if (activeTool.type == TABLET_PEN || activeTool.type == TABLET_ERASER)
+ {
+ GHOST_System* system = (GHOST_System*) GHOST_ISystem::getSystem();
+
+ if (packet.pkButtons)
+ {
+ // which button?
+ GHOST_TButtonMask e_button;
+ int buttonNumber = LOWORD(packet.pkButtons);
+ e_button = (GHOST_TButtonMask) buttonNumber;
+
+ // pressed or released?
+ GHOST_TEventType e_action;
+ int buttonAction = HIWORD(packet.pkButtons);
+ if (buttonAction == TBN_DOWN)
+ e_action = GHOST_kEventButtonDown;
+ else
+ e_action = GHOST_kEventButtonUp;
+
+ printf("button %d %s\n", buttonNumber, buttonAction == TBN_DOWN ? "down" : "up");
+
+ GHOST_EventButton* e = new GHOST_EventButton(system->getMilliSeconds(), e_action, window, e_button);
+
+// system->pushEvent(e);
+ }
+ else
+ {
+ GHOST_EventCursor* e = new GHOST_EventCursor(system->getMilliSeconds(), GHOST_kEventCursorMove, window, x, y);
+
+ // use older TabletData struct for testing until mine is in place
+ GHOST_TabletData& e_data = ((GHOST_TEventCursorData*) e->getData())->tablet;
+ e_data.Active = (GHOST_TTabletMode) data.tool.type;
+ e_data.Pressure = data.pressure;
+ e_data.Xtilt = data.tilt_x;
+ e_data.Ytilt = data.tilt_y;
+
+// system->pushEvent(e);
+ }
+ }
}
-
- putchar('\n');
-
- // at this point, construct a GHOST event and push it into the queue!
}
}
diff --git a/intern/ghost/intern/GHOST_TabletManagerWin32.h b/intern/ghost/intern/GHOST_TabletManagerWin32.h
index 5686684e12a..290798a6bfb 100644
--- a/intern/ghost/intern/GHOST_TabletManagerWin32.h
+++ b/intern/ghost/intern/GHOST_TabletManagerWin32.h
@@ -90,7 +90,7 @@ public:
void openForWindow(GHOST_WindowWin32*);
void closeForWindow(GHOST_WindowWin32*);
- void processPackets(HCTX);
+ void processPackets(GHOST_WindowWin32*);
void changeTool(HCTX, UINT serialNumber);
void dropTool();