[macOS, Windows, X11] Add stylus inverted/eraser support to
InputEventMouseMotion event
This commit is contained in:
parent
d572d3d2ab
commit
6dcc9d1131
9 changed files with 70 additions and 10 deletions
|
|
@ -2490,6 +2490,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
|||
windows[window_id].last_tilt = Vector2();
|
||||
}
|
||||
|
||||
windows[window_id].last_pen_inverted = packet.pkStatus & TPS_INVERT;
|
||||
|
||||
POINT coords;
|
||||
GetCursorPos(&coords);
|
||||
ScreenToClient(windows[window_id].hWnd, &coords);
|
||||
|
|
@ -2508,6 +2510,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
|||
|
||||
mm->set_pressure(windows[window_id].last_pressure);
|
||||
mm->set_tilt(windows[window_id].last_tilt);
|
||||
mm->set_pen_inverted(windows[window_id].last_pen_inverted);
|
||||
|
||||
mm->set_button_mask(last_button_state);
|
||||
|
||||
|
|
@ -2640,6 +2643,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
|||
if ((pen_info.penMask & PEN_MASK_TILT_X) && (pen_info.penMask & PEN_MASK_TILT_Y)) {
|
||||
mm->set_tilt(Vector2((float)pen_info.tiltX / 90, (float)pen_info.tiltY / 90));
|
||||
}
|
||||
mm->set_pen_inverted(pen_info.penFlags & (PEN_FLAG_INVERTED | PEN_FLAG_ERASER));
|
||||
|
||||
mm->set_ctrl_pressed(GetKeyState(VK_CONTROL) < 0);
|
||||
mm->set_shift_pressed(GetKeyState(VK_SHIFT) < 0);
|
||||
|
|
@ -2742,14 +2746,17 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
|||
} else {
|
||||
windows[window_id].last_tilt = Vector2();
|
||||
windows[window_id].last_pressure = (wParam & MK_LBUTTON) ? 1.0f : 0.0f;
|
||||
windows[window_id].last_pen_inverted = false;
|
||||
}
|
||||
} else {
|
||||
windows[window_id].last_tilt = Vector2();
|
||||
windows[window_id].last_pressure = (wParam & MK_LBUTTON) ? 1.0f : 0.0f;
|
||||
windows[window_id].last_pen_inverted = false;
|
||||
}
|
||||
|
||||
mm->set_pressure(windows[window_id].last_pressure);
|
||||
mm->set_tilt(windows[window_id].last_tilt);
|
||||
mm->set_pen_inverted(windows[window_id].last_pen_inverted);
|
||||
|
||||
mm->set_button_mask(last_button_state);
|
||||
|
||||
|
|
@ -3360,8 +3367,8 @@ void DisplayServerWindows::_update_tablet_ctx(const String &p_old_driver, const
|
|||
if ((p_new_driver == "wintab") && wintab_available) {
|
||||
wintab_WTInfo(WTI_DEFSYSCTX, 0, &wd.wtlc);
|
||||
wd.wtlc.lcOptions |= CXO_MESSAGES;
|
||||
wd.wtlc.lcPktData = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
|
||||
wd.wtlc.lcMoveMask = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE;
|
||||
wd.wtlc.lcPktData = PK_STATUS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
|
||||
wd.wtlc.lcMoveMask = PK_STATUS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE;
|
||||
wd.wtlc.lcPktMode = 0;
|
||||
wd.wtlc.lcOutOrgX = 0;
|
||||
wd.wtlc.lcOutExtX = wd.wtlc.lcInExtX;
|
||||
|
|
@ -3484,8 +3491,8 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
|
|||
if ((tablet_get_current_driver() == "wintab") && wintab_available) {
|
||||
wintab_WTInfo(WTI_DEFSYSCTX, 0, &wd.wtlc);
|
||||
wd.wtlc.lcOptions |= CXO_MESSAGES;
|
||||
wd.wtlc.lcPktData = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
|
||||
wd.wtlc.lcMoveMask = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE;
|
||||
wd.wtlc.lcPktData = PK_STATUS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
|
||||
wd.wtlc.lcMoveMask = PK_STATUS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE;
|
||||
wd.wtlc.lcPktMode = 0;
|
||||
wd.wtlc.lcOutOrgX = 0;
|
||||
wd.wtlc.lcOutExtX = wd.wtlc.lcInExtX;
|
||||
|
|
|
|||
|
|
@ -82,10 +82,13 @@
|
|||
#define DVC_ROTATION 18
|
||||
|
||||
#define CXO_MESSAGES 0x0004
|
||||
#define PK_STATUS 0x0002
|
||||
#define PK_NORMAL_PRESSURE 0x0400
|
||||
#define PK_TANGENT_PRESSURE 0x0800
|
||||
#define PK_ORIENTATION 0x1000
|
||||
|
||||
#define TPS_INVERT 0x0010 /* 1.1 */
|
||||
|
||||
typedef struct tagLOGCONTEXTW {
|
||||
WCHAR lcName[40];
|
||||
UINT lcOptions;
|
||||
|
|
@ -137,6 +140,7 @@ typedef struct tagORIENTATION {
|
|||
} ORIENTATION;
|
||||
|
||||
typedef struct tagPACKET {
|
||||
int pkStatus;
|
||||
int pkNormalPressure;
|
||||
int pkTangentPressure;
|
||||
ORIENTATION pkOrientation;
|
||||
|
|
@ -158,6 +162,14 @@ typedef UINT32 POINTER_FLAGS;
|
|||
typedef UINT32 PEN_FLAGS;
|
||||
typedef UINT32 PEN_MASK;
|
||||
|
||||
#ifndef PEN_FLAG_INVERTED
|
||||
#define PEN_FLAG_INVERTED 0x00000002
|
||||
#endif
|
||||
|
||||
#ifndef PEN_FLAG_ERASER
|
||||
#define PEN_FLAG_ERASER 0x00000004
|
||||
#endif
|
||||
|
||||
#ifndef PEN_MASK_PRESSURE
|
||||
#define PEN_MASK_PRESSURE 0x00000001
|
||||
#endif
|
||||
|
|
@ -357,11 +369,13 @@ class DisplayServerWindows : public DisplayServer {
|
|||
int min_pressure;
|
||||
int max_pressure;
|
||||
bool tilt_supported;
|
||||
bool pen_inverted = false;
|
||||
bool block_mm = false;
|
||||
|
||||
int last_pressure_update;
|
||||
float last_pressure;
|
||||
Vector2 last_tilt;
|
||||
bool last_pen_inverted = false;
|
||||
|
||||
HBITMAP hBitmap; //DIB section for layered window
|
||||
uint8_t *dib_data = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue