diff --git a/game/graphics/pipelines/opengl.cpp b/game/graphics/pipelines/opengl.cpp index 93bdf8daf4..8dedc2154f 100644 --- a/game/graphics/pipelines/opengl.cpp +++ b/game/graphics/pipelines/opengl.cpp @@ -541,6 +541,9 @@ void GLDisplay::render() { game_res_w = 640; game_res_h = 480; } + // set the size of the visible/playable portion of the game in the window + get_display_manager()->set_game_size(Gfx::g_global_settings.lbox_w, + Gfx::g_global_settings.lbox_h); render_game_frame( game_res_w, game_res_h, fbuf_w, fbuf_h, Gfx::g_global_settings.lbox_w, Gfx::g_global_settings.lbox_h, Gfx::g_global_settings.msaa_samples, diff --git a/game/kernel/jak2/kmachine.cpp b/game/kernel/jak2/kmachine.cpp index 82d2e1de79..1eec8c0af8 100644 --- a/game/kernel/jak2/kmachine.cpp +++ b/game/kernel/jak2/kmachine.cpp @@ -468,10 +468,16 @@ u32 MouseGetData(u32 _mouse) { // TODO - probably factor in scaling as well auto win_width = 0; auto win_height = 0; + auto game_width = 0; + auto game_height = 0; if (Display::GetMainDisplay()) { win_width = Display::GetMainDisplay()->get_display_manager()->get_window_width(); win_height = Display::GetMainDisplay()->get_display_manager()->get_window_height(); + game_width = Display::GetMainDisplay()->get_display_manager()->get_window_game_width(); + game_height = Display::GetMainDisplay()->get_display_manager()->get_window_game_height(); } + xpos -= (win_width - game_width) / 2; + ypos -= (win_height - game_height) / 2; // These are used to calculate the speed at which to move the mouse to it's new coordinates // zero'd out so they are ignored and don't impact the position we are about to set @@ -482,8 +488,8 @@ u32 MouseGetData(u32 _mouse) { // - [-208.0, 208.0] for height // (then 208 or 256 is always added to them to get the final screen coordinate) // So just normalize the actual window's values to this range - double width_per = xpos / double(win_width); - double height_per = ypos / double(win_height); + double width_per = xpos / double(game_width); + double height_per = ypos / double(game_height); mouse->posx = (512.0 * width_per) - 256.0; mouse->posy = (416.0 * height_per) - 208.0; // fmt::print("Mouse - X:{}({}), Y:{}({})\n", xpos, mouse->posx, ypos, mouse->posy); diff --git a/game/system/hid/devices/mouse.h b/game/system/hid/devices/mouse.h index 8d2b1a9ac6..9a8bb93c39 100644 --- a/game/system/hid/devices/mouse.h +++ b/game/system/hid/devices/mouse.h @@ -14,11 +14,11 @@ struct ActiveMouseAction { class MouseDevice : public InputDevice { public: struct MouseButtonStatus { - bool left; - bool right; - bool middle; - bool mouse4; - bool mouse5; + bool left = false; + bool right = false; + bool middle = false; + bool mouse4 = false; + bool mouse5 = false; }; MouseDevice(){}; diff --git a/game/system/hid/display_manager.h b/game/system/hid/display_manager.h index 50cf92ec33..befc696479 100644 --- a/game/system/hid/display_manager.h +++ b/game/system/hid/display_manager.h @@ -74,6 +74,8 @@ class DisplayManager { bool is_minimized() { return m_window_state == WindowState::Minimized; } int get_window_width() { return m_window_width; } int get_window_height() { return m_window_height; } + int get_window_game_width() { return m_window_game_width; } + int get_window_game_height() { return m_window_game_height; } float get_window_scale_x() { return m_window_scale_x; } float get_window_scale_y() { return m_window_scale_y; } int num_connected_displays() { return m_current_display_modes.size(); } @@ -90,6 +92,11 @@ class DisplayManager { void enqueue_set_window_display_mode(WindowDisplayMode mode); void enqueue_set_fullscreen_display_id(int display_id); + void set_game_size(int width, int height) { + m_window_game_width = width; + m_window_game_height = height; + } + void set_input_manager(std::shared_ptr input_manager) { m_input_manager = input_manager; } @@ -112,6 +119,8 @@ class DisplayManager { int m_window_ypos = 0; int m_window_width = 0; int m_window_height = 0; + int m_window_game_width = 0; + int m_window_game_height = 0; float m_window_scale_x = 1.0; float m_window_scale_y = 1.0; WindowState m_window_state = WindowState::Restored; diff --git a/goal_src/jak2/engine/ps2/pad.gc b/goal_src/jak2/engine/ps2/pad.gc index eec9b6cd19..bde0f29c44 100644 --- a/goal_src/jak2/engine/ps2/pad.gc +++ b/goal_src/jak2/engine/ps2/pad.gc @@ -585,6 +585,10 @@ The cpad-set-buzz! function can be used for vibration. ) (define *mouse* (new 'global 'mouse-info)) +(#when PC_PORT +;; added so we can hide the mouse +(define *disable-mouse* #f) +) ;; WARN: Return type mismatch mouse-info vs none. (defun service-mouse () @@ -619,7 +623,7 @@ The cpad-set-buzz! function can be used for vibration. (set! (-> gp-0 button0-rel 0) (logclear (-> gp-0 button0-abs 0) (-> gp-0 button0-abs 1))) ) ) - (if (and (-> gp-0 active) (-> gp-0 valid) (-> gp-0 cursor)) + (if (and (-> gp-0 active) (-> gp-0 valid) (-> gp-0 cursor) (#if PC_PORT (not *disable-mouse*) #t)) (add-debug-cursor #t (bucket-id debug-no-zbuf2)