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

keys.h

00001 // $Id: keys.h,v 1.1.1.1 2003/06/24 15:33:12 sjcomp Exp $
00002 // Copyright (c) 2003, Alexander Shyrokov aka SJ
00003 // E-mail: sjcomp[@]users.sourceforge.com
00004 // Web:    http://sjgui.sourceforge.net
00005 //
00006 // This code is under BSD license agreement.
00007 //
00008 // Alexander Shyrokov makes no representations about the suitability of this software 
00009 // for any purpose. It is provided "AS IS" without express or implied warranty.
00010 
00011 #if !defined(SJKEYS_H_INCLUDED)
00012 #define SJKEYS_H_INCLUDED
00013 
00014 #define SJ_KEY_BACKSPACE    8
00015 #define SJ_KEY_TAB          9
00016 #define SJ_KEY_ENTER        13
00017 #define SJ_KEY_ESC          27
00018 #define SJ_KEY_SPACE        32
00019 #define SJ_KEY_DELETE       127
00020 
00021 #define SJ_KEY_MENU         260
00022 #define SJ_KEY_PAUSE        261
00023 #define SJ_KEY_CAPSLOCK     261
00024 #define SJ_KEY_F1           301
00025 #define SJ_KEY_F2           302
00026 #define SJ_KEY_F3           303
00027 #define SJ_KEY_F4           304
00028 #define SJ_KEY_F5           305
00029 #define SJ_KEY_F6           306
00030 #define SJ_KEY_F7           307
00031 #define SJ_KEY_F8           308
00032 #define SJ_KEY_F9           309
00033 #define SJ_KEY_F10          310
00034 #define SJ_KEY_F11          311
00035 #define SJ_KEY_F12          312
00036 #define SJ_KEY_F13          313
00037 #define SJ_KEY_F14          314
00038 #define SJ_KEY_F15          315
00039 #define SJ_KEY_F16          316
00040 #define SJ_KEY_F17          317
00041 #define SJ_KEY_F18          318
00042 #define SJ_KEY_F19          319
00043 #define SJ_KEY_F20          320
00044 #define SJ_KEY_F21          321
00045 #define SJ_KEY_F22          322
00046 #define SJ_KEY_F23          323
00047 #define SJ_KEY_F24          324
00048 
00049 // directional keys 
00050 #define SJ_KEY_LEFT         350
00051 #define SJ_KEY_UP           351
00052 #define SJ_KEY_RIGHT        352
00053 #define SJ_KEY_DOWN         353
00054 #define SJ_KEY_PAGE_UP      354
00055 #define SJ_KEY_PAGE_DOWN    355
00056 #define SJ_KEY_HOME         356
00057 #define SJ_KEY_END          357
00058 #define SJ_KEY_INSERT       358
00059 #define SJ_KEY_DEL          359
00060 #define SJ_KEY_NUMPAD0      360
00061 #define SJ_KEY_NUMPAD1      361
00062 #define SJ_KEY_NUMPAD2      362
00063 #define SJ_KEY_NUMPAD3      363
00064 #define SJ_KEY_NUMPAD4      364
00065 #define SJ_KEY_NUMPAD5      365
00066 #define SJ_KEY_NUMPAD6      366
00067 #define SJ_KEY_NUMPAD7      367
00068 #define SJ_KEY_NUMPAD8      368
00069 #define SJ_KEY_NUMPAD9      369
00070 
00071 #define SJ_KEY_DIVIDE       370
00072 #define SJ_KEY_MULTIPLY     371
00073 #define SJ_KEY_MINUS        372
00074 #define SJ_KEY_ADD          373
00075 #define SJ_KEY_DECIMAL      374
00076 #define SJ_KEY_NUMLOCK      375
00077 #define SJ_KEY_SCROLL       376
00078 // Modifiers
00079 #define SJ_KEY_SHIFT        380
00080 #define SJ_KEY_ALT          381
00081 #define SJ_KEY_CTRL         382
00082 // Mouse keys and actions
00083 #define SJ_KEY_MOUSE_LEFT   385
00084 #define SJ_KEY_MOUSE_RIGHT  386
00085 #define SJ_KEY_MOUSE_MIDDLE 387
00086 
00087 #define SJ_KEY_IGNORE       390
00088 #define SJ_KEY_NULL         399
00089 #define SJ_KEY_MAXIMUM      400
00090 
00091 namespace sjgui{
00092 
00093 // Everything is static so one can use CKeys::SetKey() for example
00147 class CKeys
00148 {
00149     static bool*        m_pyKeys;
00150     static int          m_iTotalPressed;
00151     static int          m_iLastKey;
00152 public:
00153     static void SetKey(int ind,bool val=true); 
00154     static void PressKey(int ind) 
00155         {SetKey(ind,true);};
00156     static void ReleaseKey(int ind) 
00157         {SetKey(ind,false);};
00161     static bool IsKey(int ind){if(ind<SJ_KEY_MAXIMUM)return m_pyKeys[ind];else return false;};
00163     static int GetTotalPressed(){return m_iTotalPressed;};
00165     static int GetLastKey(){return m_iLastKey;};
00167     static bool IsShift(){return m_pyKeys[SJ_KEY_SHIFT];};
00169     static bool IsAlt(){return m_pyKeys[SJ_KEY_ALT];};
00171     static bool IsCtrl(){return m_pyKeys[SJ_KEY_CTRL];};
00172 };
00173 
00174 inline void CKeys::SetKey(int ind,bool val/*=true*/)
00175 {
00176     if(ind<SJ_KEY_MAXIMUM)
00177     {
00178         m_pyKeys[ind]=val;
00179         if(val)m_iTotalPressed++;
00180         else m_iTotalPressed--;
00181         m_iLastKey=ind;
00182     }
00183 }
00184 
00185 } // namespace sjgui
00186 
00187 #endif // !defined(SJKEYS_H_INCLUDED)
sjgui logo
Quick Links:

 News
 Description
 Screen Shots
 Projects
 Downloads
 Source Code
 Help/FAQ
 Want to help?
 Credits
 Disclaimer


Documentation:

 Documentation
 Reference
 Lessons


Useful links:

sjcomp logo
sjcomp

opengl logo

nehe logo

SourceForge.net Logo

Last modified:


Started by Alexander Shyrokov. Generated at Wed Apr 28 12:31:04 2004 for the sjgui by doxygen 1.3.1. SourceForge.net Logo