Nokia N97 SDK
Example Applications Guide

Billboardinput.h

00001 /*
00002  * ==============================================================================
00003  *  Name        : Billboardinput.h
00004  *  Part of     : OpenGLEx / Billboard
00005  *
00006  *  Copyright (c) 2005-2006 Nokia Corporation.
00007  *  This material, including documentation and any related
00008  *  computer programs, is protected by copyright controlled by
00009  *  Nokia Corporation.
00010  * ==============================================================================
00011  */
00012 
00013 #ifndef __BILLBOARDINPUTH__
00014 #define __BILLBOARDINPUTH__
00015 
00016 //  INCLUDES
00017 
00018 #include <e32base.h> // for CBase definition
00019 #include <GLES\gl.h> // OpenGL ES header file
00020 #include <aknappui.h>
00021 
00022 // MACROS
00023 
00024 // Number of inputs (used to create the lookup table)
00025 #define MAX_NUM_INPUTS   5
00026 
00027 /**
00028  * Defined joystick values that can be queried from this class.
00029  */
00030 enum
00031 {
00032 EJoystickUp,
00033 EJoystickDown,
00034 EJoystickLeft,
00035 EJoystickRight,
00036 EJoystickFire
00037 };
00038 
00039 /** Size of the keycode map. */
00040 static const TUint KKeyCodeMapSize = 10 * 2;
00041 
00042 /**
00043  * The keycode map defines which scancode is mapped to which input signal.
00044  */
00045 static const TUint KKeyCodeMap[] =
00046 {
00047     EStdKeyUpArrow,    EJoystickUp,
00048     EStdKeyDownArrow,  EJoystickDown,
00049     EStdKeyLeftArrow,  EJoystickLeft,
00050     EStdKeyRightArrow, EJoystickRight,
00051     EStdKeyDevice3,    EJoystickFire
00052 };
00053 
00054 
00055 // FORWARD DECLARATIONS
00056 
00057 /**
00058  * Class that handles the mapping of scancodes to input signals that can then
00059  * be queried from the application. When the program is initialized
00060  * this class reference is given by the CBillboardContainer to CBillboard. CBillboardContainer
00061  * class then notifies this class of key presses and releases. If an input signal
00062  * mapping exists for a scancode the state of that input signal's state is modified.
00063  * The CBillboard class can then query the state of the various input signal's from this class.
00064  *
00065  * Note that this class supports mapping of multiple scancodes to a single input signal.
00066  * But only one input signal can be mapped to one scancode (that means single keypress can't
00067  * change multiple input signals to pressed state).
00068  *
00069  */
00070  class CBillboardInput
00071     {
00072     public: // Constructors and destructor
00073 
00074         /**
00075          * Factory method for creating a new CBillboard object.
00076          * Calls the hidden constructors.
00077          */
00078         static CBillboardInput* NewL();
00079 
00080         /**
00081          * Destructor. Does nothing.
00082          */
00083         virtual ~CBillboardInput();
00084 
00085     protected: // Hidden constructors
00086 
00087         /**
00088          * Standard constructor that must never Leave.
00089          */
00090         CBillboardInput();
00091 
00092         /**
00093          * Second phase constructor that can call methods that may leave. Does nothing.
00094          */
00095         void ConstructL( void );
00096 
00097 
00098     public: // New methods
00099 
00100         /**
00101          * If a signal mapping exists for the given keycode, then that
00102          * input signal is set to pressed state.
00103          * @param aKeyCode One of the values defined in TStdScanCode.
00104          */
00105         TKeyResponse KeyDown( const int aKeyCode );
00106 
00107         /**
00108          * If a signal mapping exists for the given keycode, then that
00109          * input signal is set to non-pressed state.
00110          * @param aKeyCode One of the values defined in TStdScanCode.
00111          */
00112         TKeyResponse KeyUp( const int aKeyCode );
00113 
00114         /**
00115          * Returns whether or not a given input signal is pressed at the moment or not.
00116          * @param aInput One of the defined input signal values.
00117          * @return ETrue if the given input is pressed or EFalse if it is not pressed.
00118          */
00119         TBool IsInputPressed( TUint aInput );
00120 
00121     private: // Data
00122 
00123         /** Pressed status for each input. */
00124                 TBool* iInputPressed;
00125     };
00126 
00127 #endif
00128 
00129 // End of File

© Nokia 2009

Back to top