diff --git a/CMakeLists.txt b/CMakeLists.txt index c6099dc..9343b09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,10 @@ set(CMAKE_C_STANDARD 11) project(seika C) +if (NOT DEFINED SEIKA_STATIC_LIB) + set(SEIKA_STATIC_LIB "Make seika and dependent libs static" ON) +endif () + if (CMAKE_C_COMPILER_ID STREQUAL "MSVC") list(APPEND flags "/W3" "/Zc:preprocessor") elseif (APPLE) @@ -23,17 +27,26 @@ include(Dependencies.cmake) #--- Link ---# if (CMAKE_C_COMPILER_ID STREQUAL "MSVC") - target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio SDL3::SDL3-static freetype Ws2_32) + target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio ${SDL3_LIBRARY} freetype Ws2_32) elseif (WIN32) - target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -lmingw32 -static-libgcc SDL3::SDL3-static freetype -lws2_32) + target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -lmingw32 -static-libgcc ${SDL3_LIBRARY} freetype -lws2_32) elseif (APPLE) - target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -Xlinker SDL3::SDL3-static freetype m) + target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -Xlinker ${SDL3_LIBRARY} freetype m) else () - target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -static-libgcc -Xlinker -export-dynamic SDL3::SDL3-static freetype m) + target_link_libraries(${PROJECT_NAME} PUBLIC cglm glad stb_image zip miniaudio -static-libgcc -Xlinker -export-dynamic ${SDL3_LIBRARY} freetype m) endif () target_compile_options(${PROJECT_NAME} PUBLIC ${flags}) +if (NOT SEIKA_STATIC_LIB) + # SDL + file(GLOB SDL3_DLLS "${CMAKE_BINARY_DIR}/_deps/sdl_content-build/*.dll") + install(FILES ${SDL3_DLLS} DESTINATION ${CMAKE_BINARY_DIR}) + # Freetype + file(GLOB FREETYPE_DLLS "${CMAKE_BINARY_DIR}/_deps/freetype_content-build/*.dll") + install(FILES ${FREETYPE_DLLS} DESTINATION ${CMAKE_BINARY_DIR}) +endif () + # Copy directories over that are needed to test if (NOT DEFINED IS_CI_BUILD) set(IS_CI_BUILD "false") diff --git a/Dependencies.cmake b/Dependencies.cmake index 4b7bb20..88c3871 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -1,9 +1,5 @@ include(FetchContent) -if (NOT DEFINED SEIKA_STATIC_LIB) - set(SEIKA_STATIC_LIB "Make seika and dependent libs static" ON) -endif () - # https://github.com/libsdl-org/SDL if (NOT TARGET SDL3::SDL3-static) set(SDL_STATIC ${SEIKA_STATIC_LIB}) @@ -15,6 +11,12 @@ if (NOT TARGET SDL3::SDL3-static) GIT_TAG cacac6cc341d5856d1857bdcf7390551eed54865 ) FetchContent_MakeAvailable(SDL_content) + + if (SEIKA_STATIC_LIB) + SET(SDL3_LIBRARY SDL3::SDL3-static) + else () + SET(SDL3_LIBRARY SDL3::SDL3) + endif () endif () # https://github.com/Dav1dde/glad diff --git a/seika/input/sdl_input.h b/seika/input/sdl_input.h index eedb92e..7001e6a 100644 --- a/seika/input/sdl_input.h +++ b/seika/input/sdl_input.h @@ -317,14 +317,13 @@ void ska_sdl_process_axis_events() { } else { *hasStoppedAxisMotion = false; } - const f32 axisValueNormalized = ska_math_map_to_range((f32) axisValue, (f32) INT16_MIN, (f32) INT16_MAX, - -1.0f, 1.0f); + const f32 axisValueNormalized = ska_math_map_to_range((f32) axisValue, (f32) INT16_MIN, (f32) INT16_MAX,-1.0f, 1.0f); const SkaSDLInputEvent inputEvent = { - .sourceType = SkaInputSourceType_GAMEPAD, - .triggerType = triggerType, - .deviceIndex = i, - .key = ska_sdl_gamepad_axis_to_input_key(axis), - .axisMotionValue = axisValueNormalized + .sourceType = SkaInputSourceType_GAMEPAD, + .triggerType = triggerType, + .deviceIndex = (SkaInputDeviceIndex)i, + .key = ska_sdl_gamepad_axis_to_input_key(axis), + .axisMotionValue = axisValueNormalized }; ska_sdl_notify_input_event(&inputEvent); } diff --git a/seika/seika.c b/seika/seika.c index e7a7a3d..af62833 100644 --- a/seika/seika.c +++ b/seika/seika.c @@ -116,10 +116,6 @@ void ska_update() { } } ska_sdl_process_axis_events(); - - if (ska_input_is_key_just_pressed(SkaInputKey_KEYBOARD_ESCAPE, SKA_INPUT_FIRST_PLAYER_DEVICE_INDEX)) { - skaState.shutdownRequested = true; - } } void ska_fixed_update(f32 deltaTime) { diff --git a/seika/version_info.h b/seika/version_info.h index d052db5..665bf70 100644 --- a/seika/version_info.h +++ b/seika/version_info.h @@ -4,6 +4,6 @@ #define SKA_VERSION_MAJOR 0 #define SKA_VERSION_MINOR 1 -#define SKA_VERSION_PATCH 1 +#define SKA_VERSION_PATCH 2 #define SKA_VERSION (SKA_MACRO_TO_STRING(SKA_VERSION_MAJOR) "." SKA_MACRO_TO_STRING(SKA_VERSION_MINOR) "." SKA_MACRO_TO_STRING(SKA_VERSION_PATCH))