Skip to content

Commit

Permalink
gamecube-sdl: 1.2.15-15
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterMute committed Mar 10, 2024
1 parent eb74f0c commit 013a757
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gamecube/SDL/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pkgname=gamecube-sdl
pkgver=1.2.15
pkgrel=13
pkgrel=15
pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard."
arch=('any')
url="https://libsdl.org"
Expand Down Expand Up @@ -38,5 +38,5 @@ package() {
}

sha256sums=('d6d316a793e5e348155f0dd93b979798933fb98aa1edebcc108829d6474aad00'
'5aa8e71f31cc8d10fb586f00a79f0765aed047d6573a02e218034a03606eb90e'
'64f191a298233b078277b483145f28caacd9f6e773cbe18a25be279479b2f337'
'eb33978edaeeb22f83d108ea5236e7f749c3fb3d60765e69f624af2365e2b854')
52 changes: 50 additions & 2 deletions gamecube/SDL/SDL-1.2.15.patch
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,32 @@ index ab50ef1e2..9824c5063 100644

#ifdef __cplusplus
#define C_LINKAGE "C"
diff --git a/src/SDL.c b/src/SDL.c
index 87f1b1af2..bcb53f7e0 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -121,6 +121,10 @@ int SDL_InitSubSystem(Uint32 flags)
if ( SDL_JoystickInit() < 0 ) {
return(-1);
}
+// joystick 0 is used for mouse emulation on wii & cube.
+#if defined (__wii__) || defined (__gamecube__)
+ SDL_JoystickOpen(0);
+#endif
SDL_initialized |= SDL_INIT_JOYSTICK;
}
#else
@@ -155,6 +159,10 @@ int SDL_Init(Uint32 flags)
}
#endif

+// On Wii & GameCube always initialise joysticks.
+#if defined(__wii__) || defined (__gamecube__)
+ flags |= SDL_INIT_JOYSTICK;
+#endif
/* Clear the error message */
SDL_ClearError();

diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index beb26e0b4..fbbeb459f 100644
--- a/src/audio/SDL_audio.c
Expand Down Expand Up @@ -3006,10 +3032,10 @@ index 000000000..a86ad89b4
+#endif /* _SDL_wiivideo_h */
diff --git a/src/video/wii/SDL_wiievents.c b/src/video/wii/SDL_wiievents.c
new file mode 100644
index 000000000..048f12415
index 000000000..2688bda3f
--- /dev/null
+++ b/src/video/wii/SDL_wiievents.c
@@ -0,0 +1,242 @@
@@ -0,0 +1,264 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
Expand Down Expand Up @@ -3065,9 +3091,31 @@ index 000000000..048f12415
+
+ // this will only work if Joystick 0 has been opened and has been polled
+ WPADData *wd = WPAD_Data(WPAD_CHAN_0);
+
+ static Uint8 lastButtonStateA = SDL_RELEASED;
+ static Uint8 lastButtonStateB = SDL_RELEASED;
+
+ Uint8 stateA = (wd->btns_h & WPAD_BUTTON_A) ? SDL_PRESSED : SDL_RELEASED;
+ Uint8 stateB = (wd->btns_h & WPAD_BUTTON_B) ? SDL_PRESSED : SDL_RELEASED;
+
+ if (stateA != lastButtonStateA)
+ {
+ lastButtonStateA = stateA;
+ posted += SDL_PrivateMouseButton(stateA, SDL_BUTTON_LEFT, 0, 0);
+ }
+
+ if (stateB != lastButtonStateB)
+ {
+ lastButtonStateB = stateB;
+ posted += SDL_PrivateMouseButton(stateB, SDL_BUTTON_RIGHT, 0, 0);
+ }
+
+
+ if (wd && wd->exp.type != WPAD_EXP_CLASSIC && wd->ir.valid) {
+
+ // use SDL_BUTTON_X2 to signal that this is the wiimote acting as a mouse
+ Uint8 Buttons = SDL_GetMouseState(NULL, NULL)|SDL_BUTTON_X2MASK;
+
+ if (wd->ir.x < vresx/8)
+ wd->ir.x = vresx/8;
+ else if (wd->ir.x > (vresx + vresx/8))
Expand Down

0 comments on commit 013a757

Please sign in to comment.