Skip to content

Commit

Permalink
remap keys that are unknown to gltf
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Feb 4, 2025
1 parent 46df434 commit 0abad94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions sources/libcore/mesh/exportGltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ namespace cage
detail::StringBase<20> attribute;

// accessor
detail::StringBase<50> min;
detail::StringBase<50> max;
detail::StringBase<100> min;
detail::StringBase<100> max;
detail::StringBase<20> type;
uint32 componentType = 0;
uint32 count = 0;
Expand Down
22 changes: 16 additions & 6 deletions sources/libengine/window/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,15 @@ namespace cage
impl->eventsQueue.push(input::WindowClose{ impl });
}

void windowKeyCallback(GLFWwindow *w, int key, int, int action, int mods)
void windowKeyCallback(GLFWwindow *w, int key, int scan, int action, int mods)
{
if (key == GLFW_KEY_UNKNOWN)
return;
{
if (scan < 0 || scan > 1'000'000)
return;
static_assert(GLFW_KEY_LAST < 10'000);
key = 10'000 + scan;
}

WindowImpl *impl = (WindowImpl *)glfwGetWindowUserPointer(w);
ModifiersFlags ms = getKeyModifiers(mods);
Expand Down Expand Up @@ -917,10 +922,15 @@ namespace cage
case GLFW_KEY_KP_ENTER:
return "Ent";
}
const auto s = glfwGetKeyName(key, 0);
if (!s)
return "???";
return unicodeTransformString(String(s), UnicodeTransformConfig{ UnicodeTransformEnum::Titlecase });
uint32 scan = 0;
if (key >= 10'000)
{
scan = key - 10'000;
key = GLFW_KEY_UNKNOWN;
};
if (const auto s = glfwGetKeyName(key, scan))
return unicodeTransformString(String(s), UnicodeTransformConfig{ UnicodeTransformEnum::Titlecase });
return Stringizer() + (sint32)key + ":" + (sint32)scan;
}

detail::StringBase<27> getButtonsNames(MouseButtonsFlags buttons)
Expand Down

0 comments on commit 0abad94

Please sign in to comment.