cleanup
This commit is contained in:
69
src/main.cpp
69
src/main.cpp
@@ -718,31 +718,6 @@ int main(int argc, char** argv)
|
||||
LOG("start hmd render thread");
|
||||
App::I.has_vr = true;
|
||||
|
||||
bool trigger_down = false;
|
||||
cbuffer<glm::vec3, 10> controller_points;
|
||||
glm::vec3 controller_last_point;
|
||||
vive->on_button_axis = [&](const Controller& c, Controller::ButtonAxis b, Controller::Action a) {
|
||||
if (b == Controller::ButtonAxis::Trigger)
|
||||
{
|
||||
if (a == Controller::Action::Press)
|
||||
{
|
||||
async_lock();
|
||||
Canvas::I->stroke_start(vive->controllers[0].pos * 800.f, vive->controllers[0].axis[1].x, Canvas::I->m_current_brush);
|
||||
async_unlock();
|
||||
controller_last_point = vive->controllers[0].pos * 800.f;
|
||||
controller_points.clear();
|
||||
trigger_down = true;
|
||||
}
|
||||
if (a == Controller::Action::Release)
|
||||
{
|
||||
trigger_down = false;
|
||||
async_lock();
|
||||
Canvas::I->stroke_end();
|
||||
async_unlock();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const float target_tick_rate = 90;
|
||||
unsigned long t0 = GetTickCount();
|
||||
while (running && vive->Valid())
|
||||
@@ -752,25 +727,9 @@ int main(int argc, char** argv)
|
||||
float dt = (float)(t1 - t0) / 1000.0f;
|
||||
|
||||
vive->Update();
|
||||
App::I.vr_active = vive->active;
|
||||
App::I.vr_controller = vive->controllers[0].xform;
|
||||
App::I.vr_controller_pos = vive->controllers[0].pos;
|
||||
App::I.vr_active = vive->m_active;
|
||||
|
||||
if (trigger_down)
|
||||
{
|
||||
controller_points.add(vive->controllers[0].pos * 800.f);
|
||||
auto p = controller_points.average();
|
||||
if (glm::distance(p, controller_last_point) > 1)
|
||||
{
|
||||
async_lock();
|
||||
Canvas::I->stroke_update(p, vive->controllers[0].axis[1].x);
|
||||
async_unlock();
|
||||
controller_last_point = p;
|
||||
App::I.redraw = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (vive->active)
|
||||
if (vive->m_active)
|
||||
{
|
||||
async_lock();
|
||||
vive->Draw();
|
||||
@@ -1135,29 +1094,23 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
return DefWindowProc(hWnd, msg, wp, lp);
|
||||
}
|
||||
|
||||
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPSTR lpCmdLine, _In_ int nShowCmd)
|
||||
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
||||
{
|
||||
LPWSTR *szArgList{ nullptr };
|
||||
int argc{ 0 };
|
||||
char** argv{ nullptr };
|
||||
|
||||
szArgList = CommandLineToArgvW(GetCommandLine(), &argc);
|
||||
if (szArgList == NULL)
|
||||
{
|
||||
MessageBox(NULL, L"Unable to parse command line", L"Error", MB_OK);
|
||||
return 10;
|
||||
}
|
||||
LPWSTR *wargs = nullptr;
|
||||
char** argv = nullptr;
|
||||
int argc = 0;
|
||||
|
||||
// convert args from char to wchar
|
||||
wargs = CommandLineToArgvW(GetCommandLine(), &argc);
|
||||
argv = new char*[argc + 1];
|
||||
for (int i = 0; i < argc; i++)
|
||||
{
|
||||
auto len = wcslen(szArgList[i]) + 1;
|
||||
auto len = wcslen(wargs[i]) + 1;
|
||||
argv[i] = new char[len];
|
||||
wcstombs_s(nullptr, argv[i], len, szArgList[i], len);
|
||||
wcstombs_s(nullptr, argv[i], len, wargs[i], len);
|
||||
}
|
||||
|
||||
LocalFree(szArgList);
|
||||
LocalFree(wargs);
|
||||
|
||||
return main(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user