/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library 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 * OpenSceneGraph Public License 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); } }