mirror of
https://github.com/CrispyPin/sinpin-vr.git
synced 2024-11-22 18:10:26 +01:00
display cursor position
This commit is contained in:
parent
2242c2c824
commit
e7df6a2776
1 changed files with 20 additions and 4 deletions
24
src/main.cpp
24
src/main.cpp
|
@ -61,9 +61,8 @@ int main(int argc, char **argv)
|
||||||
auto overlay_err = ovr_overlay->CreateOverlay("deskpot", "Desktop view", &handle);
|
auto overlay_err = ovr_overlay->CreateOverlay("deskpot", "Desktop view", &handle);
|
||||||
assert(overlay_err == 0);
|
assert(overlay_err == 0);
|
||||||
ovr_overlay->ShowOverlay(handle);
|
ovr_overlay->ShowOverlay(handle);
|
||||||
ovr_overlay->SetOverlayTextureColorSpace(handle, vr::EColorSpace::ColorSpace_Gamma);
|
ovr_overlay->SetOverlayWidthInMeters(handle, 2.5f);
|
||||||
ovr_overlay->SetOverlayWidthInMeters(handle, 0.5f);
|
uint8_t col[4] = {20, 50, 50, 255};
|
||||||
uint8_t col[4] = {20, 100, 100, 255};
|
|
||||||
ovr_overlay->SetOverlayRaw(handle, &col, 1, 1, 4);
|
ovr_overlay->SetOverlayRaw(handle, &col, 1, 1, 4);
|
||||||
printf("Created overlay instance\n");
|
printf("Created overlay instance\n");
|
||||||
}
|
}
|
||||||
|
@ -101,6 +100,22 @@ int main(int argc, char **argv)
|
||||||
assert(set_err == 0);
|
assert(set_err == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
int pix_x, pix_y;
|
||||||
|
{
|
||||||
|
Window _t1;
|
||||||
|
int _t2;
|
||||||
|
unsigned int _t3;
|
||||||
|
XQueryPointer(xdisplay, root_window, &_t1, &_t1, &pix_x, &pix_y, &_t2, &_t2, &_t3);
|
||||||
|
}
|
||||||
|
float ratio = (float)height / (float)width;
|
||||||
|
float top_edge = 0.5f - ratio / 2.0f;
|
||||||
|
float x = pix_x / (float)width;
|
||||||
|
float y = pix_y / (float)width + top_edge;
|
||||||
|
auto pos = vr::HmdVector2_t{x, y};
|
||||||
|
ovr_overlay->SetOverlayCursorPositionOverride(handle, &pos);
|
||||||
|
}
|
||||||
|
|
||||||
glfwSwapBuffers(gl_window);
|
glfwSwapBuffers(gl_window);
|
||||||
|
|
||||||
usleep(1000000 / FRAMERATE);
|
usleep(1000000 / FRAMERATE);
|
||||||
|
@ -111,9 +126,10 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
void cleanup(int _sig)
|
void cleanup(int _sig)
|
||||||
{
|
{
|
||||||
printf("\nShutting down\n");
|
printf("\nCleaning up\n");
|
||||||
vr::VR_Shutdown();
|
vr::VR_Shutdown();
|
||||||
glfwDestroyWindow(gl_window);
|
glfwDestroyWindow(gl_window);
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
printf("Shutting down\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
Loading…
Reference in a new issue