*/}}
Browse Source

Init wintab (wip)

YimingWu 1 year ago
parent
commit
c52a433016
2 changed files with 51 additions and 0 deletions
  1. 1 0
      la_interface.h
  2. 50 0
      la_kernel.c

+ 1 - 0
la_interface.h

@@ -350,6 +350,7 @@ STRUCTURE(LA){
 #ifdef _WIN32
     HINSTANCE hinstance;
     HDC hdc;
+    int WinTabAvaliable;
 #endif
 #ifdef __linux__
     XVisualInfo* xvi;

+ 50 - 0
la_kernel.c

@@ -228,6 +228,51 @@ void la_DestroySystemWindowX11(laWindow* w) {
 };
 #endif //linux
 #ifdef _WIN32
+#include <wintab.h>
+void la_ScanWacomDevices(){
+    if(!MAIN.WinTabAvailable) return;
+
+    HCTX hctx = NULL;
+	UINT wDevice = 0;
+	UINT wExtX = 0;
+	UINT wExtY = 0;
+	UINT wWTInfoRetVal = 0;
+	AXIS TabletX = { 0 };
+	AXIS TabletY = { 0 };
+
+	glogContext.lcOptions |= CXO_SYSTEM;
+	wWTInfoRetVal = gpWTInfoA(WTI_DEFSYSCTX, 0, &glogContext);
+	assert(wWTInfoRetVal == sizeof(LOGCONTEXT));
+
+	assert(glogContext.lcOptions & CXO_SYSTEM);
+	wsprintf(glogContext.lcName, "PrsTest Digitizing %p", hInst);
+	glogContext.lcOptions |= CXO_MESSAGES;
+	glogContext.lcPktData = PACKETDATA;
+	glogContext.lcPktMode = PACKETMODE;
+	glogContext.lcMoveMask = PACKETDATA;
+	glogContext.lcBtnUpMask = glogContext.lcBtnDnMask;
+
+	wWTInfoRetVal = gpWTInfoA(WTI_DEVICES + 0, DVC_X, &TabletX);
+	assert(wWTInfoRetVal == sizeof(AXIS));
+
+	wWTInfoRetVal = gpWTInfoA(WTI_DEVICES, DVC_Y, &TabletY);
+	assert(wWTInfoRetVal == sizeof(AXIS));
+
+	glogContext.lcInOrgX = 0;
+	glogContext.lcInOrgY = 0;
+	glogContext.lcInExtX = TabletX.axMax;
+	glogContext.lcInExtY = TabletY.axMax;
+
+	glogContext.lcOutOrgX = GetSystemMetrics(SM_XVIRTUALSCREEN);
+	glogContext.lcOutOrgY = GetSystemMetrics(SM_YVIRTUALSCREEN);
+	glogContext.lcOutExtX = GetSystemMetrics(SM_CXVIRTUALSCREEN); //SM_CXSCREEN);
+	glogContext.lcOutExtY = -GetSystemMetrics(SM_CYVIRTUALSCREEN);	//lower left to upper left. SM_CYSCREEN);
+
+	hctx = gpWTOpenA(hWnd, &glogContext, FALSE);
+
+	return hctx;
+}
+
 void laHideCursor() {
     if (!MAIN.CurrentWindow) return; //impl
 }
@@ -749,6 +794,11 @@ int laGetReadyWith(int GLMajor, int GLMinor, int BufferSamples){
         return 0;
     }
 
+    logPrintNew("Trying to load WinTab for stylus input...\n"); int WtAvailable=1;
+    if (!LoadWintab()){ logPrint("WinTab not available."); WtAvailable=0; }
+	if (!gpWTInfoA(0, 0, NULL)){ logPrint("WinTab servicenot available. (gpWTInfoA() returns 0)."); WtAvailable=0; }
+    if(WtAvailable){ MAIN.WinTabAvailable=1; }
+
 #endif
 
     la_GetWorkingDirectoryInternal();