fix touch and pen mixed in windows
This commit is contained in:
@@ -16,20 +16,20 @@ void CanvasModeBasicCamera::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
|
||||
switch (me->m_type)
|
||||
{
|
||||
case kEventType::MouseDownL:
|
||||
if (canvas->m_touch_lock && me->m_source == kEventSource::Touch)
|
||||
{
|
||||
m_draggingR = true;
|
||||
m_dragR_start = me->m_pos;
|
||||
m_pan_start = canvas->m_pan;
|
||||
node->mouse_capture();
|
||||
}
|
||||
// if (canvas->m_touch_lock && me->m_source == kEventSource::Touch)
|
||||
// {
|
||||
// m_draggingR = true;
|
||||
// m_dragR_start = me->m_pos;
|
||||
// m_pan_start = canvas->m_pan;
|
||||
// node->mouse_capture();
|
||||
// }
|
||||
break;
|
||||
case kEventType::MouseUpL:
|
||||
if (canvas->m_touch_lock && me->m_source == kEventSource::Touch)
|
||||
{
|
||||
m_draggingR = false;
|
||||
node->mouse_release();
|
||||
}
|
||||
// if (canvas->m_touch_lock && me->m_source == kEventSource::Touch)
|
||||
// {
|
||||
// m_draggingR = false;
|
||||
// node->mouse_release();
|
||||
// }
|
||||
break;
|
||||
case kEventType::MouseDownR:
|
||||
if (App::I.keys[(int)kKey::KeyAlt])
|
||||
|
||||
35
src/main.cpp
35
src/main.cpp
@@ -30,6 +30,8 @@ int gl_count = 0;
|
||||
std::deque<std::packaged_task<void()>> tasklist;
|
||||
std::mutex task_mutex;
|
||||
float timer_stylus = 0;
|
||||
float timer_ink_touch = 0;
|
||||
float timer_ink_pen = 0;
|
||||
bool sandboxed = false;
|
||||
|
||||
//Returns the last Win32 error, in string format. Returns an empty string if there is no error.
|
||||
@@ -603,6 +605,8 @@ int main(int argc, char** argv)
|
||||
render_timer += dt;
|
||||
frame_timer += dt;
|
||||
timer_stylus += dt;
|
||||
timer_ink_touch += dt;
|
||||
timer_ink_pen += dt;
|
||||
t0 = t1;
|
||||
|
||||
if (one_sec > 1.f)
|
||||
@@ -644,14 +648,23 @@ int main(int argc, char** argv)
|
||||
App::I.redraw = true;
|
||||
render_timer = 0;
|
||||
}
|
||||
if (timer_stylus > 0.1 && WacomTablet::I.m_stylus)
|
||||
if (timer_stylus > 0.1 && (WacomTablet::I.m_stylus || WacomTablet::I.m_eraser))
|
||||
{
|
||||
WacomTablet::I.m_stylus = false;
|
||||
WacomTablet::I.m_eraser = false;
|
||||
WacomTablet::I.m_ink = false;
|
||||
App::I.redraw = true;
|
||||
}
|
||||
if (timer_ink_pen > 0.1 && WacomTablet::I.m_ink_pen)
|
||||
{
|
||||
WacomTablet::I.m_ink_pen = false;
|
||||
App::I.redraw = true;
|
||||
}
|
||||
if (timer_ink_touch > 0.1 && WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
WacomTablet::I.m_ink_touch = false;
|
||||
App::I.redraw = true;
|
||||
}
|
||||
|
||||
if (App::I.redraw)
|
||||
{
|
||||
async_lock();
|
||||
@@ -802,9 +815,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
std::lock_guard<std::mutex> lock(task_mutex);
|
||||
tasklist.emplace_back([lp, extra, p = WacomTablet::I.get_pressure()]{
|
||||
kEventSource pointer_source;
|
||||
if (WacomTablet::I.m_ink)
|
||||
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_ink_pen? kEventSource::Stylus : kEventSource::Touch;
|
||||
pointer_source = WacomTablet::I.m_ink_pen ? kEventSource::Stylus : kEventSource::Touch;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -822,7 +835,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
tasklist.emplace_back([lp, extra, hWnd, p = WacomTablet::I.get_pressure()]{
|
||||
SetCapture(hWnd);
|
||||
kEventSource pointer_source;
|
||||
if (WacomTablet::I.m_ink)
|
||||
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_ink_pen ? kEventSource::Stylus : kEventSource::Touch;
|
||||
}
|
||||
@@ -843,7 +856,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
WacomTablet::I.reset_pressure();
|
||||
ReleaseCapture();
|
||||
kEventSource pointer_source;
|
||||
if (WacomTablet::I.m_ink)
|
||||
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_ink_pen ? kEventSource::Stylus : kEventSource::Touch;
|
||||
}
|
||||
@@ -863,7 +876,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
tasklist.emplace_back([lp, extra, hWnd]{
|
||||
SetCapture(hWnd);
|
||||
kEventSource pointer_source;
|
||||
if (WacomTablet::I.m_ink)
|
||||
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_ink_pen ? kEventSource::Stylus : kEventSource::Touch;
|
||||
}
|
||||
@@ -883,7 +896,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
tasklist.emplace_back([lp, extra]{
|
||||
ReleaseCapture();
|
||||
kEventSource pointer_source;
|
||||
if (WacomTablet::I.m_ink)
|
||||
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_ink_pen ? kEventSource::Stylus : kEventSource::Touch;
|
||||
}
|
||||
@@ -948,8 +961,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
// success, process touchInfo
|
||||
// mark as handled to skip call to DefWindowProc
|
||||
//fHandled = TRUE;
|
||||
WacomTablet::I.m_ink = true;
|
||||
WacomTablet::I.m_ink_pen = false;
|
||||
timer_ink_touch = 0;
|
||||
WacomTablet::I.m_ink_touch = true;
|
||||
WacomTablet::I.m_pen_pres = 1;
|
||||
}
|
||||
break;
|
||||
@@ -965,7 +978,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
// mark as handled to skip call to DefWindowProc
|
||||
//fHandled = TRUE;
|
||||
//penInfo.pressure
|
||||
WacomTablet::I.m_ink = true;
|
||||
timer_ink_pen = 0;
|
||||
WacomTablet::I.m_ink_pen = true;
|
||||
WacomTablet::I.m_pen_pres = (float)penInfo.pressure / 1024.f;
|
||||
App::I.set_stylus();
|
||||
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
bool m_mouse_down = false;
|
||||
bool m_stylus = false;
|
||||
bool m_eraser = false;
|
||||
bool m_ink = false;
|
||||
bool m_ink_pen = false;
|
||||
bool m_ink_touch = false;
|
||||
|
||||
HCTX TabletInit(HWND hWnd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user