Skip to content

Commit 0abad94

Browse files
committed
remap keys that are unknown to gltf
1 parent 46df434 commit 0abad94

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

sources/libcore/mesh/exportGltf.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ namespace cage
4545
detail::StringBase<20> attribute;
4646

4747
// accessor
48-
detail::StringBase<50> min;
49-
detail::StringBase<50> max;
48+
detail::StringBase<100> min;
49+
detail::StringBase<100> max;
5050
detail::StringBase<20> type;
5151
uint32 componentType = 0;
5252
uint32 count = 0;

sources/libengine/window/window.cpp

+16-6
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,15 @@ namespace cage
260260
impl->eventsQueue.push(input::WindowClose{ impl });
261261
}
262262

263-
void windowKeyCallback(GLFWwindow *w, int key, int, int action, int mods)
263+
void windowKeyCallback(GLFWwindow *w, int key, int scan, int action, int mods)
264264
{
265265
if (key == GLFW_KEY_UNKNOWN)
266-
return;
266+
{
267+
if (scan < 0 || scan > 1'000'000)
268+
return;
269+
static_assert(GLFW_KEY_LAST < 10'000);
270+
key = 10'000 + scan;
271+
}
267272

268273
WindowImpl *impl = (WindowImpl *)glfwGetWindowUserPointer(w);
269274
ModifiersFlags ms = getKeyModifiers(mods);
@@ -917,10 +922,15 @@ namespace cage
917922
case GLFW_KEY_KP_ENTER:
918923
return "Ent";
919924
}
920-
const auto s = glfwGetKeyName(key, 0);
921-
if (!s)
922-
return "???";
923-
return unicodeTransformString(String(s), UnicodeTransformConfig{ UnicodeTransformEnum::Titlecase });
925+
uint32 scan = 0;
926+
if (key >= 10'000)
927+
{
928+
scan = key - 10'000;
929+
key = GLFW_KEY_UNKNOWN;
930+
};
931+
if (const auto s = glfwGetKeyName(key, scan))
932+
return unicodeTransformString(String(s), UnicodeTransformConfig{ UnicodeTransformEnum::Titlecase });
933+
return Stringizer() + (sint32)key + ":" + (sint32)scan;
924934
}
925935

926936
detail::StringBase<27> getButtonsNames(MouseButtonsFlags buttons)

0 commit comments

Comments
 (0)