00001 /* This file is part of Annchienta. 00002 * Copyright 2008 (C) Jasper Van der Jeugt 00003 * 00004 * Annchienta is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * Annchienta is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with Annchienta. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef ANNCHIENTA_INPUTMANAGER_H 00019 #define ANNCHIENTA_INPUTMANAGER_H 00020 00021 #include <SDL.h> 00022 #include "Point.h" 00023 00024 namespace Annchienta 00025 { 00026 class Person; 00027 00028 enum InputMode 00029 { 00033 CinematicMode=0, 00037 InteractiveMode=1 00038 }; 00039 00043 class InputManager 00044 { 00045 private: 00046 bool running; 00047 bool tickedKeys[ SDLK_LAST ]; 00048 bool tickedButtons[ 2 ]; 00049 Uint8 *keyState; 00050 int mouseX, mouseY; 00051 Uint8 mouseState; 00052 bool supportMouse; 00053 bool mouseMoved; 00054 Person *inputControlledPerson; 00055 InputMode inputMode; 00056 int interactKey, cancelKey; 00057 00058 public: 00059 #ifndef SWIG 00060 InputManager(); 00061 ~InputManager(); 00062 #endif 00063 00066 void update(); 00067 00073 bool isRunning(); 00074 00078 void stop(); 00079 00083 bool keyDown( int code ) const; 00084 00094 bool keyTicked( int code ) const; 00095 00098 int getMouseX() const; 00099 00102 int getMouseY() const; 00103 00106 bool isMouseMoved() const; 00107 00111 bool buttonDown( int code ) const; 00112 00116 bool buttonTicked( int code ) const; 00117 00120 Point getMousePoint() const; 00121 00129 bool hover( int x1, int y1, int x2, int y2 ) const; 00130 00134 bool clicked( int x1, int y1, int x2, int y2 ) const; 00135 00140 void setInputControlledPerson( Person *person ); 00141 00144 Person *getInputControlledPerson() const; 00145 00148 void setInputMode( InputMode mode ); 00149 00152 InputMode getInputMode() const; 00153 00157 void setInteractKey( int code ); 00158 00161 int getInteractKey() const; 00162 00166 void setCancelKey( int code ); 00167 00170 int getCancelKey() const; 00171 00174 bool interactKeyTicked() const; 00175 00178 bool cancelKeyTicked() const; 00179 00182 void setMouseVisibility( bool value ) const; 00183 }; 00184 00185 InputManager *getInputManager(); 00186 00187 }; 00188 00189 #endif