localconnectivityservice/generichid/src/hidinterfaces.cpp
branchRCL_3
changeset 39 4096754ee773
parent 38 3dcb815346df
child 40 52a167391590
equal deleted inserted replaced
38:3dcb815346df 39:4096754ee773
     1 /*
       
     2 * Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Hid interface implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <hidinterfaces.h>
       
    20 
       
    21 // -----------------------------------------------------------------------------
       
    22 // Constructor
       
    23 // -----------------------------------------------------------------------------
       
    24 //    
       
    25 EXPORT_C CHidDriver::CHidDriver()
       
    26      {
       
    27      }
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // Desturctor
       
    31 // -----------------------------------------------------------------------------
       
    32 //     
       
    33 EXPORT_C CHidDriver::~CHidDriver()
       
    34     {    
       
    35     REComSession::DestroyedImplementation( iDtor_ID_Key );
       
    36     }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // NewL()
       
    40 // -----------------------------------------------------------------------------
       
    41 //  
       
    42 EXPORT_C CHidDriver* CHidDriver::NewL( 
       
    43     TUid aImplementationUid,
       
    44     MDriverAccess* aHid )
       
    45     {
       
    46     TAny* ptr;
       
    47     TInt32 keyOffset = _FOFF( CHidDriver, iDtor_ID_Key );   
       
    48     ptr = REComSession::CreateImplementationL(
       
    49         aImplementationUid,
       
    50         keyOffset,
       
    51         aHid
       
    52         );    
       
    53     return reinterpret_cast<CHidDriver*> (ptr);
       
    54     }    
       
    55     
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // NewL()
       
    59 // -----------------------------------------------------------------------------
       
    60 //      
       
    61 CHidInputDataHandlingReg* CHidInputDataHandlingReg::NewL()
       
    62     {
       
    63     CHidInputDataHandlingReg* self = new (ELeave) CHidInputDataHandlingReg();
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop( self );    
       
    67     return self;    
       
    68     
       
    69     }    
       
    70     
       
    71 // -----------------------------------------------------------------------------
       
    72 // Constructor
       
    73 // -----------------------------------------------------------------------------
       
    74 //      
       
    75 CHidInputDataHandlingReg::CHidInputDataHandlingReg()
       
    76     {        
       
    77     }        
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // Constructor
       
    81 // -----------------------------------------------------------------------------
       
    82 //      
       
    83 void CHidInputDataHandlingReg::ConstructL()
       
    84     {        
       
    85     iEventArray =  new ( ELeave ) CArrayFixFlat<THidEvent>( 2 );    
       
    86     }        
       
    87 // -----------------------------------------------------------------------------
       
    88 // Destructor
       
    89 // -----------------------------------------------------------------------------
       
    90 //      
       
    91 CHidInputDataHandlingReg::~CHidInputDataHandlingReg()
       
    92     { 
       
    93     Reset();           
       
    94     delete iEventArray;
       
    95     }       
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // AddHandledEvent
       
    99 // -----------------------------------------------------------------------------
       
   100 //    
       
   101 EXPORT_C void  CHidInputDataHandlingReg::AddHandledEvent( TInt aUsagePage, TInt aUsage )
       
   102     {
       
   103     THidEvent event;
       
   104     event.iUsagePage = aUsagePage;    
       
   105     event.iKeyCode = aUsage;
       
   106     TRAP_IGNORE(iEventArray->AppendL( event ));
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // AllowedToHandleEvent
       
   111 // -----------------------------------------------------------------------------
       
   112 //        
       
   113 EXPORT_C TBool  CHidInputDataHandlingReg::AllowedToHandleEvent(TInt aUsagePage, TInt aUsage)
       
   114     {
       
   115     TInt i;    
       
   116     for (i = 0; i< iEventArray->Count() ;i++)
       
   117         {
       
   118         if ( iEventArray->At(i).iUsagePage == aUsagePage && iEventArray->At(i).iKeyCode == aUsage )
       
   119             {
       
   120             return EFalse;    
       
   121             }
       
   122         }   
       
   123     return ETrue;     
       
   124     }    
       
   125    
       
   126 // -----------------------------------------------------------------------------
       
   127 // Reset
       
   128 // -----------------------------------------------------------------------------
       
   129 //      
       
   130 void  CHidInputDataHandlingReg::Reset()
       
   131     {
       
   132     iEventArray->Reset();    
       
   133     }
       
   134 
       
   135