From 8d31b91e5c026a544b26111bfec690027b2aa525 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 28 Dec 2008 11:40:50 +0000 Subject: [PATCH] Initial joystick support --- src/Input.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Input.cpp b/src/Input.cpp index 9985e44..fb637ae 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -31,10 +31,15 @@ Input::Input() throw runtime_error("Unable to initialise SDL: " + string(SDL_GetError())); } + cout << "Found " << SDL_NumJoysticks() << " joysticks" << endl; + + for (int i = 0; i < SDL_NumJoysticks(); i++) + cout << i << ": " << SDL_JoystickName(i) << endl; + // Only use the first joystick if (SDL_NumJoysticks() > 0) { - SDL_JoystickEventState(SDL_DISABLE); // TODO: enable when I have a joystick to test! - //joystick = SDL_JoystickOpen(0); + SDL_JoystickEventState(SDL_ENABLE); + joystick = SDL_JoystickOpen(0); } for (int i = 0; i < NUM_KEYS; i++) -- 2.39.2