vr brush preview and pen gestures (pick and size)

This commit is contained in:
2018-10-30 00:37:46 +01:00
parent a64e2fa8fb
commit 3b73e84fe9
5 changed files with 74 additions and 19 deletions

View File

@@ -714,7 +714,7 @@ int main(int argc, char** argv)
BT_SetTerminate();
LOG("start hmd render thread");
App::I.has_vr = true;
const float target_tick_rate = 90;
unsigned long t0 = GetTickCount();
while (running && vive->Valid())
@@ -731,6 +731,7 @@ int main(int argc, char** argv)
const int diff = framerate - (t1 - t0);
hmd_render_cv.wait_for(lock, std::chrono::milliseconds(diff));
}
App::I.has_vr = false;
async_lock();
vive->Terminate();
async_unlock();
@@ -772,7 +773,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
static bool leftDown = false;
static DWORD lastTime;
static POINT lastPoint;
static glm::vec2 lastPoint;
auto extra = GetMessageExtraInfo();
// if ((extra & 0xFFFFFF00) == 0xFF515700)
@@ -866,8 +867,25 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
break;
case WM_MOUSEMOVE:
{
/*
RECT r;
POINT curpos;
GetWindowRect(hWnd, &r);
glm::vec2 center = { r.left + (r.right - r.left) / 2, r.top + (r.bottom - r.top) / 2 };
GetCursorPos(&curpos);
SetCursorPos(center.x, center.y);
//glm::vec2 cur = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) };
glm::vec2 sz = { App::I.width, App::I.height };
glm::vec2 diff = { curpos.x - center.x, curpos.y - center.y };
lastPoint = glm::clamp(lastPoint + diff, { 0, 0 }, sz);
*/
lastPoint = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) };
auto pt = lastPoint;
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([lp, extra, p = WacomTablet::I.get_pressure()]{
tasklist.emplace_back([pt, extra, p = WacomTablet::I.get_pressure()]{
kEventSource pointer_source;
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
{
@@ -879,14 +897,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
if ((extra & 0xFFFFFF00) == 0xFF515700)
pointer_source = kEventSource::Touch;
}
App::I.mouse_move((float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, pointer_source, WacomTablet::I.m_eraser);
App::I.mouse_move((float)pt.x, (float)pt.y, p, pointer_source, WacomTablet::I.m_eraser);
});
}
break;
case WM_LBUTTONDOWN:
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([lp, extra, hWnd, p = WacomTablet::I.get_pressure()]{
auto pt = lastPoint;
tasklist.emplace_back([pt, extra, hWnd, p = WacomTablet::I.get_pressure()]{
SetCapture(hWnd);
kEventSource pointer_source;
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
@@ -899,14 +918,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
if ((extra & 0xFFFFFF00) == 0xFF515700)
pointer_source = kEventSource::Touch;
}
App::I.mouse_down(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, pointer_source, WacomTablet::I.m_eraser);
App::I.mouse_down(0, (float)pt.x, (float)pt.y, p, pointer_source, WacomTablet::I.m_eraser);
});
}
break;
case WM_LBUTTONUP:
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([lp, extra]{
auto pt = lastPoint;
tasklist.emplace_back([pt, extra] {
WacomTablet::I.reset_pressure();
ReleaseCapture();
kEventSource pointer_source;
@@ -920,14 +940,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
if ((extra & 0xFFFFFF00) == 0xFF515700)
pointer_source = kEventSource::Touch;
}
App::I.mouse_up(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), pointer_source, WacomTablet::I.m_eraser);
App::I.mouse_up(0, (float)pt.x, (float)pt.y, pointer_source, WacomTablet::I.m_eraser);
});
}
break;
case WM_RBUTTONDOWN:
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([lp, extra, hWnd]{
auto pt = lastPoint;
tasklist.emplace_back([pt, extra, hWnd] {
SetCapture(hWnd);
kEventSource pointer_source;
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
@@ -940,14 +961,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
if ((extra & 0xFFFFFF00) == 0xFF515700)
pointer_source = kEventSource::Touch;
}
App::I.mouse_down(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), 1.f, pointer_source, 0);
App::I.mouse_down(1, (float)pt.x, (float)pt.y, 1.f, pointer_source, 0);
});
}
break;
case WM_RBUTTONUP:
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([lp, extra]{
auto pt = lastPoint;
tasklist.emplace_back([pt, extra] {
ReleaseCapture();
kEventSource pointer_source;
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
@@ -960,7 +982,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
if ((extra & 0xFFFFFF00) == 0xFF515700)
pointer_source = kEventSource::Touch;
}
App::I.mouse_up(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), pointer_source, 0);
App::I.mouse_up(1, (float)pt.x, (float)pt.y, pointer_source, 0);
});
}
break;