From 44eb537564950eea0908c1c136f262bf2f451f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20H=C3=BCbner?= Date: Sat, 23 Jun 2018 02:15:25 +0200 Subject: [PATCH] working shortcuts again --- imgui.ini | 4 ++-- source/app.d | 28 +++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/imgui.ini b/imgui.ini index b828e05..cc124ba 100644 --- a/imgui.ini +++ b/imgui.ini @@ -4,7 +4,7 @@ Size=400,400 Collapsed=0 [Window][Emulator Status] -Pos=156,47 -Size=370,370 +Pos=425,47 +Size=444,533 Collapsed=0 diff --git a/source/app.d b/source/app.d index 61657f0..3de6b9b 100644 --- a/source/app.d +++ b/source/app.d @@ -166,6 +166,31 @@ struct Chip8Status { } // draw + void handleEvent(ref SDL_Event ev) { + switch (ev.type) with (SDL_EventType) { + case SDL_KEYDOWN: + if ((ev.key.keysym.mod & KMOD_CTRL) != 0) { + switch (ev.key.keysym.scancode) with (SDL_EventType) { + case SDL_SCANCODE_L: loadShortcut(); break; + case SDL_SCANCODE_S: saveShortcut(); break; + case SDL_SCANCODE_D: debugShortcut(); break; + case SDL_SCANCODE_G: redrawShortcut(); break; + case SDL_SCANCODE_R: toggleRunShortcut(); break; + case SDL_SCANCODE_T: stepShortcut(); break; + case SDL_SCANCODE_Q: quitShortcut(); + default: break; + } + } else { + if (ev.key.keysym.scancode == SDL_SCANCODE_ESCAPE) { + quitShortcut(); + break; + } + } + default: + break; + } + } // handleEvent + } // Chip8Status string doCapture(string sym, uint start, uint end)(){ @@ -661,7 +686,7 @@ struct Emulator { void create() { // create window - window.createWindow(640, 480); + window.createWindow(960, 768); // setup imgui imgui.initialize(); @@ -678,6 +703,7 @@ struct Emulator { while (SDL_PollEvent(&event)) { imgui.handleEvent(event); + status.handleEvent(event); emu.handleEvent(event); switch (event.type) with (SDL_EventType) {