00001 /* _______ __ __ __ ______ __ __ _______ __ __ 00002 * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ 00003 * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / 00004 * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / 00005 * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / 00006 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / 00007 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ 00008 * 00009 * Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson 00010 * Copyright (C) 2007 The Mana World Development Team 00011 * 00012 * Js_./ 00013 * Per Larsson a.k.a finalman _RqZ{a<^_aa 00014 * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a// 00015 * _Qhm`] _f "'c 1!5m 00016 * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ 00017 * .)j(] .d_/ '-( P . S 00018 * License: (BSD) <Td/Z <fP"5(\"??"\a. .L 00019 * Redistribution and use in source and _dV>ws?a-?' ._/L #' 00020 * binary forms, with or without )4d[#7r, . ' )d`)[ 00021 * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' 00022 * that the following conditions are met: j<<WP+k/);. _W=j f 00023 * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$ 00024 * retain the above copyright notice, ]E.pYY(Q]>. a J@\ 00025 * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a 00026 * following disclaimer. 4'_uomm\. )L);-4 (3= 00027 * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[ 00028 * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m 00029 * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/ 00030 * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m 00031 * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]' 00032 * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W" 00033 * 3. Neither the name of Guichan nor the :$we` _! + _/ . j? 00034 * names of its contributors may be used =3)= _f (_yQmWW$#( " 00035 * to endorse or promote products derived - W, sQQQQmZQ#Wwa].. 00036 * from this software without specific (js, \[QQW$QWW#?!V"". 00037 * prior written permission. ]y:.<\.. . 00038 * -]n w/ ' [. 00039 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ ! 00040 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , ' 00041 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- % 00042 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r 00043 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La 00044 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L 00045 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a 00046 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'., 00047 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?" 00048 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. . 00049 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _, 00050 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^ 00051 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00052 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00053 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00054 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 00055 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00056 */ 00057 00058 #ifndef SDLINPUT_H 00059 #define SDLINPUT_H 00060 00061 #include <queue> 00062 00063 #include <SDL/SDL.h> 00064 00065 #include <guichan/input.hpp> 00066 #include <guichan/keyinput.hpp> 00067 #include <guichan/mouseinput.hpp> 00068 #include <guichan/platform.hpp> 00069 00070 namespace Key 00071 { 00072 enum 00073 { 00074 SPACE = ' ', 00075 TAB = '\t', 00076 ENTER = '\n', 00077 // Negative values, to avoid conflicts with higher character codes. 00078 LEFT_ALT = -1000, 00079 RIGHT_ALT, 00080 LEFT_SHIFT, 00081 RIGHT_SHIFT, 00082 LEFT_CONTROL, 00083 RIGHT_CONTROL, 00084 LEFT_META, 00085 RIGHT_META, 00086 LEFT_SUPER, 00087 RIGHT_SUPER, 00088 INSERT, 00089 HOME, 00090 PAGE_UP, 00091 DELETE, 00092 END, 00093 PAGE_DOWN, 00094 ESCAPE, 00095 CAPS_LOCK, 00096 BACKSPACE, 00097 F1, 00098 F2, 00099 F3, 00100 F4, 00101 F5, 00102 F6, 00103 F7, 00104 F8, 00105 F9, 00106 F10, 00107 F11, 00108 F12, 00109 F13, 00110 F14, 00111 F15, 00112 PRINT_SCREEN, 00113 SCROLL_LOCK, 00114 PAUSE, 00115 NUM_LOCK, 00116 ALT_GR, 00117 LEFT, 00118 RIGHT, 00119 UP, 00120 DOWN 00121 }; 00122 } 00123 00127 class SDLInput : public gcn::Input 00128 { 00129 public: 00130 00134 SDLInput(); 00135 00142 virtual void pushInput(SDL_Event event); 00143 00149 virtual void _pollInput() { } 00150 00151 00152 // Inherited from Input 00153 00154 virtual bool isKeyQueueEmpty(); 00155 00156 virtual gcn::KeyInput dequeueKeyInput(); 00157 00158 virtual bool isMouseQueueEmpty(); 00159 00160 virtual gcn::MouseInput dequeueMouseInput(); 00161 00162 protected: 00170 int convertMouseButton(int button); 00171 00179 int convertKeyCharacter(SDL_Event event); 00180 00181 std::queue<gcn::KeyInput> mKeyInputQueue; 00182 std::queue<gcn::MouseInput> mMouseInputQueue; 00183 00184 bool mMouseDown; 00185 bool mMouseInWindow; 00186 }; 00187 00188 #endif