Merge pull request #2 from im-tem/master
win32 app icon + multikey shortcut fix
This commit is contained in:
@@ -23,7 +23,11 @@ file(GLOB SOURCES
|
|||||||
"${PROJECT_SOURCE_DIR}/src/*.h"
|
"${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)
|
target_include_directories(${PROJECT_NAME} PRIVATE include include/imgui include/tinyxml2 src)
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
|
BIN
assets/win_icon.ico
Normal file
BIN
assets/win_icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
1
assets/win_icon.rc
Normal file
1
assets/win_icon.rc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
IDI_ICON1 ICON DISCARDABLE "win_icon.ico"
|
@@ -109,9 +109,17 @@ input_held(Input* self, InputType type)
|
|||||||
bool
|
bool
|
||||||
input_release(Input* self, InputType type)
|
input_release(Input* self, InputType type)
|
||||||
{
|
{
|
||||||
for (KeyType key : INPUT_KEYS[type])
|
for (size_t i = 0; i < INPUT_KEYS[type].size(); i++) {
|
||||||
if (!key_release(&self->keyboard, (key)))
|
auto& key = INPUT_KEYS[type][i];
|
||||||
return false;
|
//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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -273,13 +273,13 @@ const std::vector<KeyType> INPUT_KEYS[INPUT_COUNT] =
|
|||||||
{ KEY_2 },
|
{ KEY_2 },
|
||||||
{ KEY_Z },
|
{ KEY_Z },
|
||||||
{ KEY_Y },
|
{ KEY_Y },
|
||||||
{ KEY_LCTRL, KEY_S }
|
{ KEY_LCTRL , KEY_S}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Keyboard
|
struct Keyboard
|
||||||
{
|
{
|
||||||
bool current[KEY_COUNT];
|
bool current[KEY_COUNT] = { 0 };
|
||||||
bool previous[KEY_COUNT];
|
bool previous[KEY_COUNT] = { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Mouse
|
struct Mouse
|
||||||
|
Reference in New Issue
Block a user