Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

keyboard_tty.h

Go to the documentation of this file.
00001 /*
00002         $Id: keyboard_tty.h,v 1.1 2001/03/06 15:09:21 mbn Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 */
00014 
00015 #ifndef header_keyboard_tty
00016 #define header_keyboard_tty
00017 
00018 #ifndef USE_TTY_INPUT
00019 #ifdef USE_SVGALIB
00020 #define USE_TTY_INPUT
00021 #else
00022 #ifdef USE_FBDEV
00023 #define USE_TTY_INPUT
00024 #endif
00025 #endif
00026 #endif
00027 
00028 #ifdef USE_TTY_INPUT
00029 
00030 #include "API/Display/Input/inputbutton.h"
00031 #include "API/Display/Input/keyboard.h"
00032 #include "Core/System/Unix/init_linux.h"
00033 #include "API/Core/System/keep_alive.h"
00034 #include <termios.h>
00035 
00036 class CL_InputButton_TTYKeyboard : public CL_InputButton
00037 {
00038 public:
00039         CL_InputButton_TTYKeyboard(int key, char *keymap);
00040         virtual bool is_pressed();
00041 
00042 private:
00043         int key;
00044         char *keymap;
00045 };
00046 
00047 class CL_TTYKeyboard : public CL_Keyboard, CL_KeepAlive
00048 {
00049 public:
00050         CL_TTYKeyboard();
00051         virtual ~CL_TTYKeyboard();
00052 
00053         virtual char *get_name() const;
00054 
00055         virtual int get_num_buttons() const;
00056         virtual CL_InputButton *get_button(int button_num);
00057 
00058         virtual int get_num_axes() const;
00059         virtual CL_InputAxis *get_axis(int axis_num);
00060 
00061         virtual int get_num_hats() const;
00062         virtual CL_InputHat *get_hat(int hat_num);
00063 
00064         virtual int get_num_cursors() const;
00065         virtual CL_InputCursor *get_cursor(int cursor_num);
00066 
00067         virtual void keep_alive();
00068 
00069 private:
00070         void restore();
00071 
00072         char keymap[128];
00073         
00074         int fd;
00075         int old_mode;
00076         int old_kd;
00077         struct termios old_termios;
00078         void handle_code(char code);
00079         char translate(int kb_value);
00080         
00081         CL_InputButton_TTYKeyboard **buttons;
00082 };
00083 
00084 #endif
00085 
00086 #endif

Generated at Wed Apr 4 19:54:01 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001