Commit: d7d68bcec2ec4ac9aebfb1c8d67557532e515fbf Author: Nicholas Rishel Date: Fri May 21 12:46:55 2021 -0700 Branches: wintab-high-frequency https://developer.blender.org/rBd7d68bcec2ec4ac9aebfb1c8d67557532e515fbf
Dynamic api switching. =================================================================== 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_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 525c6016d31..4e82532de6e 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1623,6 +1623,12 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, eventHandled = true; break; } + case WT_INFOCHANGE: + if (GHOST_WintabWin32 *wt = window->getWintab()) { + wt->processInfoChange(lParam); + } + eventHandled = true; + break; case WT_PACKET: processWintabEvent(window); eventHandled = true; diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index a182eb2c75c..0aaa34e52c9 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -983,7 +983,7 @@ bool GHOST_WindowWin32::useTabletAPI(GHOST_TTabletAPI api) const return true; } else if (m_system->getTabletAPI() == GHOST_kTabletAutomatic) { - if (m_wintab.tablet) + if (m_wintab && m_wintab->devicesPresent()) return api == GHOST_kTabletWintab; else return api == GHOST_kTabletNative; diff --git a/intern/ghost/intern/GHOST_Wintab.cpp b/intern/ghost/intern/GHOST_Wintab.cpp index aa20119a2a7..44e897b666c 100644 --- a/intern/ghost/intern/GHOST_Wintab.cpp +++ b/intern/ghost/intern/GHOST_Wintab.cpp @@ -166,6 +166,7 @@ GHOST_WintabWin32::GHOST_WintabWin32(HWND hwnd, m_context(std::move(hctx)), m_pkts(queueSize) { + m_fpInfo(WTI_INTERFACE, IFC_NDEVICES, &numDevices); updateCursorInfo(); } @@ -224,6 +225,23 @@ void GHOST_WintabWin32::updateCursorInfo() } } +void GHOST_WintabWin32::processInfoChange(LPARAM lParam) +{ + /* Update number of connected Wintab digitizers */ + if (LOWORD(lParam) == WTI_INTERFACE && HIWORD(lParam) == IFC_NDEVICES) { + m_fpInfo(WTI_INTERFACE, IFC_NDEVICES, &numDevices); + } +} + +/** + * TODO + */ +bool GHOST_WintabWin32::devicesPresent() +{ + return numDevices; +} + + void GHOST_WintabWin32::getInput(std::vector<GHOST_WintabInfoWin32> &outWintabInfo) { const int numPackets = m_fpPacketsGet(m_context.get(), m_pkts.size(), m_pkts.data()); diff --git a/intern/ghost/intern/GHOST_Wintab.h b/intern/ghost/intern/GHOST_Wintab.h index 60b88cee417..c27069454b0 100644 --- a/intern/ghost/intern/GHOST_Wintab.h +++ b/intern/ghost/intern/GHOST_Wintab.h @@ -87,6 +87,17 @@ class GHOST_WintabWin32 { */ void updateCursorInfo(); + /** + * Handle Wintab info changes such as change in number of connected tablets. + * \param lParam: LPARAM of the event. + */ + void processInfoChange(LPARAM lParam); + + /** + * TODO + */ + bool devicesPresent(); + /** * Translate Wintab packets into GHOST_WintabInfoWin32 structs. * \param outWintabInfo: Storage to return resulting GHOST_WintabInfoWin32 structs. @@ -112,6 +123,7 @@ class GHOST_WintabWin32 { LONG m_maxPressure = 0; LONG m_maxAzimuth = 0; LONG m_maxAltitude = 0; + UINT numDevices; /** Reusable buffer to read in Wintab packets. */ std::vector<PACKET> m_pkts; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs