From 34443ebf35061242004173995de17be9ba64c88c Mon Sep 17 00:00:00 2001 From: im-tem Date: Tue, 1 Jul 2025 17:44:43 +0300 Subject: [PATCH 1/2] win32: handle app icon --- CMakeLists.txt | 6 +++++- assets/win_icon.ico | Bin 0 -> 2183 bytes assets/win_icon.rc | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 assets/win_icon.ico create mode 100644 assets/win_icon.rc diff --git a/CMakeLists.txt b/CMakeLists.txt index bc01344..04b7540 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,11 @@ file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/src/*.h" ) -add_executable(${PROJECT_NAME} ${SOURCES}) +if (WIN32) + enable_language("RC") + set (WIN32_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/assets/win_icon.rc) +endif() +add_executable(${PROJECT_NAME} ${SOURCES} ${WIN32_RESOURCES}) target_include_directories(${PROJECT_NAME} PRIVATE include include/imgui include/tinyxml2 src) if (NOT MSVC) diff --git a/assets/win_icon.ico b/assets/win_icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..624177ea7679f35ed6f08c279ff28bd09609ea65 GIT binary patch literal 2183 zcmZQzU<5)CU}R8WDCA&Z5CgJ11N_{1xum#&OkPh9mmmfPCLoiEfrAZ5eW|$ei-Cc| z!qdeuq+-t78wY#u7znr?T)NO<<%uIcI~6599IUMf<@~^WC_(Pmb9SH(O2EH7Uw(!a zx2o@-{J#JF?3%heQQCjyf23D2FnsvW33P@K1A~AH1A~GG1B1f^28IR&pl=+3u5Dsr zU|^x4g7aS(63*@Y?w3E~%f9ztSR@_;?WBjjxV(13*tTI?_4~Q^3|`jWf62*X^?c34 z@9Oi@XK>Rt9B{b@9vA1oG-Q6iXT3M^((iqjg(bFJi@Ge`AgMP%(FSv_?PcbS=+9_*aGG6|6ue|E;lJ~!tsrOXfFRwbJasU2z{pjqa|CwV4AZ^0}iH6ySBrBpW zGcS9)_x+RK&*z+c&Uoz2UibU<&zB5**i5f_vKRuxU`|9DyD+o59jL`9hyuo-77c_th5;zJYD@< J);T3K0RZUmF;M^j literal 0 HcmV?d00001 diff --git a/assets/win_icon.rc b/assets/win_icon.rc new file mode 100644 index 0000000..dacd6e9 --- /dev/null +++ b/assets/win_icon.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "win_icon.ico" \ No newline at end of file From daefc91a72c08ddd33302ca6a8433bf17ff32833 Mon Sep 17 00:00:00 2001 From: im-tem Date: Tue, 1 Jul 2025 17:45:04 +0300 Subject: [PATCH 2/2] input: hacky way of handling multikey shortcuts --- src/input.cpp | 14 +++++++++++--- src/input.h | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index e61a1b9..906143b 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -109,9 +109,17 @@ input_held(Input* self, InputType type) bool input_release(Input* self, InputType type) { - for (KeyType key : INPUT_KEYS[type]) - if (!key_release(&self->keyboard, (key))) - return false; + for (size_t i = 0; i < INPUT_KEYS[type].size(); i++) { + auto& key = INPUT_KEYS[type][i]; + //below is some hackery to ensure that multikey shortcuts work... + //ideally would split this into a separate function or rename this? + if (i != INPUT_KEYS[type].size()) { + if (!key_held(&self->keyboard, key)) return false; + } + // last key in the shortcut chain, so in a mod1-mod2-...-key it won't be a mod key + // todo: introduce a list of modifer keys as a more reliable solution + else if (!key_release(&self->keyboard, (key))) return false; + }; return true; } diff --git a/src/input.h b/src/input.h index ef55b90..6107424 100644 --- a/src/input.h +++ b/src/input.h @@ -273,13 +273,13 @@ const std::vector INPUT_KEYS[INPUT_COUNT] = { KEY_2 }, { KEY_Z }, { KEY_Y }, - { KEY_LCTRL } + { KEY_LCTRL , KEY_S} }; struct Keyboard { - bool current[KEY_COUNT]; - bool previous[KEY_COUNT]; + bool current[KEY_COUNT] = { 0 }; + bool previous[KEY_COUNT] = { 0 }; }; struct Mouse