Nokia N97 SDK
Example Applications Guide

Billboardinput.cpp

00001 /*
00002  * ==============================================================================
00003  *  Name        : Billboardinput.cpp
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 // INCLUDE FILES
00014 #include <aknnotewrappers.h>
00015 #include "billboardinput.h"
00016 
00017 // MACROS
00018 #define FRUSTUM_LEFT   -1.f     //left vertical clipping plane
00019 #define FRUSTUM_RIGHT  +1.f     //right vertical clipping plane
00020 #define FRUSTUM_BOTTOM -1.f     //bottom horizontal clipping plane
00021 #define FRUSTUM_TOP    +1.f     //top horizontal clipping plane
00022 #define FRUSTUM_NEAR   +3.f     //near depth clipping plane
00023 #define FRUSTUM_FAR    +1000.f  //far depth clipping plane
00024 
00025 // CONSTANTS
00026 
00027 // ============================= MEMBER FUNCTIONS ==============================
00028 // ============================= LOCAL FUNCTIONS ===============================
00029 // ============================= MEMBER FUNCTIONS ===============================
00030 
00031 // -----------------------------------------------------------------------------
00032 // CBillboardInput::NewL
00033 // Symbian 2-phase constructor. Can leave.
00034 // -----------------------------------------------------------------------------
00035 //
00036 CBillboardInput* CBillboardInput::NewL()
00037     {
00038     // Symbian 2-phase constructor. Calls both the default
00039     // C++ constructor and Symbian ConstructL methods
00040     CBillboardInput* self = new (ELeave) CBillboardInput();
00041     CleanupStack::PushL( self );
00042     self->ConstructL();
00043     CleanupStack::Pop();
00044 
00045     return self;
00046     }
00047 
00048 // ----------------------------------------------------------------------------
00049 // CBillboardInput::CBillboardInput
00050 // C++ default constructor can NOT contain any code, that
00051 // might leave.
00052 // ----------------------------------------------------------------------------
00053 //
00054 CBillboardInput::CBillboardInput()
00055     {
00056     }
00057 
00058 // ----------------------------------------------------------------------------
00059 // CBillboardInput::ConstructL
00060 // Symbian 2nd phase constructor can leave.
00061 // ----------------------------------------------------------------------------
00062 //
00063 void CBillboardInput::ConstructL( void )
00064     {
00065     iInputPressed = new (ELeave) TBool[ MAX_NUM_INPUTS ];
00066     for( int i = 0; i < MAX_NUM_INPUTS; i++ )
00067         {
00068         iInputPressed[i] = EFalse;
00069         }
00070     }
00071 
00072 // ----------------------------------------------------------------------------
00073 // CBillboardInput::~CBillboardInput()
00074 // Destructor.
00075 // ----------------------------------------------------------------------------
00076 //
00077 CBillboardInput::~CBillboardInput()
00078     {
00079     delete iInputPressed;
00080     }
00081 
00082 // ----------------------------------------------------------------------------
00083 // CBillboardInput::KeyDown( const int aKeyCode )
00084 // Sets the given keycode to pressed state.
00085 // ----------------------------------------------------------------------------
00086 //
00087 TKeyResponse CBillboardInput::KeyDown( const int aKeyCode )
00088 {
00089     TInt inputIdx = -1;
00090     for( int i = 0; i < KKeyCodeMapSize; i +=2 )
00091         {
00092         if( KKeyCodeMap[i] == aKeyCode )
00093             {
00094             inputIdx = KKeyCodeMap[i + 1];
00095             break;
00096             }
00097         }
00098 
00099     if( inputIdx >= 0 )
00100     {
00101         iInputPressed[ inputIdx ] = ETrue;
00102                 return EKeyWasConsumed;
00103     }
00104 
00105     return EKeyWasNotConsumed;
00106 }
00107 
00108 // ----------------------------------------------------------------------------
00109 // CBillboardInput::KeyUp( const int aKeyCode )
00110 // Sets the given keycode to non-pressed state.
00111 // ----------------------------------------------------------------------------
00112 //
00113 TKeyResponse CBillboardInput::KeyUp( const int aKeyCode )
00114 {
00115     TInt inputIdx = -1;
00116     for( int i = 0; i < KKeyCodeMapSize; i +=2 )
00117         {
00118         if( KKeyCodeMap[i] == aKeyCode )
00119             {
00120             inputIdx = KKeyCodeMap[i + 1];
00121             break;
00122             }
00123         }
00124 
00125     if( inputIdx >= 0 )
00126     {
00127         iInputPressed[ inputIdx ] = EFalse;
00128                 return EKeyWasConsumed;
00129     }
00130 
00131     return EKeyWasNotConsumed;
00132 }
00133 
00134 // ----------------------------------------------------------------------------
00135 // CBillboardInput::IsInputPressed( Input aInput )
00136 // Returns whether or not a given input is pressed at the moment or not.
00137 // ----------------------------------------------------------------------------
00138 //
00139 TBool CBillboardInput::IsInputPressed( TUint aInput )
00140 {
00141     return iInputPressed[ aInput ];
00142 }
00143 
00144 
00145 // End of File

© Nokia 2009

Back to top