localconnectivityservice/generichid/tsrc/GenericHidTest/inc/tgenerichidapi.h
branchRCL_3
changeset 19 0aa8cc770c8a
equal deleted inserted replaced
18:453dfc402455 19:0aa8cc770c8a
       
     1 /*
       
     2 * Copyright (c) 2004-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 generic api test class
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __TESTGEHERICHIDAPI_H
       
    19 #define __TESTGEHERICHIDAPI_H
       
    20 
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <hidinterfaces.h>
       
    24 #include <hidgeneric.h>
       
    25 #include "hidreportgenerator.h"
       
    26 #include "hidtranslate.h"
       
    27 
       
    28 #include "CHidDriverPlugin.h"
       
    29 #include "hiduids.h"
       
    30 
       
    31 
       
    32 /**
       
    33  *  HID generic api test class 
       
    34  *
       
    35  *  @lib 
       
    36  *  @since S60 v.3.2
       
    37  */
       
    38 NONSHARABLE_CLASS(CtGenericHIDAPI): public CBase, public MTransportLayer
       
    39     { 
       
    40     public:
       
    41         static CtGenericHIDAPI* NewL();
       
    42         static CtGenericHIDAPI* NewLC();
       
    43 
       
    44     /**
       
    45      * Destructor.
       
    46      */
       
    47     virtual ~CtGenericHIDAPI();
       
    48 
       
    49     public:  
       
    50 
       
    51     /**
       
    52      * Connect
       
    53      *
       
    54      * @since S60 v.3.2
       
    55      * @param aConnectionId connection id 
       
    56      * @param aDescriptor report descriptor
       
    57      * @return None
       
    58      */
       
    59     void ConnectL(TInt aConnectionId, const TDesC8& aDescriptor);
       
    60 
       
    61     /**
       
    62      * Disconnect
       
    63      *
       
    64      * @since S60 v.3.2
       
    65      * @param aConnectionId a connection id 
       
    66      * @return None
       
    67      */
       
    68     void DisconnectL(TInt aConnectionId);
       
    69   
       
    70     /**
       
    71      * DataIn
       
    72      *
       
    73      * @since S60 v.3.2
       
    74      * @param aConnectionId connection id 
       
    75      * @param aDescriptor report descriptor
       
    76      * @return error code
       
    77      */
       
    78     TInt DataInL(TInt aConnectionId, const TDesC8& aDescriptor);
       
    79     
       
    80     TInt RunCountryCodeL();
       
    81         
       
    82     TInt RunVendorIdL();
       
    83         
       
    84     TInt RunProductIdL( );
       
    85         
       
    86     TInt RunSetProtocolL();
       
    87         
       
    88     TInt RunGetProtocoL( );
       
    89         
       
    90     TInt RunGetReportL( );
       
    91         
       
    92     TInt RunSetReportL(const TDesC8& aDescriptor );
       
    93                 
       
    94     TInt RunDataOutL( const TDesC8& aDescriptor );
       
    95         
       
    96     TInt GetGetIdleL( );
       
    97         
       
    98     TInt RunSetIdleL( );
       
    99         
       
   100     TInt GetCommandResultL( );
       
   101         
       
   102     TInt GetReportDescriptorL();
       
   103     
       
   104     TInt CreateReportGeneratorL();
       
   105     
       
   106     TInt DeleteReportGeneratorL();
       
   107     
       
   108     TInt ReportGeneratorReport();
       
   109     
       
   110     TInt ReportGeneratorSetFieldL(  TBool aIsArray, TBool aOutOfRange, TBool aFieldNull, TBool aFieldCountZero, TBool aExistingUsageId, TBool aBadIndex  );
       
   111     
       
   112     TInt CreateReportTranslatorL( const TDesC8& aDescriptor, TBool aIsArray, TBool aFieldNull, TBool aFieldCountZero);
       
   113     
       
   114     //TInt CreateReportTranslator_FieldNullL( const TDesC8& aDescriptor  );
       
   115             
       
   116     TInt DeleteReportTranslatorL( );
       
   117     
       
   118     TInt ReportTranslatorGetValueL( );
       
   119             
       
   120     TInt ReportTranslatorValueL(  );
       
   121             
       
   122     TInt ReportTranslatorGetUsageIdL( TBool aBadControlIndex );
       
   123             
       
   124     TInt ReportTranslatorUsageIdL( );
       
   125             
       
   126     TInt ReportTranslatorRawValueL( );
       
   127             
       
   128     TInt ReportTranslatorCountL( );
       
   129     
       
   130    TInt CollectiontypeL( );
       
   131    TInt CollectionIsPhysicalL( );
       
   132    TInt CollectionIsLogicalL( );
       
   133    TInt CollectionIsReportL( );
       
   134    TInt CollectionIsNamedArrayL( );
       
   135    TInt CollectionIsUsageSwitchL( );
       
   136    TInt CollectionIsUsageModifierL( );
       
   137    
       
   138    TInt CollectionIsApplicationL( );
       
   139    TInt CollectionUsagePageL( );
       
   140    TInt CollectionUsageL( );
       
   141    TInt CollectionCollectionCountL( );
       
   142    TInt CollectionFieldCountL( );
       
   143    TInt CollectionCollectionByIndexL( TBool aPresent );
       
   144    TInt CollectionFieldByIndexL( );
       
   145    
       
   146    TInt ReportrootReportSizeBytes( );
       
   147    
       
   148 
       
   149    TInt FieldLogicalMaxL( );
       
   150    TInt FieldPhysicalMinL( );
       
   151    TInt FieldPhysicalMaxL( );
       
   152    TInt FieldUnitL( );
       
   153    TInt FieldUnitExponentL( );
       
   154    TInt FieldCountL( );
       
   155    TInt FieldSizeL( );
       
   156    TInt FieldOffsetL( TBool setReport );
       
   157    TInt FieldReportIdL( );
       
   158    TInt FieldIsInReportL( );
       
   159    TInt FieldUsagePageL( );
       
   160    TInt FieldDesignatorIndexL( );
       
   161    TInt FieldStringIndexL( );
       
   162    TInt FieldHasUsageL( );
       
   163    TInt FieldUsageArrayL( );
       
   164    TInt FieldUsageL( );
       
   165    TInt FieldUsageCountL( );
       
   166    TInt FieldClearUsageListL( );
       
   167    TInt FieldLastUsageL( TBool empty );
       
   168    TInt FieldAttributesL( );
       
   169    TInt FieldTypeL( );
       
   170    TInt FieldIsArrayL(  );
       
   171    TInt FieldIsVariableL( );
       
   172    TInt FieldIsConstantL(  );
       
   173    TInt FieldIsDataL(  );
       
   174    TInt FieldSetLogicalMinL();
       
   175    TInt FieldSetLogicalMaxL( );
       
   176    TInt FieldSetPhysicalMinL( );
       
   177    TInt FieldSetPhysicalMaxL( );
       
   178    TInt FieldSetDesignatorMinL( );
       
   179    TInt FieldSetDesignatorMaxL(  );
       
   180    TInt FieldSetUsageMinL( );
       
   181    TInt FieldSetUsageMaxL( );
       
   182    TInt FieldSetStringMinL( );
       
   183    TInt FieldSetStringMaxL( );
       
   184    TInt FieldSetLogicalRangeL( );
       
   185    TInt FieldSetUsageRangeL( );
       
   186    TInt FieldSetPhysicalRangeL( );
       
   187    TInt FieldSetStringRangeL( );
       
   188    TInt FieldSetDesignatorRangeL( );
       
   189    TInt FieldIsInputL( );
       
   190    TInt FieldIsOutputL( );
       
   191    TInt FieldIsFeatureL( );
       
   192 
       
   193     
       
   194   
       
   195 private: //from MTransportLayer
       
   196 
       
   197     /**
       
   198      * Request for the country code of the given device.
       
   199      *
       
   200      * @since S60 v3.2
       
   201      * @param aConnID The device identifier
       
   202      * @return country code.
       
   203      */
       
   204     TUint CountryCodeL(TInt aConnID);
       
   205 
       
   206     /**
       
   207      * Request for the vendor identifier for the given device.
       
   208      *
       
   209      * @since S60 v3.2
       
   210      * @param aConnID The device identifier
       
   211      * @return vendor id.
       
   212      */
       
   213     TUint VendorIdL(TInt aConnID);
       
   214 
       
   215     /**
       
   216      * Request for the product identifier for the given device.
       
   217      *
       
   218      * @since S60 v3.2
       
   219      * @param aConnID The device identifier
       
   220      * @return product id.
       
   221      */
       
   222     TUint ProductIdL(TInt aConnID);
       
   223 
       
   224     /**
       
   225      * Request for the current device report protocol. The protocol will be
       
   226      * received as a control report via the CHidTransport::DataIn function
       
   227      *
       
   228      * @since S60 v3.2
       
   229      * @param aConnID The device identifier
       
   230      * @param aInterface The interface we want to get the protocol from
       
   231      * @return None.
       
   232      */
       
   233     void GetProtocolL(TInt aConnID,  TUint16 aInterface);
       
   234 
       
   235     /**
       
   236      * Request to put the device in the specified protocol
       
   237      *
       
   238      * @since S60 v3.2
       
   239      * @param aConnID The device identifier
       
   240      * @param aValue The requested protocol for the device (boot or report)
       
   241      * @param aInterface The interface we want to set the protocol for
       
   242      * @return None.
       
   243      */
       
   244     void SetProtocolL(TInt aConnID, TUint16 aValue,
       
   245             TUint16 aInterface);
       
   246 
       
   247     /**
       
   248      * Request for a device report. The data will be received as a control report
       
   249      * via the CHidTransport::DataIn function
       
   250      *
       
   251      * @since S60 v3.2
       
   252      * @param aConnID The device identifier
       
   253      * @param aReportType The type of report (input/output/feature) requested
       
   254      * @param aReportID The specific report required
       
   255      * @param aInterface The interface we want the report from
       
   256      * @param aLength The expected length of the report buffer
       
   257      * @return None.
       
   258      */
       
   259     void GetReportL(TInt aConnID, TUint8 aReportType,TUint8 aReportID,
       
   260             TUint16 aInterface, TUint16 aLength);
       
   261 
       
   262     /**
       
   263      * Request to send a report to a device. The response will be reported via the
       
   264      * CHidTransport::CommandResult function
       
   265      *
       
   266      * @since S60 v3.2
       
   267      * @param aConnID The device identifier
       
   268      * @param aReportType The type of report (input/output/feature) requested
       
   269      * @param aReportID The specific report required to set
       
   270      * @param aInterface The interface we want to send the report to
       
   271      * @param aReport The report payload to be sent to the device
       
   272      * @return None.
       
   273      */
       
   274     void SetReportL(TInt aConnID, TUint8 aReportType,TUint8 aReportID,
       
   275         TUint16 aInterface, const TDesC8& aReport);
       
   276 
       
   277     /**
       
   278      * Request to send data to a device. There are no responses to this report from device.
       
   279      *
       
   280      * @since S60 v3.2
       
   281      * @param aConnID The device identifier
       
   282      * @param @param aReportID The specific report required
       
   283      * @param aInterface The interface we want to send the report to
       
   284      * @param aReport The report payload to be sent to the device   
       
   285      * @return None.
       
   286      */
       
   287     void DataOutL(TInt aConnID, TUint8 aReportID,
       
   288             TUint16 aInterface, const TDesC8& aReport);
       
   289 
       
   290     /**
       
   291      * Request for the current idle rate of a report from the device. The response
       
   292      * will be recevied via the CHidTransport::DataIn function
       
   293      *
       
   294      * @since S60 v3.2
       
   295      * @param aConnID The device identifier
       
   296      * @param aReportID The specific report to be queried
       
   297      * @param aInterface The interface we want to query for idle rate
       
   298      * @return None.
       
   299      */
       
   300     void GetIdleL(TInt aConnID, TUint8 aReportID,
       
   301             TUint16 aInterface);
       
   302 
       
   303     /**
       
   304      * Request to set the current idle rate for a report on the device.
       
   305      * The response will be received via the CHidTransport::CommandResult function
       
   306      *
       
   307      * @since S60 v3.2
       
   308      * @param aConnID The device identifier
       
   309      * @param aReportID The specific report to be queried
       
   310      * @param aDuration The time period between idle reports (4ms per bit. An
       
   311      *        interval of 0 disables idle reports so that Interrupt reports are only ever
       
   312      *        received when the reported data has changed
       
   313      * @param aReportID The specific report to be queried
       
   314      * @param aInterface The interface we want to query for idle rate
       
   315      * @return None.
       
   316      */
       
   317     void SetIdleL(TInt aConnID,  TUint8 aDuration, TUint8 aReportID,
       
   318             TUint16 aInterface);
       
   319   
       
   320 
       
   321 private:
       
   322     CtGenericHIDAPI();    
       
   323     void ConstructL();    
       
   324     
       
   325     const CField* CreateConstCFieldL();
       
   326     CField* CreateCFieldL();
       
   327     
       
   328 private:
       
   329     CGenericHid*        iGenHID;   
       
   330     MDriverAccess*      iDriverAcces;
       
   331     CReportGenerator*   iReportGenerator;
       
   332     TReportTranslator*  iTranslator;
       
   333     
       
   334     CHidDriver* iHidDriver;
       
   335     
       
   336     RPointerArray<CField> iFieldList;
       
   337   };
       
   338 #endif
       
   339  
       
   340