Skip to content

Commit

Permalink
harness: prescale mouse pointer so it works seamlessly with hires
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Nov 9, 2022
1 parent c077b8c commit 6b0d39e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/harness/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ target_include_directories(harness
include
)

if(DETHRACE_FIX_BUGS)
target_compile_definitions(harness PRIVATE DETHRACE_FIX_BUGS)
endif()

target_link_libraries(harness PRIVATE brender compile_with_werror)

if(WIN32)
Expand Down Expand Up @@ -70,6 +74,8 @@ if (IO_PLATFORM STREQUAL "SDL_OpenGL")
renderers/gl/stored_context.c
renderers/gl/stored_context.h
)
target_include_directories(harness PRIVATE "${dethrace_SOURCE_DIR}/src/DETHRACE/common")
target_include_directories(harness PRIVATE "${dethrace_SOURCE_DIR}/src/S3/include")
target_link_libraries(harness PRIVATE SDL2::SDL2 glad)
endif()

Expand Down
13 changes: 13 additions & 0 deletions src/harness/io_platforms/sdl_gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "harness/config.h"
#include "harness/trace.h"

#include "globvars.h"
#include "grafdata.h"
#include "pd/sys.h"

#define ARRAY_LEN(array) (sizeof((array)) / sizeof((array)[0]))

int scancode_map[123];
Expand Down Expand Up @@ -308,6 +312,15 @@ void Input_GetMousePosition(int* pX, int* pY) {
*pY -= vp_y;
*pX *= sdl_window_scale.x;
*pY *= sdl_window_scale.y;

#if defined(DETHRACE_FIX_BUGS)
// In hires mode (640x480), the menus are still rendered at (320x240),
// so prescale the cursor coordinates accordingly.
*pX *= gGraf_specs[gGraf_data_index].phys_width;
*pX /= gGraf_specs[gReal_graf_data_index].phys_width;
*pY *= gGraf_specs[gGraf_data_index].phys_height;
*pY /= gGraf_specs[gReal_graf_data_index].phys_height;
#endif
}

void Input_GetMouseButtons(int* pButton1, int* pButton2) {
Expand Down

0 comments on commit 6b0d39e

Please sign in to comment.