diff options
-rw-r--r-- | src/Game.h | 1 | ||||
-rw-r--r-- | src/GameTick.cpp | 6 | ||||
-rw-r--r-- | src/Support.cpp | 25 | ||||
-rw-r--r-- | src/Support.h | 1 | ||||
-rw-r--r-- | src/main.zig | 7 |
5 files changed, 19 insertions, 21 deletions
diff --git a/src/Game.h b/src/Game.h index d2b454f..6e53188 100644 --- a/src/Game.h +++ b/src/Game.h @@ -74,7 +74,6 @@ public: // Mouse Point mouseloc; - Point oldmouseloc; float mouserotation,mouserotation2; float oldmouserotation,oldmouserotation2; float mousesensitivity; diff --git a/src/GameTick.cpp b/src/GameTick.cpp index 6536547..61e5dec 100644 --- a/src/GameTick.cpp +++ b/src/GameTick.cpp @@ -157,7 +157,7 @@ void Game::handleMenu() initGame(this); } - MoveMouse(oldmouseloc.h, oldmouseloc.v, &mouseloc); + GetMouse(&mouseloc); if (visions) alSourcePlay(gSourceID[visionsound]); @@ -3442,9 +3442,7 @@ void Game::Tick() if (paused || person[0].currentanimation== diveanim || person[0].currentanimation == throwanim) - MoveMouse(oldmouseloc.h, oldmouseloc.v, &mouseloc); - else - oldmouseloc = mouseloc; + GetMouse(&mouseloc); setListener(facing); if (score < 0) diff --git a/src/Support.cpp b/src/Support.cpp index 4703b14..a233dd7 100644 --- a/src/Support.cpp +++ b/src/Support.cpp @@ -25,30 +25,33 @@ void GetMouse(Point *p) { double xpos, ypos; glfwGetCursorPos(glfwGetCurrentContext(), &xpos, &ypos); - p->h = xpos; - p->v = ypos; + p->h = floor(xpos); + p->v = floor(ypos); } void GetMouseRel(Point *p) { - return GetMouse(p); + const auto window = glfwGetCurrentContext(); + glfwGetWindowSize(window, &p->h, &p->v); + p->h /= 2; + p->v /= 2; + + double xpos, ypos; + glfwGetCursorPos(window, &xpos, &ypos); + glfwSetCursorPos(window, p->h, p->v); // we shouldn't need this + p->h = floor(xpos) - p->h; + p->v = floor(ypos) - p->v; } int Button(void) { - auto window = glfwGetCurrentContext(); + const auto window = glfwGetCurrentContext(); return glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS; } -void MoveMouse(int xcoord, int ycoord, Point *mouseloc) -{ - /* TODO: mouse warp is annoying when we can just grab the mouse */ - GetMouse(mouseloc); -} - bool IsKeyDown(int key) { - auto window = glfwGetCurrentContext(); + const auto window = glfwGetCurrentContext(); return glfwGetKey(window, key) == GLFW_PRESS; } diff --git a/src/Support.h b/src/Support.h index 83ea163..901b9b4 100644 --- a/src/Support.h +++ b/src/Support.h @@ -34,7 +34,6 @@ typedef struct Point int Random(); void GetMouse(Point *p); void GetMouseRel(Point *p); -void MoveMouse(int xcoord, int ycoord, Point *mouseloc); int Button(void); bool IsKeyDown(int key); diff --git a/src/main.zig b/src/main.zig index 8552e10..70d08c1 100644 --- a/src/main.zig +++ b/src/main.zig @@ -35,11 +35,10 @@ pub fn main() !void { const window = try gf.Window.create(config.width, config.height, "Black Shades", .{}, .{}); try window.makeCurrent(); + try window.setCursorMode(.disabled); + // try window.setInputMode(.raw_mouse_motion, true); + try window.setInputMode(.sticky_mouse_buttons, true); try window.setInputMode(.sticky_keys, true); - if (config.menu) { - try window.setInputMode(.sticky_mouse_buttons, true); - try window.setCursorMode(.hidden); - } legacy.initGl(game); const device = try al.Device.init(null); |