Controller + avoid disassembling if in Release build + minor things

This commit is contained in:
CocoSimone
2022-08-18 18:21:35 +02:00
parent 066b1ace17
commit 02636d38b6
10 changed files with 155 additions and 20 deletions

View File

@@ -5,6 +5,7 @@
void App::Run() {
// Main loop
bool done = false;
const u8* state = SDL_GetKeyboardState(nullptr);
while (!done) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
@@ -14,6 +15,15 @@ void App::Run() {
case SDL_WINDOWEVENT:
done = window.gotClosed(event);
break;
case SDL_CONTROLLERDEVICEADDED: {
const int index = event.cdevice.which;
core.gamepad = SDL_GameControllerOpen(index);
core.gamepadConnected = true;
} break;
case SDL_CONTROLLERDEVICEREMOVED:
SDL_GameControllerClose(core.gamepad);
core.gamepadConnected = false;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym) {
case SDLK_o: {
@@ -28,7 +38,7 @@ void App::Run() {
} break;
}
core.PollInputs(event);
core.UpdateController(state);
}
core.Run(window);