[Linux/Windows] Set pressure to 1.0f when primary button is pressed and device is not pressure sensitive.
(cherry picked from commit 0128947894
)
This commit is contained in:
parent
a286edb821
commit
da2ca9e22a
|
@ -446,6 +446,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
mm->set_control(control_mem);
|
mm->set_control(control_mem);
|
||||||
mm->set_shift(shift_mem);
|
mm->set_shift(shift_mem);
|
||||||
mm->set_alt(alt_mem);
|
mm->set_alt(alt_mem);
|
||||||
|
mm->set_pressure((raw->data.mouse.ulButtons & RI_MOUSE_LEFT_BUTTON_DOWN) ? 1.0f : 0.0f);
|
||||||
|
|
||||||
mm->set_button_mask(last_button_state);
|
mm->set_button_mask(last_button_state);
|
||||||
|
|
||||||
|
@ -554,13 +555,21 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
Ref<InputEventMouseMotion> mm;
|
Ref<InputEventMouseMotion> mm;
|
||||||
mm.instance();
|
mm.instance();
|
||||||
|
|
||||||
mm->set_pressure(pen_info.pressure ? (float)pen_info.pressure / 1024 : 0);
|
if (pen_info.penMask & PEN_MASK_PRESSURE) {
|
||||||
mm->set_tilt(Vector2(pen_info.tiltX ? (float)pen_info.tiltX / 90 : 0, pen_info.tiltY ? (float)pen_info.tiltY / 90 : 0));
|
mm->set_pressure((float)pen_info.pressure / 1024);
|
||||||
|
} else {
|
||||||
|
mm->set_pressure((HIWORD(wParam) & POINTER_MESSAGE_FLAG_FIRSTBUTTON) ? 1.0f : 0.0f);
|
||||||
|
}
|
||||||
|
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_control((wParam & MK_CONTROL) != 0);
|
mm->set_control((wParam & MK_CONTROL) != 0);
|
||||||
mm->set_shift((wParam & MK_SHIFT) != 0);
|
mm->set_shift((wParam & MK_SHIFT) != 0);
|
||||||
mm->set_alt(alt_mem);
|
mm->set_alt(alt_mem);
|
||||||
|
|
||||||
|
mm->set_pressure((wParam & MK_LBUTTON) ? 1.0f : 0.0f);
|
||||||
|
|
||||||
mm->set_button_mask(last_button_state);
|
mm->set_button_mask(last_button_state);
|
||||||
|
|
||||||
POINT coords; //client coords
|
POINT coords; //client coords
|
||||||
|
|
|
@ -64,6 +64,22 @@ typedef UINT32 POINTER_FLAGS;
|
||||||
typedef UINT32 PEN_FLAGS;
|
typedef UINT32 PEN_FLAGS;
|
||||||
typedef UINT32 PEN_MASK;
|
typedef UINT32 PEN_MASK;
|
||||||
|
|
||||||
|
#ifndef PEN_MASK_PRESSURE
|
||||||
|
#define PEN_MASK_PRESSURE 0x00000001
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PEN_MASK_TILT_X
|
||||||
|
#define PEN_MASK_TILT_X 0x00000004
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PEN_MASK_TILT_Y
|
||||||
|
#define PEN_MASK_TILT_Y 0x00000008
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef POINTER_MESSAGE_FLAG_FIRSTBUTTON
|
||||||
|
#define POINTER_MESSAGE_FLAG_FIRSTBUTTON 0x00000010
|
||||||
|
#endif
|
||||||
|
|
||||||
enum tagPOINTER_INPUT_TYPE {
|
enum tagPOINTER_INPUT_TYPE {
|
||||||
PT_POINTER = 0x00000001,
|
PT_POINTER = 0x00000001,
|
||||||
PT_TOUCH = 0x00000002,
|
PT_TOUCH = 0x00000002,
|
||||||
|
|
|
@ -2085,6 +2085,7 @@ void OS_X11::process_xevents() {
|
||||||
|
|
||||||
xi.pressure = 0;
|
xi.pressure = 0;
|
||||||
xi.tilt = Vector2();
|
xi.tilt = Vector2();
|
||||||
|
xi.pressure_supported = false;
|
||||||
|
|
||||||
while (XPending(x11_display) > 0) {
|
while (XPending(x11_display) > 0) {
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
@ -2137,9 +2138,11 @@ void OS_X11::process_xevents() {
|
||||||
Map<int, Vector2>::Element *pen_pressure = xi.pen_pressure_range.find(device_id);
|
Map<int, Vector2>::Element *pen_pressure = xi.pen_pressure_range.find(device_id);
|
||||||
if (pen_pressure) {
|
if (pen_pressure) {
|
||||||
Vector2 pen_pressure_range = pen_pressure->value();
|
Vector2 pen_pressure_range = pen_pressure->value();
|
||||||
if (pen_pressure_range != Vector2())
|
if (pen_pressure_range != Vector2()) {
|
||||||
|
xi.pressure_supported = true;
|
||||||
xi.pressure = (*values - pen_pressure_range[0]) /
|
xi.pressure = (*values - pen_pressure_range[0]) /
|
||||||
(pen_pressure_range[1] - pen_pressure_range[0]);
|
(pen_pressure_range[1] - pen_pressure_range[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
values++;
|
values++;
|
||||||
|
@ -2484,7 +2487,11 @@ void OS_X11::process_xevents() {
|
||||||
Ref<InputEventMouseMotion> mm;
|
Ref<InputEventMouseMotion> mm;
|
||||||
mm.instance();
|
mm.instance();
|
||||||
|
|
||||||
mm->set_pressure(xi.pressure);
|
if (xi.pressure_supported) {
|
||||||
|
mm->set_pressure(xi.pressure);
|
||||||
|
} else {
|
||||||
|
mm->set_pressure((get_mouse_button_state() & (1 << (BUTTON_LEFT - 1))) ? 1.0f : 0.0f);
|
||||||
|
}
|
||||||
mm->set_tilt(xi.tilt);
|
mm->set_tilt(xi.tilt);
|
||||||
|
|
||||||
// Make the absolute position integral so it doesn't look _too_ weird :)
|
// Make the absolute position integral so it doesn't look _too_ weird :)
|
||||||
|
|
|
@ -138,6 +138,7 @@ class OS_X11 : public OS_Unix {
|
||||||
XIEventMask all_master_event_mask;
|
XIEventMask all_master_event_mask;
|
||||||
Map<int, Vector2> state;
|
Map<int, Vector2> state;
|
||||||
double pressure;
|
double pressure;
|
||||||
|
bool pressure_supported;
|
||||||
Vector2 tilt;
|
Vector2 tilt;
|
||||||
Vector2 mouse_pos_to_filter;
|
Vector2 mouse_pos_to_filter;
|
||||||
Vector2 relative_motion;
|
Vector2 relative_motion;
|
||||||
|
|
Loading…
Reference in New Issue