working shortcuts again

This commit is contained in:
Robin Hübner 2018-06-23 02:15:25 +02:00
parent 90897bd8d6
commit 44eb537564
2 changed files with 29 additions and 3 deletions

View File

@ -4,7 +4,7 @@ Size=400,400
Collapsed=0 Collapsed=0
[Window][Emulator Status] [Window][Emulator Status]
Pos=156,47 Pos=425,47
Size=370,370 Size=444,533
Collapsed=0 Collapsed=0

View File

@ -166,6 +166,31 @@ struct Chip8Status {
} // draw } // 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 } // Chip8Status
string doCapture(string sym, uint start, uint end)(){ string doCapture(string sym, uint start, uint end)(){
@ -661,7 +686,7 @@ struct Emulator {
void create() { void create() {
// create window // create window
window.createWindow(640, 480); window.createWindow(960, 768);
// setup imgui // setup imgui
imgui.initialize(); imgui.initialize();
@ -678,6 +703,7 @@ struct Emulator {
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
imgui.handleEvent(event); imgui.handleEvent(event);
status.handleEvent(event);
emu.handleEvent(event); emu.handleEvent(event);
switch (event.type) with (SDL_EventType) { switch (event.type) with (SDL_EventType) {