From 72ee43e9470c6fdbc6ed7ff92b85dfa5062c5762 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 6 Jan 2015 18:51:37 +0000 Subject: Added separate event handlers for mouse button clicks and mouse wheel movement. --- src/client/joystick.cc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/client/joystick.cc') diff --git a/src/client/joystick.cc b/src/client/joystick.cc index 0ea05a8..77d0b51 100644 --- a/src/client/joystick.cc +++ b/src/client/joystick.cc @@ -4,7 +4,7 @@ the terms and conditions of the GNU General Public License version 2 */ -#include "SDL/SDL.h" +#include "SDL2/SDL.h" #include "auxiliary/functions.h" #include "client/joystick.h" @@ -38,7 +38,7 @@ void Joystick::init() SDL_Joystick *joystick = SDL_JoystickOpen(i); if (joystick) { con_print << " joystick " << i + 1 << ": " << - SDL_JoystickName(i) << " " << + SDL_JoystickName(joystick) << " " << SDL_JoystickNumAxes(joystick) << " axes " << SDL_JoystickNumButtons(joystick) << " buttons " << std::endl; @@ -84,18 +84,14 @@ void Joystick::list() SDL_JoystickClose(current_joystick); current_joystick = 0; } - /* - // reset makes glorious segfaults - //SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - //SDL_InitSubSystem(SDL_INIT_JOYSTICK); - */ + int nbjoysticks = SDL_NumJoysticks(); if (nbjoysticks) { for (int i = 0; i < nbjoysticks; i++) { SDL_Joystick *joystick = SDL_JoystickOpen(i); if (joystick) { con_print << " joystick " << i + 1 << ": " << - SDL_JoystickName(i) << " " << + SDL_JoystickName(joystick) << " " << SDL_JoystickNumAxes(joystick) << " axes " << SDL_JoystickNumButtons(joystick) << " buttons " << std::endl; @@ -115,7 +111,7 @@ void Joystick::list() } if (current_joystick) { - con_debug << " using joystick " << SDL_JoystickName(current_joystick_number - 1) << std::endl; + con_debug << " using joystick " << SDL_JoystickName(current_joystick) << std::endl; SDL_JoystickEventState(SDL_ENABLE); } } @@ -145,7 +141,7 @@ void Joystick::frame() } if (current_joystick) { - con_debug << " using joystick " << SDL_JoystickName(current_joystick_number - 1) << std::endl; + con_debug << " using joystick " << SDL_JoystickName(current_joystick) << std::endl; SDL_JoystickEventState(SDL_ENABLE); } } -- cgit v1.2.3