Skip to content

Commit 9f4ea09

Browse files
author
Semphris
committed
Added rumbling when a new device is selected
1 parent 85f41d4 commit 9f4ea09

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

src/supertux/menu/multiplayer_player_menu.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616

1717
#include "supertux/menu/multiplayer_player_menu.hpp"
1818

19+
#include "SDL.h"
20+
1921
#include "control/game_controller_manager.hpp"
2022
#include "control/input_manager.hpp"
2123
#include "control/joystick_manager.hpp"
2224
#include "gui/dialog.hpp"
25+
#include "supertux/gameconfig.hpp"
2326
#include "supertux/game_session.hpp"
27+
#include "supertux/globals.hpp"
2428
#include "supertux/savegame.hpp"
2529
#include "supertux/sector.hpp"
2630
#include "object/player.hpp"
@@ -146,6 +150,30 @@ MultiplayerPlayerMenu::MultiplayerPlayerMenu(int player_id)
146150
pair2.second = -1;
147151

148152
MenuManager::instance().set_menu(std::make_unique<MultiplayerPlayerMenu>(player_id));
153+
154+
#if SDL_VERSION_ATLEAST(2, 0, 9)
155+
if (g_config->multiplayer_buzz_controllers)
156+
{
157+
#if SDL_VERSION_ATLEAST(2, 0, 18)
158+
if (SDL_GameControllerHasRumble(controller))
159+
{
160+
#endif
161+
// TODO: Rumble intensity setting (like volume)
162+
SDL_GameControllerRumble(controller, 0xFFFF, 0xFFFF, 300);
163+
#if SDL_VERSION_ATLEAST(2, 0, 18)
164+
}
165+
else
166+
{
167+
Dialog::show_message(_("This controller does not support rumbling;\n"
168+
"please check the controllers manually."));
169+
}
170+
#endif
171+
}
172+
#else
173+
Dialog::show_message(_("This SuperTux build does not support rumbling\n"
174+
"controllers; please check the controllers manually.\n"
175+
"\nYou may disable this message in the Options menu."));
176+
#endif
149177
});
150178
}
151179
}
@@ -165,6 +193,30 @@ MultiplayerPlayerMenu::MultiplayerPlayerMenu(int player_id)
165193
pair2.second = -1;
166194

167195
MenuManager::instance().set_menu(std::make_unique<MultiplayerPlayerMenu>(player_id));
196+
197+
#if SDL_VERSION_ATLEAST(2, 0, 9)
198+
if (g_config->multiplayer_buzz_controllers)
199+
{
200+
#if SDL_VERSION_ATLEAST(2, 0, 18)
201+
if (SDL_JoystickHasRumbleTriggers(joystick))
202+
{
203+
#endif
204+
// TODO: Rumble intensity setting (like volume)
205+
SDL_JoystickRumble(joystick, 0xFFFF, 0xFFFF, 300);
206+
#if SDL_VERSION_ATLEAST(2, 0, 18)
207+
}
208+
else
209+
{
210+
Dialog::show_message(_("This joystick does not support rumbling;\n"
211+
"please check the joysticks manually."));
212+
}
213+
#endif
214+
}
215+
#else
216+
Dialog::show_message(_("This SuperTux build does not support rumbling\n"
217+
"joysticks; please check the joysticks manually.\n"
218+
"\nYou may disable this message in the Options menu."));
219+
#endif
168220
});
169221
}
170222
}

0 commit comments

Comments
 (0)