Skip to content

Commit 1c488f8

Browse files
committed
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.
1 parent 5874423 commit 1c488f8

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/main/wii/SDL_wii_main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include <fat.h>
3939
#include <ogc/usbmouse.h>
4040
#include <ogcsys.h>
41-
#include <wiikeyboard/keyboard.h>
4241
#include <wiiuse/wpad.h>
4342

4443
static void ShutdownCB()
@@ -73,7 +72,6 @@ int main(int argc, char *argv[])
7372
WPAD_SetVRes(WPAD_CHAN_ALL, 640, 480);
7473

7574
MOUSE_Init();
76-
KEYBOARD_Init(NULL);
7775
fatInitDefault();
7876

7977
/* Call the user's main function. Make sure that argv contains at least one

src/video/ogc/SDL_ogcvideo.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <ogc/gx.h>
4242
#include <ogc/system.h>
4343
#include <ogc/video.h>
44+
#include <wiikeyboard/keyboard.h>
4445

4546
#include <opengx.h>
4647

@@ -315,6 +316,8 @@ int OGC_VideoInit(_THIS)
315316

316317
#ifdef __wii__
317318
OGC_InitMouse(_this);
319+
/* OGC_PumpEvents reads the keyboard, so we need to initialize it here */
320+
KEYBOARD_Init(NULL);
318321
#endif
319322
return 0;
320323
}

0 commit comments

Comments
 (0)