00001 /*************************************************************************** 00002 input.h - mouse, keyboard, joystick, timer etc. input methods 00003 ------------------- 00004 begin : Tue Jul 24 2001 00005 copyright : (C) 2001 by T Kontkanen 00006 email : tkontkanen@mail.com 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef INPUT_H 00019 #define INPUT_H 00020 00021 #include "allincludes.h" 00022 #include "gamedefs.h" 00023 #include "renderer.h" 00024 00029 class Input { 00030 public: 00031 Input(); 00032 ~Input(); 00034 void setRenderer( Renderer *prenderer ); 00035 int pollEvents(); 00036 int mouseX(); 00037 int mouseY(); 00039 Vector mousePos(); 00040 int relativeMouseX(); 00041 int relativeMouseY(); 00043 int timerTicks(); 00045 int diffTime(); 00047 int frameDelay(); 00048 bool mouseButton( int button ); 00049 bool mouseClicked( int button ); 00050 bool mouseReleased( int button ); 00051 bool key( int keycode ); 00053 SDLMod keyModifiers() { return modifiers; } 00055 bool keyClicked( int keycode ); 00056 void setInputGrapping( bool onoff ); 00057 void showMouseCursor( bool onoff ); 00058 bool isMouseVisible( void ) { return mouse_visible; } 00059 void renderMouseCursor( void ); 00060 private: 00061 bool mouse_visible, mouse_sys_cursor; 00062 void handleEvent ( SDL_Event *event ); 00063 SDL_Event event; 00064 bool keys[512], key_clicks[512]; 00065 SDLMod modifiers; 00066 int mouse_x, mouse_y, rel_mouse_x, rel_mouse_y; 00067 int time_now, time_prev; 00068 bool mouse_buttons[3], mouse_clicked[3], mouse_released[3]; //buttons state, buttons clicked before poll 00069 Renderer *renderer; 00070 }; 00071 00072 #endif