forked from bartvdbraak/blender
continued Win32 tablet hackery
This commit is contained in:
parent
7428380cc3
commit
91e2a55171
@ -35,6 +35,7 @@ GHOST_Buttons::GHOST_Buttons()
|
||||
clear();
|
||||
}
|
||||
|
||||
GHOST_Buttons::~GHOST_Buttons() {}
|
||||
|
||||
bool GHOST_Buttons::get(GHOST_TButtonMask mask) const
|
||||
{
|
||||
@ -75,5 +76,3 @@ bool GHOST_Buttons::anyDown() const
|
||||
{
|
||||
return m_ButtonLeft || m_ButtonMiddle || m_ButtonRight;
|
||||
}
|
||||
|
||||
GHOST_Buttons::~GHOST_Buttons() {}
|
||||
|
@ -247,6 +247,9 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent)
|
||||
}
|
||||
} while (waitForEvent && !anyProcessed);
|
||||
|
||||
if (m_tabletManager->processPackets())
|
||||
anyProcessed = true;
|
||||
|
||||
return anyProcessed;
|
||||
}
|
||||
|
||||
@ -500,15 +503,28 @@ void GHOST_SystemWin32::processModifierKeys(GHOST_IWindow *window)
|
||||
|
||||
bool eventIsFromTablet()
|
||||
{
|
||||
// bool IsFromPen = ((GetMessageExtraInfo() & 0xFF515700) == 0xFF515700); // this only works on TabletPCs
|
||||
return GetMessageExtraInfo() & 0x7f; // true for tablet mouse, not just pen
|
||||
// this (apparently) gives the packet serial number, which only tablet events have
|
||||
return GetMessageExtraInfo() != 0;
|
||||
// bool IsFromPen = ((GetMessageExtraInfo() & 0xFF515700) == 0xFF515700); // this only works on TabletPCs
|
||||
// static int all_magic = 0;
|
||||
// int magic = GetMessageExtraInfo();
|
||||
// all_magic |= magic;
|
||||
// printf("from tablet? %08x %08x\n", magic, all_magic);
|
||||
// return magic & 0x7f; // true for tablet mouse, not just pen
|
||||
}
|
||||
|
||||
GHOST_EventButton* GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TButtonMask mask)
|
||||
{
|
||||
puts("ghost button event");
|
||||
// if (eventIsFromTablet())
|
||||
// return NULL;
|
||||
if (eventIsFromTablet())
|
||||
return NULL;
|
||||
|
||||
static GHOST_Buttons buttons;
|
||||
if (type == GHOST_kEventButtonUp && !buttons.get(mask))
|
||||
// discard rogue button up events (probably from tablet)
|
||||
return NULL;
|
||||
buttons.set(mask, type == GHOST_kEventButtonDown);
|
||||
|
||||
printf("system button %d %s\n", mask, (type == GHOST_kEventButtonDown) ? "down" : (type == GHOST_kEventButtonUp) ? "up" : "???");
|
||||
|
||||
return new GHOST_EventButton (getSystem()->getMilliSeconds(), type, window, mask);
|
||||
}
|
||||
@ -516,6 +532,8 @@ GHOST_EventButton* GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type,
|
||||
|
||||
GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, GHOST_IWindow *Iwindow, int x_screen, int y_screen)
|
||||
{
|
||||
printf("system cursor (%d,%d)\n", x_screen, y_screen);
|
||||
|
||||
GHOST_SystemWin32 * system = ((GHOST_SystemWin32 * ) getSystem());
|
||||
GHOST_WindowWin32 * window = ( GHOST_WindowWin32 * ) Iwindow;
|
||||
|
||||
@ -933,10 +951,11 @@ bool GHOST_SystemWin32::handleEvent(GHOST_WindowWin32* window, UINT msg, WPARAM
|
||||
// Tablet events, processed
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
case WT_PACKET:
|
||||
puts("WT_PACKET");
|
||||
m_tabletManager->processPackets(window);
|
||||
break;
|
||||
case WT_CSRCHANGE:
|
||||
m_tabletManager->changeTool((HCTX)lParam, wParam);
|
||||
m_tabletManager->changeTool(window, wParam);
|
||||
break;
|
||||
case WT_PROXIMITY:
|
||||
if (LOWORD(lParam) == 0)
|
||||
@ -1034,8 +1053,10 @@ bool GHOST_SystemWin32::handleEvent(GHOST_WindowWin32* window, UINT msg, WPARAM
|
||||
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, raw_ptr, &rawSize, sizeof(RAWINPUTHEADER));
|
||||
eventSent |= processRawInput(raw, window);
|
||||
|
||||
// necessary?
|
||||
// DefRawInputProc(&raw_ptr, 1, sizeof(RAWINPUTHEADER));
|
||||
if (processRawInput(raw, window))
|
||||
eventSent = true;
|
||||
// else
|
||||
// DefRawInputProc(&raw_ptr, 1, sizeof(RAWINPUTHEADER));
|
||||
|
||||
#if 0
|
||||
#define RAWCOUNT 10
|
||||
@ -1067,7 +1088,7 @@ bool GHOST_SystemWin32::handleEvent(GHOST_WindowWin32* window, UINT msg, WPARAM
|
||||
}
|
||||
|
||||
// clear processed events from the queue
|
||||
DefRawInputProc((RAWINPUT**)&rawBuffer, n, sizeof(RAWINPUTHEADER));
|
||||
// DefRawInputProc((RAWINPUT**)&rawBuffer, n, sizeof(RAWINPUTHEADER));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -11,14 +11,28 @@
|
||||
#include <math.h>
|
||||
|
||||
#define PACKETDATA PK_CURSOR | PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION
|
||||
#define PACKETMODE PK_BUTTONS
|
||||
#define PACKETMODE 0 /*PK_BUTTONS*/
|
||||
// #define PACKETTILT PKEXT_ABSOLUTE
|
||||
|
||||
#include "pktdef.h"
|
||||
|
||||
#define MAX_QUEUE_SIZE 100
|
||||
|
||||
static void print(AXIS const& t, char const* label = NULL)
|
||||
{
|
||||
const char* unitName[] = {"dinosaur","inch","cm","circle"};
|
||||
|
||||
if (label)
|
||||
printf("%s: ", label);
|
||||
|
||||
printf("%d to %d, %d.%d per %s\n",
|
||||
t.axMin, t.axMax,
|
||||
HIWORD(t.axResolution), LOWORD(t.axResolution),
|
||||
unitName[t.axUnits]);
|
||||
}
|
||||
|
||||
GHOST_TabletManagerWin32::GHOST_TabletManagerWin32()
|
||||
: activeWindow(NULL)
|
||||
{
|
||||
dropTool();
|
||||
|
||||
@ -46,56 +60,45 @@ GHOST_TabletManagerWin32::GHOST_TabletManagerWin32()
|
||||
if (func_Info(WTI_DEVICES, DVC_NAME, tabletName))
|
||||
puts(tabletName);
|
||||
|
||||
puts("active tablet area");
|
||||
AXIS xRange, yRange;
|
||||
func_Info(WTI_DEVICES, DVC_X, &xRange);
|
||||
func_Info(WTI_DEVICES, DVC_Y, &yRange);
|
||||
print(xRange,"x"); print(yRange,"y");
|
||||
|
||||
printf("active area: %dx%d\n", xRange.axMax, yRange.axMax);
|
||||
|
||||
func_Info(WTI_DEVICES, DVC_NCSRTYPES, &cursorCount);
|
||||
func_Info(WTI_DEVICES, DVC_FIRSTCSR, &cursorBase);
|
||||
|
||||
puts("pressure sensitivity");
|
||||
AXIS pressureRange;
|
||||
hasPressure = func_Info(WTI_DEVICES, DVC_NPRESSURE, &pressureRange);// && pressureRange.axMax != 0;
|
||||
print(pressureRange);
|
||||
|
||||
printf("pressure sensitivity: ");
|
||||
if (hasPressure)
|
||||
{
|
||||
printf("%d to %d\n", pressureRange.axMin, pressureRange.axMax);
|
||||
pressureScale = 1.f / pressureRange.axMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("none\n");
|
||||
pressureScale = 0.f;
|
||||
}
|
||||
|
||||
printf("tilt sensitivity:\n");
|
||||
puts("tilt sensitivity");
|
||||
AXIS tiltRange[3];
|
||||
hasTilt = func_Info(WTI_DEVICES, DVC_ORIENTATION, tiltRange);
|
||||
|
||||
if (hasTilt)
|
||||
{
|
||||
// leave this code in place to help support tablets I haven't tested
|
||||
const char* axisName[] = {"azimuth","altitude","twist"};
|
||||
for (int i = 0; i < 3; ++i)
|
||||
print(tiltRange[i], axisName[i]);
|
||||
|
||||
// cheat by using available data from Intuos4. test on other tablets!!!
|
||||
azimuthScale = 1.f / HIWORD(tiltRange[1].axResolution);
|
||||
altitudeScale = 1.f / tiltRange[1].axMax;
|
||||
|
||||
// leave this code in place to help support tablets I haven't tested
|
||||
const char* axisName[] = {"azimuth","altitude","twist"};
|
||||
const char* unitName[] = {NULL,"inch","cm","circle"};
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
AXIS const& t = tiltRange[i];
|
||||
if (t.axResolution)
|
||||
printf("%s: %d to %d values per %d.%d %s\n",
|
||||
axisName[i], t.axMin, t.axMax,
|
||||
HIWORD(t.axResolution), LOWORD(t.axResolution),
|
||||
unitName[t.axUnits]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("none\n");
|
||||
puts("none");
|
||||
azimuthScale = altitudeScale = 0.f;
|
||||
}
|
||||
|
||||
#if 0 // WTX_TILT -- cartesian tilt extension, no conversion needed
|
||||
@ -106,7 +109,6 @@ GHOST_TabletManagerWin32::GHOST_TabletManagerWin32()
|
||||
UINT extensionCount;
|
||||
func_Info(WTI_INTERFACE, IFC_NEXTENSIONS, &extensionCount);
|
||||
for (UINT i = 0; i < extensionCount; ++i)
|
||||
// for (UINT i = 0; func_Info(WTI_EXTENSIONS + i, EXT_TAG, &tag); ++i)
|
||||
{
|
||||
printf("trying extension %d\n", i);
|
||||
func_Info(WTI_EXTENSIONS + i, EXT_TAG, &tag);
|
||||
@ -119,17 +121,17 @@ GHOST_TabletManagerWin32::GHOST_TabletManagerWin32()
|
||||
|
||||
if (hasTilt)
|
||||
{
|
||||
func_Info(WTI_EXTENSIONS + tag, EXT_MASK, &tiltMask);
|
||||
AXIS tiltRange[2];
|
||||
func_Info(WTI_EXTENSIONS + tag, EXT_AXES, tiltRange);
|
||||
printf("%d to %d along x\n", tiltRange[0].axMin, tiltRange[0].axMax);
|
||||
printf("%d to %d along y\n", tiltRange[1].axMin, tiltRange[1].axMax);
|
||||
print("x", tiltRange[0]);
|
||||
print("y", tiltRange[1]);
|
||||
tiltScaleX = 1.f / tiltRange[0].axMax;
|
||||
tiltScaleY = 1.f / tiltRange[1].axMax;
|
||||
func_Info(WTI_EXTENSIONS + tag, EXT_MASK, &tiltMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("none\n");
|
||||
puts("none");
|
||||
tiltScaleX = tiltScaleY = 0.f;
|
||||
}
|
||||
#endif // WTX_TILT
|
||||
@ -165,18 +167,27 @@ void GHOST_TabletManagerWin32::openForWindow(GHOST_WindowWin32* window)
|
||||
|
||||
// set up context
|
||||
LOGCONTEXT archetype;
|
||||
// func_Info(WTI_DEFSYSCTX, 0, &archetype);
|
||||
func_Info(WTI_DEFCONTEXT, 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;
|
||||
archetype.lcOptions |= CXO_SYSTEM | CXO_MESSAGES | CXO_CSRMESSAGES;
|
||||
|
||||
WTPKT packetData = PACKETDATA;
|
||||
if (!hasPressure)
|
||||
packetData &= ~PK_NORMAL_PRESSURE;
|
||||
if (!hasTilt)
|
||||
packetData &= ~PK_ORIENTATION;
|
||||
archetype.lcPktData = packetData;
|
||||
|
||||
archetype.lcPktMode = PACKETMODE;
|
||||
archetype.lcOptions |= /*CXO_MESSAGES |*/ CXO_CSRMESSAGES;
|
||||
// archetype.lcOptions |= CXO_SYSTEM | CXO_MESSAGES | CXO_CSRMESSAGES;
|
||||
|
||||
#if PACKETMODE & PK_BUTTONS
|
||||
// we want first 5 buttons
|
||||
archetype.lcBtnDnMask = 0x1f;
|
||||
archetype.lcBtnUpMask = 0x1f;
|
||||
#endif
|
||||
|
||||
// BEGIN derived from Wacom's TILTTEST.C:
|
||||
AXIS TabletX, TabletY;
|
||||
@ -259,15 +270,22 @@ void GHOST_TabletManagerWin32::convertTilt(ORIENTATION const& ort, TabletToolDat
|
||||
data.tilt_y = sin(M_PI/2.0 - azmRad) * vecLen;
|
||||
}
|
||||
|
||||
void GHOST_TabletManagerWin32::processPackets(GHOST_WindowWin32* window)
|
||||
bool GHOST_TabletManagerWin32::processPackets(GHOST_WindowWin32* window)
|
||||
{
|
||||
if (window == NULL)
|
||||
window = activeWindow;
|
||||
|
||||
HCTX context = contextForWindow(window);
|
||||
|
||||
bool anyProcessed = false;
|
||||
|
||||
if (context)
|
||||
{
|
||||
// PACKET packet;
|
||||
// func_Packet(context, serialNumber, &packet);
|
||||
PACKET packets[MAX_QUEUE_SIZE];
|
||||
int n = func_PacketsGet(context, MAX_QUEUE_SIZE, packets);
|
||||
// printf("processing %d packets\n", n);
|
||||
// printf("processing %d packets\n", n);
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
@ -277,7 +295,7 @@ void GHOST_TabletManagerWin32::processPackets(GHOST_WindowWin32* window)
|
||||
int y = packet.pkY;
|
||||
|
||||
if (activeTool.type == TABLET_MOUSE)
|
||||
if (x == prevMouseX && y == prevMouseY)
|
||||
if (x == prevMouseX && y == prevMouseY && packet.pkButtons == prevButtons)
|
||||
// don't send any "mouse hasn't moved" events
|
||||
continue;
|
||||
else {
|
||||
@ -285,7 +303,12 @@ void GHOST_TabletManagerWin32::processPackets(GHOST_WindowWin32* window)
|
||||
prevMouseY = y;
|
||||
}
|
||||
|
||||
// every packet from a WT_PACKET message comes from the same tool
|
||||
anyProcessed = true;
|
||||
|
||||
// Since we're using a digitizing context, we need to
|
||||
// move the on-screen cursor ourselves.
|
||||
// SetCursorPos(x, y);
|
||||
|
||||
switch (activeTool.type)
|
||||
{
|
||||
case TABLET_MOUSE:
|
||||
@ -316,24 +339,36 @@ void GHOST_TabletManagerWin32::processPackets(GHOST_WindowWin32* window)
|
||||
|
||||
if (activeTool.hasTilt)
|
||||
{
|
||||
// ORIENTATION const& tilt = packet.pkOrientation;
|
||||
// printf(" /%d,%d/", tilt.orAzimuth, tilt.orAltitude);
|
||||
convertTilt(packet.pkOrientation, data);
|
||||
ORIENTATION const& o = packet.pkOrientation;
|
||||
|
||||
if (o.orAzimuth || o.orAltitude)
|
||||
{
|
||||
convertTilt(o, data);
|
||||
printf(" /%d,%d/", o.orAzimuth, o.orAltitude);
|
||||
printf(" /%.2f,%.2f/", data.tilt_x, data.tilt_y);
|
||||
if (fabs(data.tilt_x) < 0.001 && fabs(data.tilt_x) < 0.001)
|
||||
{
|
||||
// really should fix the initial test for activeTool.hasTilt,
|
||||
// not apply a band-aid here.
|
||||
data.tool.hasTilt = false;
|
||||
data.tilt_x = 0.f;
|
||||
data.tilt_y = 0.f;
|
||||
}
|
||||
}
|
||||
else
|
||||
data.tool.hasTilt = false;
|
||||
|
||||
// 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');
|
||||
|
||||
// at this point, construct a GHOST event and push it into the queue!
|
||||
// (having trouble with Wacom mouse scaling, so ignore it for now)
|
||||
|
||||
// if (activeTool.type == TABLET_PEN || activeTool.type == TABLET_ERASER)
|
||||
{
|
||||
GHOST_System* system = (GHOST_System*) GHOST_ISystem::getSystem();
|
||||
|
||||
// any buttons changed?
|
||||
#if PACKETMODE & PK_BUTTONS
|
||||
// relative buttons mode
|
||||
if (packet.pkButtons)
|
||||
{
|
||||
// which button?
|
||||
@ -349,12 +384,42 @@ void GHOST_TabletManagerWin32::processPackets(GHOST_WindowWin32* window)
|
||||
else
|
||||
e_action = GHOST_kEventButtonUp;
|
||||
|
||||
printf("button %d %s\n", buttonNumber, buttonAction == TBN_DOWN ? "down" : "up");
|
||||
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);
|
||||
system->pushEvent(e);
|
||||
}
|
||||
#else
|
||||
// absolute buttons mode
|
||||
UINT diff = prevButtons ^ packet.pkButtons;
|
||||
if (diff)
|
||||
{
|
||||
for (int i = 0; i < 32 /*GHOST_kButtonNumMasks*/; ++i)
|
||||
{
|
||||
UINT mask = 1 << i;
|
||||
|
||||
if (diff & mask)
|
||||
{
|
||||
GHOST_TButtonMask e_button = (GHOST_TButtonMask) i;
|
||||
GHOST_TEventType e_action = (packet.pkButtons & mask) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp;
|
||||
|
||||
GHOST_EventButton* e = new GHOST_EventButton(system->getMilliSeconds(), e_action, window, e_button);
|
||||
GHOST_TabletData& e_data = ((GHOST_TEventButtonData*) 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;
|
||||
|
||||
printf(" button %d %s\n", i, (e_action == GHOST_kEventButtonDown) ? "down" : "up");
|
||||
|
||||
system->pushEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
prevButtons = packet.pkButtons;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
GHOST_EventCursor* e = new GHOST_EventCursor(system->getMilliSeconds(), GHOST_kEventCursorMove, window, x, y);
|
||||
@ -366,19 +431,27 @@ void GHOST_TabletManagerWin32::processPackets(GHOST_WindowWin32* window)
|
||||
e_data.Xtilt = data.tilt_x;
|
||||
e_data.Ytilt = data.tilt_y;
|
||||
|
||||
// system->pushEvent(e);
|
||||
}
|
||||
puts(" move");
|
||||
|
||||
system->pushEvent(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return anyProcessed;
|
||||
}
|
||||
|
||||
void GHOST_TabletManagerWin32::changeTool(HCTX context, UINT serialNumber)
|
||||
void GHOST_TabletManagerWin32::changeTool(GHOST_WindowWin32* window, UINT serialNumber)
|
||||
{
|
||||
puts("-- changing tool --");
|
||||
|
||||
dropTool();
|
||||
|
||||
HCTX context = contextForWindow(window);
|
||||
|
||||
if (context)
|
||||
{
|
||||
activeWindow = window;
|
||||
|
||||
PACKET packet;
|
||||
func_Packet(context, serialNumber, &packet);
|
||||
UINT cursor = (packet.pkCursor - cursorBase) % cursorCount;
|
||||
@ -404,10 +477,10 @@ void GHOST_TabletManagerWin32::changeTool(HCTX context, UINT serialNumber)
|
||||
}
|
||||
|
||||
WTPKT toolData;
|
||||
func_Info(WTI_CURSORS + cursor, CSR_PKTDATA, &toolData);
|
||||
func_Info(WTI_CURSORS + packet.pkCursor, CSR_PKTDATA, &toolData);
|
||||
activeTool.hasPressure = toolData & PK_NORMAL_PRESSURE;
|
||||
activeTool.hasTilt = toolData & PK_ORIENTATION;
|
||||
// activeTool.hasTilt = toolData & tiltMask;
|
||||
// activeTool.hasTilt = toolData & tiltMask;
|
||||
|
||||
if (activeTool.hasPressure)
|
||||
puts(" - pressure");
|
||||
@ -419,6 +492,7 @@ void GHOST_TabletManagerWin32::changeTool(HCTX context, UINT serialNumber)
|
||||
if (toolData & PK_BUTTONS)
|
||||
puts(" - buttons");
|
||||
}
|
||||
}
|
||||
|
||||
void GHOST_TabletManagerWin32::dropTool()
|
||||
{
|
||||
@ -427,4 +501,7 @@ void GHOST_TabletManagerWin32::dropTool()
|
||||
activeTool.hasTilt = false;
|
||||
|
||||
prevMouseX = prevMouseY = 0;
|
||||
prevButtons = 0;
|
||||
|
||||
activeWindow = NULL;
|
||||
}
|
||||
|
@ -69,15 +69,16 @@ class GHOST_TabletManagerWin32
|
||||
UINT cursorCount;
|
||||
UINT cursorBase;
|
||||
|
||||
// candidate for a base class:
|
||||
// book-keeping
|
||||
std::map<GHOST_WindowWin32*,HCTX> contexts;
|
||||
HCTX contextForWindow(GHOST_WindowWin32*);
|
||||
|
||||
GHOST_WindowWin32* activeWindow;
|
||||
TabletTool activeTool;
|
||||
|
||||
int prevMouseX;
|
||||
int prevMouseY;
|
||||
|
||||
// book-keeping
|
||||
std::map<GHOST_WindowWin32*,HCTX> contexts;
|
||||
HCTX contextForWindow(GHOST_WindowWin32*);
|
||||
UINT prevButtons;
|
||||
|
||||
void convertTilt(ORIENTATION const&, TabletToolData&);
|
||||
|
||||
@ -90,9 +91,11 @@ public:
|
||||
void openForWindow(GHOST_WindowWin32*);
|
||||
void closeForWindow(GHOST_WindowWin32*);
|
||||
|
||||
void processPackets(GHOST_WindowWin32*);
|
||||
// returns whether any packets resulted in GHOST events
|
||||
bool processPackets(GHOST_WindowWin32* = NULL);
|
||||
// void processPacket(GHOST_WindowWin32*, UINT serialNumber);
|
||||
|
||||
void changeTool(HCTX, UINT serialNumber);
|
||||
void changeTool(GHOST_WindowWin32*, UINT serialNumber);
|
||||
void dropTool();
|
||||
};
|
||||
|
||||
@ -100,10 +103,10 @@ public:
|
||||
The tablet manager is driven by the following Windows event processing code:
|
||||
|
||||
case WT_PACKET:
|
||||
m_tabletManager->processPackets((HCTX)lParam);
|
||||
m_tabletManager->processPackets(window);
|
||||
break;
|
||||
case WT_CSRCHANGE:
|
||||
m_tabletManager->changeTool((HCTX)lParam, wParam);
|
||||
m_tabletManager->changeTool(window, wParam);
|
||||
break;
|
||||
case WT_PROXIMITY:
|
||||
if (LOWORD(lParam) == 0)
|
||||
|
@ -1977,7 +1977,7 @@ int WM_modal_tweak_exit(wmEvent *evt, int tweak_event)
|
||||
if(evt->val==tweak_modal)
|
||||
return 1;
|
||||
default:
|
||||
/* this case is when modal callcback didnt get started with a tweak */
|
||||
/* this case is when modal callback didnt get started with a tweak */
|
||||
if(evt->val)
|
||||
return 1;
|
||||
}
|
||||
@ -2062,28 +2062,6 @@ static int convert_key(GHOST_TKey key)
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* adds customdata to event */
|
||||
static void update_tablet_data(wmWindow *win, wmEvent *event)
|
||||
{
|
||||
const GHOST_TabletData *td= GHOST_GetTabletData(win->ghostwin);
|
||||
|
||||
/* if there's tablet data from an active tablet device then add it */
|
||||
if ((td != NULL) && td->Active != GHOST_kTabletModeNone) {
|
||||
struct wmTabletData *wmtab= MEM_mallocN(sizeof(wmTabletData), "customdata tablet");
|
||||
|
||||
wmtab->Active = (int)td->Active;
|
||||
wmtab->Pressure = td->Pressure;
|
||||
wmtab->Xtilt = td->Xtilt;
|
||||
wmtab->Ytilt = td->Ytilt;
|
||||
|
||||
event->custom= EVT_DATA_TABLET;
|
||||
event->customdata= wmtab;
|
||||
event->customdatafree= 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* adds customdata to event */
|
||||
static void attach_tablet_data(wmEvent* event, const GHOST_TabletData* ghost)
|
||||
{
|
||||
@ -2100,7 +2078,7 @@ static void attach_tablet_data(wmEvent* event, const GHOST_TabletData* ghost)
|
||||
event->customdata = data;
|
||||
event->customdatafree = 1;
|
||||
|
||||
printf("+ pressure = %.2f tilt = %.2f %2f\n", data->Pressure, data->Xtilt, data->Ytilt);
|
||||
// printf("+ pressure = %.2f tilt = %.2f %.2f\n", data->Pressure, data->Xtilt, data->Ytilt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2165,7 +2143,7 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
|
||||
}
|
||||
|
||||
/* windows store own event queues, no bContext here */
|
||||
/* time is in 1000s of seconds (or milliseconds?), from ghost */
|
||||
/* time is in milliseconds, from ghost */
|
||||
void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata)
|
||||
{
|
||||
wmWindow *owin;
|
||||
@ -2205,7 +2183,6 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t
|
||||
lastevent->type = INBETWEEN_MOUSEMOVE;
|
||||
|
||||
attach_tablet_data(&event, &(cd->tablet));
|
||||
// update_tablet_data(win, &event);
|
||||
wm_event_add(win, &event);
|
||||
|
||||
/* also add to other window if event is there, this makes overdraws disappear nicely */
|
||||
@ -2218,7 +2195,6 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t
|
||||
oevent.y=owin->eventstate->y= event.y;
|
||||
oevent.type= MOUSEMOVE;
|
||||
|
||||
// update_tablet_data(owin, &oevent);
|
||||
wm_event_add(owin, &oevent);
|
||||
}
|
||||
}
|
||||
@ -2263,7 +2239,8 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t
|
||||
case GHOST_kEventButtonDown:
|
||||
case GHOST_kEventButtonUp: {
|
||||
GHOST_TEventButtonData *bd= customdata;
|
||||
event.val= (type==GHOST_kEventButtonDown) ? KM_PRESS:KM_RELEASE; /* Note!, this starts as 0/1 but later is converted to KM_PRESS/KM_RELEASE by tweak */
|
||||
event.val= (type==GHOST_kEventButtonDown) ? KM_PRESS:KM_RELEASE;
|
||||
/* Note!, this starts as 0/1 but later is converted to KM_PRESS/KM_RELEASE by tweak */
|
||||
|
||||
if (bd->button == GHOST_kButtonMaskLeft)
|
||||
event.type= LEFTMOUSE;
|
||||
@ -2287,12 +2264,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t
|
||||
oevent.val= event.val;
|
||||
|
||||
attach_tablet_data(&oevent, &(bd->tablet));
|
||||
// update_tablet_data(owin, &oevent);
|
||||
wm_event_add(owin, &oevent);
|
||||
}
|
||||
else {
|
||||
attach_tablet_data(&event, &(bd->tablet));
|
||||
// update_tablet_data(win, &event);
|
||||
wm_event_add(win, &event);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user