[nostalgia/core/glfw] Fix keyboard support for ImGui

This commit is contained in:
2022-02-01 02:15:49 -06:00
parent 87c03c0d98
commit 0d76129a0e
2 changed files with 20 additions and 20 deletions
-19
View File
@@ -15,24 +15,6 @@ namespace nostalgia::core {
void draw(Context *ctx) noexcept;
static void handleKeyPress(Context *ctx, int key) {
switch (key) {
case GLFW_KEY_ESCAPE:
case GLFW_KEY_Q:
shutdown(ctx);
break;
default:
break;
}
}
static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) {
const auto ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
if (action == GLFW_PRESS) {
handleKeyPress(ctx, key);
}
}
ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, const char *appName) noexcept {
auto ctx = ox::make_unique<Context>();
ctx->rom = std::move(fs);
@@ -43,7 +25,6 @@ ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, const
id->startTime = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
glfwInit();
oxReturnError(initGfx(ctx.get()));
glfwSetKeyCallback(id->window, handleGlfwKeyEvent);
return ctx;
}