/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield * * This software is open source and may be redistributed and/or modified under * the terms of the GNU General Public License (GPL) version 2.0. * The full license is in LICENSE.txt file included with this distribution,. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * include LICENSE.txt for more details. */ #include #include "SDLIntegration.h" #include #include #include #include SDLIntegration::SDLIntegration() { _verbose = false; // init SDL if ( SDL_Init(SDL_INIT_JOYSTICK) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); int numJoysticks = SDL_NumJoysticks(); if (_verbose) { std::cout<<"number of joysticks "<0 ? SDL_JoystickOpen(0) : 0; _numAxes = _joystick ? SDL_JoystickNumAxes(_joystick) : 0; _numBalls = _joystick ? SDL_JoystickNumBalls(_joystick) : 0; _numHats = _joystick ? SDL_JoystickNumHats(_joystick) : 0; _numButtons = _joystick ? SDL_JoystickNumButtons(_joystick) : 0; if (_verbose) { std::cout<<"numAxes = "<<_numAxes<0) { if (newButtonValues[bi]==0) eq->mouseButtonRelease(projected_mx,projected_my,mouseButton,time); else eq->mouseButtonPress(projected_mx,projected_my,mouseButton,time); } else if (key>0) { if (newButtonValues[bi]==0) eq->keyRelease(key,time); else eq->keyPress(key,time); } } } _axisValues.swap(newAxisValues); _buttonValues.swap(newButtonValues); } }