https://github.com/libsdl-org/Maelstrom/commit/4a1202de6f79afc952f6298bb1b86e3b35502433
From 4a1202de6f79afc952f6298bb1b86e3b35502433 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 24 Nov 2011 13:46:29 -0500
Subject: [PATCH] Don't complain if we don't have any joysticks
---
game/controls.cpp | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/game/controls.cpp b/game/controls.cpp
index cef23cb8..6e852dfd 100644
--- a/game/controls.cpp
+++ b/game/controls.cpp
@@ -434,18 +434,20 @@ void InitPlayerControls(void)
Uint8 controlMask = 0;
unsigned i;
- for (i = 0; i < MAX_PLAYERS; ++i) {
- controlMask |= gPlayers[i]->GetControlType();
- }
-
- for (i = 0; i < MAX_JOYSTICKS; ++i) {
- if (!(controlMask & joystickMasks[i])) {
- continue;
+ if (SDL_NumJoysticks() > 0) {
+ for (i = 0; i < MAX_PLAYERS; ++i) {
+ controlMask |= gPlayers[i]->GetControlType();
}
- joysticks[i] = SDL_JoystickOpen(i);
- if (joysticks[i] == NULL) {
- error("Warning: Couldn't open joystick '%s' : %s\n",
- SDL_JoystickName(i), SDL_GetError());
+
+ for (i = 0; i < MAX_JOYSTICKS; ++i) {
+ if (!(controlMask & joystickMasks[i])) {
+ continue;
+ }
+ joysticks[i] = SDL_JoystickOpen(i);
+ if (joysticks[i] == NULL) {
+ error("Warning: Couldn't open joystick '%s' : %s\n",
+ SDL_JoystickName(i), SDL_GetError());
+ }
}
}
}