From 1c488f8371665c15d8c35b3400fcdcc0f39e4c2d Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Sat, 11 Apr 2026 10:02:37 +0300 Subject: [PATCH] main: initialize the keyboard from within the video module The keyboard is being read from OGC_PumpEvents, which is part of the video subsystem. Therefore ensure that it's initialized in that subsystem, and not in SDL_main. This fixes a bug where an application not using our SDL main would access invalid memory areas due to the keyboard not being initialized. --- src/main/wii/SDL_wii_main.c | 2 -- src/video/ogc/SDL_ogcvideo.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/wii/SDL_wii_main.c b/src/main/wii/SDL_wii_main.c index ec6329d5f023a..80bbbf54b088f 100644 --- a/src/main/wii/SDL_wii_main.c +++ b/src/main/wii/SDL_wii_main.c @@ -38,7 +38,6 @@ #include #include #include -#include #include static void ShutdownCB() @@ -73,7 +72,6 @@ int main(int argc, char *argv[]) WPAD_SetVRes(WPAD_CHAN_ALL, 640, 480); MOUSE_Init(); - KEYBOARD_Init(NULL); fatInitDefault(); /* Call the user's main function. Make sure that argv contains at least one diff --git a/src/video/ogc/SDL_ogcvideo.c b/src/video/ogc/SDL_ogcvideo.c index 5653700f738c3..a99077beb9e48 100644 --- a/src/video/ogc/SDL_ogcvideo.c +++ b/src/video/ogc/SDL_ogcvideo.c @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -315,6 +316,8 @@ int OGC_VideoInit(_THIS) #ifdef __wii__ OGC_InitMouse(_this); + /* OGC_PumpEvents reads the keyboard, so we need to initialize it here */ + KEYBOARD_Init(NULL); #endif return 0; }