javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtinput.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 19 Aug 2010 09:48:13 +0300
branchRCL_3
changeset 60 6c158198356e
parent 19 04becd199f91
permissions -rw-r--r--
Revision: v2.2.9 Kit: 201033

/*******************************************************************************
 * Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Nokia Corporation - S60 implementation
 *******************************************************************************/


#include <hal.h>
#include "swtinput.h"
#include "swtmobiledevice.h"


// ======== MEMBER FUNCTIONS ========


// ---------------------------------------------------------------------------
// CSwtInput::NewL
// ---------------------------------------------------------------------------
//
CSwtInput* CSwtInput::NewL(TSwtPeer aPeer, TInt aId)
{
    CSwtInput* self = new(ELeave) CSwtInput(aPeer);
    CleanupStack::PushL(self);
    self->ConstructL(aId);
    CleanupStack::Pop(self);
    return self;
}

// ---------------------------------------------------------------------------
// CSwtInput::CSwtInput
// ---------------------------------------------------------------------------
//
CSwtInput::CSwtInput(TSwtPeer aPeer)
        : iPeer(aPeer)
        , iType(KErrNotFound)
        , iLocation(KErrNotFound)
{
}

void CSwtInput::ConstructL(TInt aId)
{
    RArray<CSwtMobileDevice::TSwtHwInput> inputs;
    CleanupClosePushL(inputs);
    CSwtMobileDevice::GetHwInputsL(inputs);
    if (aId < inputs.Count())
    {
        iType = inputs[aId].iType;
        iLocation = inputs[aId].iLocation;
    }
    CleanupStack::PopAndDestroy(&inputs);
}


// ---------------------------------------------------------------------------
// CSwtInput::~CSwtInput
// ---------------------------------------------------------------------------
//
CSwtInput::~CSwtInput()
{
}

// ---------------------------------------------------------------------------
// CSwtInput::Dispose
// From MSwtInput
// ---------------------------------------------------------------------------
//
TSwtPeer CSwtInput::Dispose()
{
    TSwtPeer peer(iPeer);
    delete this;
    return peer;
}

// ---------------------------------------------------------------------------
// CSwtInput::GetLocation
// From MSwtInput
// ---------------------------------------------------------------------------
//
TInt CSwtInput::GetLocation()
{
    return iLocation;
}

// ---------------------------------------------------------------------------
// CSwtInput::GetType
// From MSwtInput
// ---------------------------------------------------------------------------
//
TInt CSwtInput::GetType()
{
    return iType;
}