1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-12-21 21:28:33 +00:00

initial implementation of VR

This commit is contained in:
Zeno Rogue
2020-11-19 18:20:06 +01:00
parent 4444fa6bf1
commit 0de8ce9a10
16 changed files with 1315 additions and 49 deletions

View File

@@ -26,6 +26,7 @@ EX bool holdmouse;
EX int getcstat, lgetcstat;
EX ld getcshift;
EX bool inslider;
EX int slider_x;
EX function <void(int sym, int uni)> keyhandler = [] (int sym, int uni) {};
EX function <bool(SDL_Event &ev)> joyhandler = [] (SDL_Event &ev) {return false;};
@@ -134,6 +135,11 @@ EX void movepckeydir(int d) {
if(!canmove) movepcto(md), remission(); else movepcto(md);
}
EX void movevrdir(hyperpoint vec) {
movedir md = vectodir(vec);
if(!canmove) movepcto(md), remission(); else movepcto(md);
}
EX void calcMousedest() {
if(mouseout()) return;
if(vid.revcontrol == true) { mouseh[0] = -mouseh[0]; mouseh[1] = -mouseh[1]; }
@@ -278,6 +284,7 @@ EX bool quitmainloop = false;
EX bool doexiton(int sym, int uni) {
if(sym == SDLK_ESCAPE) return true;
if(sym == SDLK_F10) return true;
if(sym == PSEUDOKEY_EXIT) return true;
if(sym == PSEUDOKEY_RELEASE) return false;
#ifndef FAKE_SDL
if(sym == SDLK_LSHIFT) return false;
@@ -329,6 +336,14 @@ EX void full_forward_camera(ld t) {
}
}
EX void full_strafe_camera(ld t) {
if(GDIM == 3) {
shift_view(ctangent(0, t * camera_speed));
didsomething = true;
playermoved = false;
}
}
EX void full_rotate_camera(int dir, ld val) {
if(rug::rug_control() && lshiftclick) {
val *= camera_rot_speed;
@@ -548,6 +563,9 @@ EX void handleKeyNormal(int sym, int uni) {
if(sym == 'v' && DEFAULTNOR(sym))
pushScreen(showMainMenu);
if(sym == PSEUDOKEY_MENU)
pushScreen(showMainMenu);
if(sym == '-' || sym == PSEUDOKEY_WHEELDOWN) {
actonrelease = false;
@@ -643,6 +661,10 @@ EX void mainloopiter() {
vid.monmode = 0;
#endif
#if CAP_VR
vrhr::vr_shift();
#endif
optimizeview();
models::configure();
@@ -759,6 +781,18 @@ EX void mainloopiter() {
SDL_Event ev;
DEBB(DF_GRAPH, ("polling for events\n"));
#if CAP_VR
if(vrhr::state) {
rug::using_rugview urv;
dynamicval<bool> ds(didsomething, didsomething);
using namespace vrhr;
if(vraim_x) full_rotate_camera(0, -vraim_x / 20);
if(vraim_y) full_rotate_camera(1, vraim_y / 20);
if(vrgo_y) full_forward_camera(-vrgo_y / 20);
if(vrgo_x) full_strafe_camera(-vrgo_x / 20);
}
#endif
if(mouseaiming(shmup::on)) {
#if CAP_MOUSEGRAB
rug::using_rugview urv;
@@ -787,7 +821,17 @@ EX void mainloopiter() {
}
else sc_ticks = ticks;
#if CAP_VR
vrhr::vr_control();
#endif
achievement_pump();
for(auto d: dialog::key_queue) {
println(hlog, "handling key ", d);
handlekey(d, d);
}
dialog::key_queue.clear();
while(SDL_PollEvent(&ev)) handle_event(ev);
fix_mouseh();
#if CAP_SDLJOY