00001 /* 00002 * Copyright (C) 2003-2009 Olivier Boudeville 00003 * 00004 * This file is part of the OSDL library. 00005 * 00006 * The OSDL library is free software: you can redistribute it and/or modify 00007 * it under the terms of either the GNU Lesser General Public License or 00008 * the GNU General Public License, as they are published by the Free Software 00009 * Foundation, either version 3 of these Licenses, or (at your option) 00010 * any later version. 00011 * 00012 * The OSDL library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License and the GNU General Public License 00016 * for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License and of the GNU General Public License along with the OSDL library. 00020 * If not, see <http://www.gnu.org/licenses/>. 00021 * 00022 * Author: Olivier Boudeville (olivier.boudeville@esperide.com) 00023 * 00024 */ 00025 00026 00027 #include "OSDLJoystickCommon.h" 00028 00029 00030 00031 #ifdef OSDL_USES_CONFIG_H 00032 #include "OSDLConfig.h" // for configure-time settings (SDL) 00033 #endif // OSDL_USES_CONFIG_H 00034 00035 #if OSDL_ARCH_NINTENDO_DS 00036 #include "OSDLConfigForNintendoDS.h" // for OSDL_USES_SDL and al 00037 #endif // OSDL_ARCH_NINTENDO_DS 00038 00039 00040 00041 using std::string ; 00042 00043 using namespace OSDL::Events ; 00044 00045 00046 00047 #if OSDL_USES_SDL 00048 00049 #include "SDL.h" // for SDL_HAT_* 00050 00051 // The eight possible directions for a hat: 00052 00053 extern const HatPosition OSDL::Events::Centered = SDL_HAT_CENTERED ; 00054 extern const HatPosition OSDL::Events::Up = SDL_HAT_UP ; 00055 extern const HatPosition OSDL::Events::Right = SDL_HAT_RIGHT ; 00056 extern const HatPosition OSDL::Events::Down = SDL_HAT_DOWN ; 00057 extern const HatPosition OSDL::Events::Left = SDL_HAT_LEFT ; 00058 00059 extern const HatPosition OSDL::Events::RightUp = SDL_HAT_RIGHTUP ; 00060 extern const HatPosition OSDL::Events::RightDown = SDL_HAT_RIGHTDOWN ; 00061 extern const HatPosition OSDL::Events::LeftUp = SDL_HAT_LEFTUP ; 00062 extern const HatPosition OSDL::Events::LeftDown = SDL_HAT_LEFTDOWN ; 00063 00064 #else // OSDL_USES_SDL 00065 00066 // Same values as SDL: 00067 00068 extern const OSDL::Events::HatPosition OSDL::Events::Centered = 0x00 ; 00069 extern const OSDL::Events::HatPosition OSDL::Events::Up = 0x01 ; 00070 extern const OSDL::Events::HatPosition OSDL::Events::Right = 0x02 ; 00071 extern const OSDL::Events::HatPosition OSDL::Events::Down = 0x04 ; 00072 extern const OSDL::Events::HatPosition OSDL::Events::Left = 0x08 ; 00073 00074 extern const OSDL::Events::HatPosition OSDL::Events::RightUp = 00075 (OSDL::Events::Right|OSDL::Events::Up) ; 00076 00077 extern const OSDL::Events::HatPosition OSDL::Events::RightDown = 00078 (OSDL::Events::Right|OSDL::Events::Down) ; 00079 00080 extern const OSDL::Events::HatPosition OSDL::Events::LeftUp = 00081 (OSDL::Events::Left|OSDL::Events::Up) ; 00082 00083 extern const OSDL::Events::HatPosition OSDL::Events::LeftDown = 00084 (OSDL::Events::Left|OSDL::Events::Down) ; ; 00085 00086 #endif // OSDL_USES_SDL 00087 00088 00089 00090 00091 00092 JoystickException::JoystickException( const std::string & reason ) : 00093 EventsException( "Joystick exception: " + reason ) 00094 { 00095 00096 } 00097 00098 00099 00100 JoystickException::~JoystickException() throw() 00101 { 00102 00103 } 00104