• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

input.h

Go to the documentation of this file.
00001 /*
00002    $Id: input.h,v 1.11 2001/07/19 08:41:27 gnurou Exp $
00003 
00004    Copyright (C) 1999/2000/2001  Alexandre Courbot.
00005    Part of the Adonthell Project http://adonthell.linuxgames.com
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 
00015 
00016 /**
00017  * @file   input.h
00018  * @author Alexandre Courbot <alexandrecourbot@linuxgames.com>
00019  * 
00020  * @brief  Declares the input class.
00021  * 
00022  * 
00023  */
00024 
00025 
00026 
00027 #ifndef INPUT_H__
00028 #define INPUT_H__
00029 
00030 #include "types.h"
00031 #include "SDL_keysym.h"
00032 
00033 
00034 /**
00035  * Handles keyboard and mouse input.
00036  *
00037  * @todo Rewrite it!
00038  * 
00039  */ 
00040 class input
00041 {
00042 public:
00043 
00044     /** 
00045      * Initialise the input system.
00046      * 
00047      */
00048     static void init();
00049 
00050     /** 
00051      * Free resources occupied by the input system.
00052      * 
00053      */
00054     static void shutdown();
00055 
00056     /** 
00057      * Update the input state.
00058      * 
00059      */
00060     static void update();
00061 
00062     /** 
00063      * Returns whether a key is currently pushed or not.
00064      * 
00065      * @param key key to test.
00066      * 
00067      * @return true if key is currently pushed, false otherwise.
00068      */
00069     static bool is_pushed(SDLKey key);
00070 
00071     /** 
00072      * Returns whether a key has been pushed since last function call, false otherwise.
00073      * 
00074      * @param key key to test.
00075      * 
00076      * @return true if the key has been pushed since last call, false otherwise.
00077      */
00078     static bool has_been_pushed(SDLKey key);
00079     
00080     
00081     /** 
00082      * Returns the code of the next key on the input queue.
00083      * 
00084      * 
00085      * @return Code of the next key that has been pushed.
00086      */
00087     static s_int32 get_next_key();
00088      
00089     /** 
00090      * Returns the next unicode on the input queue.
00091      * 
00092      * 
00093      * @return Unicode of the next key that has been pushed.
00094      */
00095     static s_int32 get_next_unicode();
00096     
00097     /** 
00098      * Sets whether the key repeat is active or not.
00099      * 
00100      * @param delay delay (in ms) before repetition.
00101      * @param interval interval (in ms) between repetitions.
00102      */
00103     static void set_key_repeat(int delay=SDL_DEFAULT_REPEAT_DELAY, int interval=SDL_DEFAULT_REPEAT_INTERVAL);
00104 
00105     /** 
00106      * Totally clears the key queue.
00107      * 
00108      */
00109     static void clear_keys_queue();
00110     
00111 
00112 private:
00113     static u_int16 last_key;
00114 
00115     static int filterevents(const SDL_Event *event);
00116     
00117     static u_int16 mouse_posx, mouse_posy;
00118     static u_int8 * keystate;
00119     static u_int8 * p_keystate;
00120     static s_int32 keystatelength;
00121 #ifndef SWIG
00122     static bool mouse_button[3];
00123 #endif
00124     
00125 };
00126 
00127 #endif

Generated on Mon Sep 12 2011 for Adonthell by  doxygen 1.7.1