[Bf-blender-cvs] [98f30909520] wintab-logging: Add debugging info for Wintab.
Nicholas Rishel
noreply at git.blender.org
Wed Jun 23 02:47:32 CEST 2021
Commit: 98f309095200f7b493244156c41cad215e5ea56f
Author: Nicholas Rishel
Date: Tue Jun 22 17:30:10 2021 -0700
Branches: wintab-logging
https://developer.blender.org/rB98f309095200f7b493244156c41cad215e5ea56f
Add debugging info for Wintab.
===================================================================
M intern/ghost/intern/GHOST_Debug.h
M intern/ghost/intern/GHOST_SystemWin32.cpp
M intern/ghost/intern/GHOST_WindowWin32.cpp
M intern/ghost/intern/GHOST_Wintab.cpp
M intern/ghost/intern/GHOST_Wintab.h
===================================================================
diff --git a/intern/ghost/intern/GHOST_Debug.h b/intern/ghost/intern/GHOST_Debug.h
index 13858410c5a..e171e4c6485 100644
--- a/intern/ghost/intern/GHOST_Debug.h
+++ b/intern/ghost/intern/GHOST_Debug.h
@@ -52,6 +52,13 @@
# define GHOST_PRINTF(x, ...)
#endif // WITH_GHOST_DEBUG
+#include <stdio.h> //for printf()
+#define WINTAB_PRINTF(x, ...) \
+ { \
+ printf(x, __VA_ARGS__); \
+ } \
+ (void)0
+
#ifdef WITH_ASSERT_ABORT
# include <stdio.h> //for fprintf()
# include <stdlib.h> //for abort()
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index aa8dad44799..a2de396514f 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -876,6 +876,13 @@ GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type,
int msgPosY = GET_Y_LPARAM(msgPos);
system->pushEvent(new GHOST_EventCursor(
::GetMessageTime(), GHOST_kEventCursorMove, window, msgPosX, msgPosY, td));
+
+ if (type == GHOST_kEventButtonDown) {
+ WINTAB_PRINTF("%p OS button down\n", window->getHWND());
+ }
+ else if (type == GHOST_kEventButtonUp) {
+ WINTAB_PRINTF("%p OS button up\n", window->getHWND());
+ }
}
window->updateMouseCapture(type == GHOST_kEventButtonDown ? MousePressed : MouseReleased);
@@ -918,6 +925,8 @@ void GHOST_SystemWin32::processWintabEvent(GHOST_WindowWin32 *window)
break;
}
case GHOST_kEventButtonDown: {
+ WINTAB_PRINTF("%p wintab button down", window->getHWND());
+
UINT message;
switch (info.button) {
case GHOST_kButtonMaskLeft:
@@ -945,6 +954,11 @@ void GHOST_SystemWin32::processWintabEvent(GHOST_WindowWin32 *window)
if (!useWintabPos) {
continue;
}
+ else {
+ WINTAB_PRINTF(" ... but associated to system button mismatched position\n");
+ }
+
+ WINTAB_PRINTF(" ... associated to system button\n");
/* Steal the Win32 event which was previously peeked. */
PeekMessage(&msg, window->getHWND(), message, message, PM_REMOVE | PM_NOYIELD);
@@ -962,9 +976,14 @@ void GHOST_SystemWin32::processWintabEvent(GHOST_WindowWin32 *window)
mouseMoveHandled = true;
break;
}
+ else {
+ WINTAB_PRINTF(" ... but no system button\n");
+ }
}
case GHOST_kEventButtonUp: {
+ WINTAB_PRINTF("%p wintab button up", window->getHWND());
if (!useWintabPos) {
+ WINTAB_PRINTF(" ... but Wintab position isn't trusted\n");
continue;
}
@@ -990,10 +1009,14 @@ void GHOST_SystemWin32::processWintabEvent(GHOST_WindowWin32 *window)
if (PeekMessage(&msg, window->getHWND(), message, message, PM_REMOVE | PM_NOYIELD) &&
msg.message != WM_QUIT) {
+ WINTAB_PRINTF(" ... associated to system button\n");
window->updateMouseCapture(MouseReleased);
system->pushEvent(
new GHOST_EventButton(info.time, info.type, window, info.button, info.tabletData));
}
+ else {
+ WINTAB_PRINTF(" ... but no system button\n");
+ }
break;
}
default:
@@ -1584,6 +1607,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
// Wintab events, processed
////////////////////////////////////////////////////////////////////////
case WT_CSRCHANGE: {
+ WINTAB_PRINTF("%p WT_CSRCHANGE\n", window->getHWND());
GHOST_Wintab *wt = window->getWintab();
if (wt) {
wt->updateCursorInfo();
@@ -1592,6 +1616,12 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
}
case WT_PROXIMITY: {
+ WINTAB_PRINTF(
+ "%p WT_PROXIMITY loword (!0 enter 0 leave context): %d, hiword (!0 enter !0 leave "
+ "hardware): %d\n",
+ window->getHWND(),
+ LOWORD(lParam),
+ HIWORD(lParam));
GHOST_Wintab *wt = window->getWintab();
if (wt) {
bool inRange = LOWORD(lParam);
@@ -1607,6 +1637,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
}
case WT_INFOCHANGE: {
+ WINTAB_PRINTF("%p WT_INFOCHANGE\n", window->getHWND());
GHOST_Wintab *wt = window->getWintab();
if (wt) {
wt->processInfoChange(lParam);
@@ -1623,6 +1654,31 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
eventHandled = true;
break;
////////////////////////////////////////////////////////////////////////
+ // Wintab events, debug
+ ////////////////////////////////////////////////////////////////////////
+ case WT_CTXOPEN:
+ WINTAB_PRINTF("%p WT_CTXOPEN\n", window->getHWND());
+ break;
+ case WT_CTXCLOSE:
+ WINTAB_PRINTF("%p WT_CTXCLOSE\n", window->getHWND());
+ break;
+ case WT_CTXUPDATE:
+ WINTAB_PRINTF("%p WT_CTXUPDATE\n", window->getHWND());
+ break;
+ case WT_CTXOVERLAP:
+ switch (lParam) {
+ case CXS_DISABLED:
+ WINTAB_PRINTF("%p WT_CTXOVERLAP CXS_DISABLED\n", window->getHWND());
+ break;
+ case CXS_OBSCURED:
+ WINTAB_PRINTF("%p WT_CTXOVERLAP CXS_OBSCURED\n", window->getHWND());
+ break;
+ case CXS_ONTOP:
+ WINTAB_PRINTF("%p WT_CTXOVERLAP CXS_ONTOP\n", window->getHWND());
+ break;
+ }
+ break;
+ ////////////////////////////////////////////////////////////////////////
// Pointer events, processed
////////////////////////////////////////////////////////////////////////
case WM_POINTERUPDATE:
@@ -1683,6 +1739,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case WM_MOUSEMOVE:
if (!window->m_mousePresent) {
+ WINTAB_PRINTF("%p mouse enter\n", window->getHWND());
TRACKMOUSEEVENT tme = {sizeof(tme)};
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hwnd;
@@ -1731,6 +1788,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
}
break;
case WM_MOUSELEAVE: {
+ WINTAB_PRINTF("%p mouse leave\n", window->getHWND());
window->m_mousePresent = false;
if (window->getTabletData().Active == GHOST_kTabletModeNone) {
processCursorEvent(window);
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 33c79daf11d..4e47ff73d19 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -938,6 +938,7 @@ GHOST_Wintab *GHOST_WindowWin32::getWintab() const
void GHOST_WindowWin32::loadWintab(bool enable)
{
if (!m_wintab) {
+ WINTAB_PRINTF("Loading Wintab for window %p\n", m_hWnd);
if (m_wintab = GHOST_Wintab::loadWintab(m_hWnd)) {
if (enable) {
m_wintab->enable();
@@ -960,6 +961,7 @@ void GHOST_WindowWin32::loadWintab(bool enable)
void GHOST_WindowWin32::closeWintab()
{
+ WINTAB_PRINTF("Closing Wintab for window %p\n", m_hWnd);
delete m_wintab;
m_wintab = NULL;
}
diff --git a/intern/ghost/intern/GHOST_Wintab.cpp b/intern/ghost/intern/GHOST_Wintab.cpp
index cf0309b1521..f008773c9b3 100644
--- a/intern/ghost/intern/GHOST_Wintab.cpp
+++ b/intern/ghost/intern/GHOST_Wintab.cpp
@@ -21,6 +21,7 @@
#define _USE_MATH_DEFINES
#include "GHOST_Wintab.h"
+#include "GHOST_Debug.h"
GHOST_Wintab *GHOST_Wintab::loadWintab(HWND hwnd)
{
@@ -130,6 +131,11 @@ GHOST_Wintab *GHOST_Wintab::loadWintab(HWND hwnd)
}
}
+ int sanityQueueSize = queueSizeGet(hctx.get());
+ WINTAB_PRINTF("initializeWintab queueSize: %d, queueSizeGet: %d\n", queueSize, sanityQueueSize);
+
+ WINTAB_PRINTF("Loaded Wintab context %p\n", hctx.get());
+
return new GHOST_Wintab(hwnd,
std::move(handle),
info,
@@ -200,6 +206,51 @@ GHOST_Wintab::GHOST_Wintab(HWND hwnd,
{
m_fpInfo(WTI_INTERFACE, IFC_NDEVICES, &m_numDevices);
updateCursorInfo();
+
+ /* Debug info. */
+
+ WINTAB_PRINTF("initializeWintab numDevices: %d\n", m_numDevices);
+
+ UINT maxcontexts, opencontexts;
+ m_fpInfo(WTI_INTERFACE, IFC_NCONTEXTS, &maxcontexts);
+ m_fpInfo(WTI_STATUS, STA_CONTEXTS, &opencontexts);
+ WINTAB_PRINTF("%u max contexts, %u open contexts\n", maxcontexts, opencontexts);
+
+ /* Print button maps. */
+ BYTE logicalButtons[32] = {0};
+ BYTE systemButtons[32] = {0};
+ for (int i = 0; i < 3; i++) {
+ WINTAB_PRINTF("initializeWintab cursor %d buttons\n", i);
+ UINT lbut = m_fpInfo(WTI_CURSORS + i, CSR_BUTTONMAP, &logicalButtons);
+ if (lbut) {
+ WINTAB_PRINTF("%d", logicalButtons[0]);
+ for (int j = 1; j < lbut; j++) {
+ WINTAB_PRINTF(", %d", logicalButtons[j]);
+ }
+ WINTAB_PRINTF("\n");
+ }
+ else {
+ WINTAB_PRINTF("logical button error\n");
+ }
+ UINT sbut = m_fpInfo(WTI_CURSORS + i, CSR_SYSBTNMAP, &systemButtons);
+ if (sbut) {
+ WINTAB_PRINTF("%d", systemButtons[0]);
+ for (int j = 1; j < sbut; j++) {
+ WINTAB_PRINTF(", %d", systemButtons[j]);
+ }
+ WINTAB_PRINTF("\n");
+ }
+ else {
+ WINTAB_PRINTF("system button error\n");
+ }
+ }
+
+ printContextInfo();
+}
+
+GHOST_Wintab::~GHOST_Wintab()
+{
+ WINTAB_PRINTF("Closing Wintab context %p\n", m_context.get());
}
void GHOST_Wintab::enable()
@@ -265,6 +316,7 @@ void GHOST_Wintab::updateCursorInfo()
BOOL pressureSupport = m_fpInfo(WTI_DEVICES, DVC_NPRESSURE, &Pressure);
m_maxPressure = pressureSupport ? Pressure.axMax : 0;
+ WINTAB_PRINTF("cursorInfo maxPressure: %d\n", m_maxPressure);
BOOL tiltSupport = m_fpInfo(WTI_DEVICES, DVC_ORIENTATION, &Orientation);
/* Check if tablet supports azimuth [0] and altitude [1], encoded in axResolution. */
@@ -275,12
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list