Merge pull request #62723 from hansemro/eraser-detect-3.x
This commit is contained in:
@ -490,6 +490,8 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
last_tilt = Vector2();
|
||||
}
|
||||
|
||||
last_pen_inverted = packet.pkStatus & TPS_INVERT;
|
||||
|
||||
POINT coords;
|
||||
GetCursorPos(&coords);
|
||||
ScreenToClient(hWnd, &coords);
|
||||
@ -504,6 +506,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
mm->set_shift(GetKeyState(VK_SHIFT) < 0);
|
||||
mm->set_alt(alt_mem);
|
||||
|
||||
mm->set_pen_inverted(last_pen_inverted);
|
||||
mm->set_pressure(last_pressure);
|
||||
mm->set_tilt(last_tilt);
|
||||
|
||||
@ -631,6 +634,8 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
Ref<InputEventMouseMotion> mm;
|
||||
mm.instance();
|
||||
|
||||
mm->set_pen_inverted(pen_info.penFlags & (PEN_FLAG_INVERTED | PEN_FLAG_ERASER));
|
||||
|
||||
if (pen_info.penMask & PEN_MASK_PRESSURE) {
|
||||
mm->set_pressure((float)pen_info.pressure / 1024);
|
||||
} else {
|
||||
@ -742,14 +747,17 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
} else {
|
||||
last_tilt = Vector2();
|
||||
last_pressure = (wParam & MK_LBUTTON) ? 1.0f : 0.0f;
|
||||
last_pen_inverted = false;
|
||||
}
|
||||
} else {
|
||||
last_tilt = Vector2();
|
||||
last_pressure = (wParam & MK_LBUTTON) ? 1.0f : 0.0f;
|
||||
last_pen_inverted = false;
|
||||
}
|
||||
|
||||
mm->set_pressure(last_pressure);
|
||||
mm->set_tilt(last_tilt);
|
||||
mm->set_pen_inverted(last_pen_inverted);
|
||||
|
||||
mm->set_button_mask(last_button_state);
|
||||
|
||||
@ -1478,8 +1486,8 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
|
||||
if ((get_current_tablet_driver() == "wintab") && wintab_available) {
|
||||
wintab_WTInfo(WTI_DEFSYSCTX, 0, &wtlc);
|
||||
wtlc.lcOptions |= CXO_MESSAGES;
|
||||
wtlc.lcPktData = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
|
||||
wtlc.lcMoveMask = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE;
|
||||
wtlc.lcPktData = PK_STATUS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
|
||||
wtlc.lcMoveMask = PK_STATUS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE;
|
||||
wtlc.lcPktMode = 0;
|
||||
wtlc.lcOutOrgX = 0;
|
||||
wtlc.lcOutExtX = wtlc.lcInExtX;
|
||||
@ -1507,6 +1515,7 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
|
||||
last_pressure = 0;
|
||||
last_pressure_update = 0;
|
||||
last_tilt = Vector2();
|
||||
last_pen_inverted = false;
|
||||
|
||||
#if defined(OPENGL_ENABLED)
|
||||
|
||||
@ -3823,8 +3832,8 @@ void OS_Windows::set_current_tablet_driver(const String &p_driver) {
|
||||
if ((p_driver == "wintab") && wintab_available) {
|
||||
wintab_WTInfo(WTI_DEFSYSCTX, 0, &wtlc);
|
||||
wtlc.lcOptions |= CXO_MESSAGES;
|
||||
wtlc.lcPktData = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
|
||||
wtlc.lcMoveMask = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE;
|
||||
wtlc.lcPktData = PK_STATUS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
|
||||
wtlc.lcMoveMask = PK_STATUS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE;
|
||||
wtlc.lcPktMode = 0;
|
||||
wtlc.lcOutOrgX = 0;
|
||||
wtlc.lcOutExtX = wtlc.lcInExtX;
|
||||
|
||||
@ -71,10 +71,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;
|
||||
@ -126,6 +129,7 @@ typedef struct tagORIENTATION {
|
||||
} ORIENTATION;
|
||||
|
||||
typedef struct tagPACKET {
|
||||
int pkStatus;
|
||||
int pkNormalPressure;
|
||||
int pkTangentPressure;
|
||||
ORIENTATION pkOrientation;
|
||||
@ -147,6 +151,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
|
||||
@ -272,11 +284,13 @@ class OS_Windows : public OS {
|
||||
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;
|
||||
|
||||
enum {
|
||||
KEY_EVENT_BUFFER_SIZE = 512
|
||||
|
||||
Reference in New Issue
Block a user