bluetoothengine/bthid/manager/src/client.cpp
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2008 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:  This is the implementation of application class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32math.h>
       
    20 
       
    21 #include "layoutmgr.h"
       
    22 #include "client.h"
       
    23 #include "debug.h"
       
    24 #include "hiduids.h"
       
    25 
       
    26 // ----------------------------------------------------------------------
       
    27 
       
    28 EXPORT_C RLayoutManager::RLayoutManager()
       
    29     {
       
    30     // Nothing else to do
       
    31     }
       
    32 
       
    33 EXPORT_C TInt RLayoutManager::Connect()
       
    34     {
       
    35     const TVersion KMinServerVersion(1, 0, 0);
       
    36     _LIT(KLayoutServerFilename, "LayoutMgr");
       
    37     const TUid KServerUid3 =
       
    38         {
       
    39             LAYOUTMGR_UID
       
    40         }
       
    41         ;	//This was KServerUid2 before
       
    42     const TUidType serverUid(KNullUid, KNullUid, KServerUid3);
       
    43     const TUint KDefaultMessageSlots = 3;
       
    44 
       
    45     return StartSession(KLayoutServerName, KMinServerVersion,
       
    46                         KLayoutServerFilename, serverUid, KDefaultMessageSlots);
       
    47     }
       
    48 
       
    49 // ----------------------------------------------------------------------
       
    50 
       
    51 EXPORT_C TInt RLayoutManager::KeyEvent(TBool aIsKeyDown,
       
    52                                        TInt aHidKey, TInt aUsagePage, TInt aModifiers,
       
    53                                        const TLockKeys& aLockKeys, TDecodedKeyInfo& aDecodedKeys) const
       
    54     {
       
    55     //#ifdef DBG_ACTIVE
       
    56     TRACE_INFO( (aIsKeyDown ?
       
    57                  _L("RLayoutManager::KeyEvent(down, 0x%x:0x%x, 0x%x, %d, %d]\r\n")
       
    58                  : _L("RLayoutManager::KeyEvent(up, 0x%x:0x%x, 0x%x, %d, %d]\r\n"),
       
    59                  aIsKeyDown, aUsagePage, aHidKey, aModifiers,
       
    60                  aLockKeys.iCapsLock, aLockKeys.iNumLock));
       
    61     //#endif
       
    62 
       
    63     TPckgBuf<TKeyEventInfo> infoPkg;
       
    64     TKeyEventInfo& info = infoPkg();
       
    65     info.iIsKeyDown = aIsKeyDown;
       
    66     info.iHidKey = aHidKey;
       
    67     info.iUsagePage = aUsagePage;
       
    68     info.iModifiers = THidModifier(static_cast<TUint8>(aModifiers));
       
    69     info.iLockKeys = aLockKeys;
       
    70 
       
    71     TPckgBuf<TDecodedKeyInfo> keyPkg;
       
    72 
       
    73     TInt result = SendReceive(EKeyEvent, TIpcArgs(&infoPkg, &keyPkg));
       
    74 
       
    75     aDecodedKeys.iCount = 0;
       
    76     if (result == KErrNone)
       
    77         {
       
    78         aDecodedKeys = keyPkg();
       
    79         }
       
    80 
       
    81     return result;
       
    82     }
       
    83 
       
    84 EXPORT_C TInt RLayoutManager::Reset() const
       
    85     {
       
    86     TRACE_INFO( (_L("RLayoutManager::Reset()")));
       
    87     return SendReceive(EResetDecoder);
       
    88     }
       
    89 
       
    90 // ----------------------------------------------------------------------
       
    91 
       
    92 EXPORT_C TInt RLayoutManager::SetInitialLayout(TInt aCountry,
       
    93         TInt aVendor, TInt aProduct) const
       
    94     {
       
    95     return SendReceive(ESetInitialLayout, TIpcArgs(aCountry, aVendor, aProduct));
       
    96     }
       
    97 
       
    98 // ----------------------------------------------------------------------
       
    99 
       
   100 EXPORT_C TInt RLayoutManager::SetLayout(TInt aLayoutId) const
       
   101     {
       
   102     return SendReceive(ESetLayout, TIpcArgs(aLayoutId));
       
   103     }
       
   104 
       
   105 EXPORT_C TInt RLayoutManager::GetLayout(TInt& aLayoutId) const
       
   106     {
       
   107     TPckg<TInt> layoutPkg(aLayoutId);
       
   108     return SendReceive(EGetLayout, TIpcArgs(&layoutPkg));
       
   109     }
       
   110 
       
   111 EXPORT_C TInt RLayoutManager::GetInitialLayout(TInt& aLayoutId) const
       
   112     {
       
   113     TPckg<TInt> layoutPkg(aLayoutId);
       
   114     return SendReceive(EGetInitialLayout, TIpcArgs(&layoutPkg));
       
   115     }
       
   116 
       
   117 // ----------------------------------------------------------------------
       
   118 
       
   119 EXPORT_C TInt RLayoutManager::GetDeviceInfo(TBool& aIsNokiaSu8,
       
   120         TBool& aFoundLayout) const
       
   121     {
       
   122 
       
   123     TPckg<TBool> isNokiaPkg(aIsNokiaSu8);
       
   124     TPckg<TBool> foundLayoutPkg(aFoundLayout);
       
   125 
       
   126     return SendReceive(EGetDeviceInfo, TIpcArgs(&isNokiaPkg,&foundLayoutPkg));
       
   127     }
       
   128