diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 2a04dcd94..7f0eee6d0 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -674,6 +674,14 @@ private: static bool IsNoLayoutZoom; static void Csizeinit(); static void (*skin)(); + + static bool pen; + static bool pen_barrel; + static bool pen_inverted; + static bool pen_eraser; + static double pen_pressure; + static double pen_rotation; + static Pointf pen_tilt; friend void InitRichTextZoom(); friend void AvoidPaintingCheck__(); @@ -1289,6 +1297,14 @@ public: static int64 GetEventId() { return eventid; } + static bool IsPointerPen() { return pen; } + static bool IsPenBarrelPressed() { return pen_barrel; } + static bool IsPenInverted() { return pen_inverted; } + static bool IsPenEraserPressed() { return pen_eraser; } + static double GetPenPressure() { return pen_pressure; } + static double GetPenRotation() { return pen_rotation; } + static Pointf GetPenTilt() { return pen_tilt; } + Ctrl(); virtual ~Ctrl(); diff --git a/uppsrc/CtrlCore/CtrlMouse.cpp b/uppsrc/CtrlCore/CtrlMouse.cpp index 08ba75fc2..0a22b181e 100644 --- a/uppsrc/CtrlCore/CtrlMouse.cpp +++ b/uppsrc/CtrlCore/CtrlMouse.cpp @@ -18,6 +18,14 @@ Point Ctrl::leftmousepos = Null; Point Ctrl::rightmousepos = Null; Point Ctrl::middlemousepos = Null; +bool Ctrl::pen; +bool Ctrl::pen_barrel; +bool Ctrl::pen_inverted; +bool Ctrl::pen_eraser; +double Ctrl::pen_pressure = Null; +double Ctrl::pen_rotation = Null; +Pointf Ctrl::pen_tilt = Null; + dword GetMouseFlags() { dword style = 0; if(GetAlt()) style |= K_ALT; diff --git a/uppsrc/CtrlCore/Win32Proc.cpp b/uppsrc/CtrlCore/Win32Proc.cpp index 01d0adf51..5f05f3eb5 100644 --- a/uppsrc/CtrlCore/Win32Proc.cpp +++ b/uppsrc/CtrlCore/Win32Proc.cpp @@ -63,7 +63,54 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { // LLOG("Ctrl::WindowProc(" << message << ") in " << ::Name(this) << ", focus " << (void *)::GetFocus()); Ptr _this = this; HWND hwnd = GetHWND(); + switch(message) { + case WM_POINTERDOWN: + case WM_POINTERUPDATE: + case WM_POINTERUP: + { + pen = false; + pen_pressure = pen_rotation = Null; + pen_tilt = Null; + pen_eraser = false; + pen_barrel = false; + pen_inverted = false; + + static BOOL (WINAPI *GetPointerInfo)(UINT32 pointerId, POINTER_INFO *pointerInfo); + static BOOL (WINAPI *GetPointerPenInfo)(UINT32 pointerId, POINTER_PEN_INFO *penInfo); + ONCELOCK { + DllFn(GetPointerInfo, "User32.dll", "GetPointerInfo"); + DllFn(GetPointerPenInfo, "User32.dll", "GetPointerPenInfo"); + }; + + POINTER_INFO pi; + if(GetPointerInfo(GET_POINTERID_WPARAM(wParam), &pi)) { + if(pi.pointerType == PT_PEN) { + POINTER_PEN_INFO ppi; + if(GetPointerPenInfo(pi.pointerId, &ppi)) { + pen = true; + if(ppi.penFlags & PEN_FLAG_BARREL) + pen_barrel = true; + if(ppi.penFlags & PEN_FLAG_INVERTED) + pen_inverted = true; + if(ppi.penFlags & PEN_FLAG_ERASER) + pen_eraser = true; + if(ppi.penMask & PEN_MASK_PRESSURE) + pen_pressure = ppi.pressure / 1024.0; + if(ppi.penMask & PEN_MASK_ROTATION) + pen_pressure = ppi.rotation * M_2PI / 360; + if(ppi.penMask & PEN_MASK_TILT_X) + pen_tilt.x = ppi.tiltX * M_2PI / 360; + if(ppi.penMask & PEN_MASK_TILT_Y) + pen_tilt.y = ppi.tiltY * M_2PI / 360; + } + } + } + } + break; + case WM_POINTERLEAVE: + pen = false; + break; case WM_PALETTECHANGED: if((HWND)wParam == hwnd) break;