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);

View File

@@ -3,6 +3,7 @@
struct App {
App() : window(core) {};
~App() = default;
void Run();
inline void LoadROM(const std::string& path) {
core.LoadROM(path);

View File

@@ -174,6 +174,9 @@ Window::~Window() {
vkDestroyDescriptorPool(device, descriptorPool, nullptr);
vkDestroyDevice(device, nullptr);
vkDestroyInstance(instance, nullptr);
SDL_DestroyWindow(window);
SDL_DestroyWindow(g_Window);
SDL_Quit();
}
ImDrawData* Window::Present(n64::Core& core) {