os/graphics/windowing/windowserver/test/tauto/eventdd.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <kernel/kernel.h>
sl@0
    17
#include "eventdd.h"
sl@0
    18
sl@0
    19
/**
sl@0
    20
  Logical Device (factory class) for 'EventDD'
sl@0
    21
*/
sl@0
    22
class DEventFactory : public DLogicalDevice
sl@0
    23
	{
sl@0
    24
public:
sl@0
    25
	DEventFactory();
sl@0
    26
	//Pure virtual funcitons from DLogicalDevice
sl@0
    27
	TInt Install();
sl@0
    28
	void GetCaps(TDes8& aDes) const;
sl@0
    29
	TInt Create(DLogicalChannelBase*& aChannel);
sl@0
    30
	};
sl@0
    31
sl@0
    32
class DEventDD : public DLogicalChannelBase
sl@0
    33
	{
sl@0
    34
public:
sl@0
    35
	//Pure virtual function from DLogicalChannelBase
sl@0
    36
	TInt Request(TInt aReqNo,TAny* a1,TAny* a2);
sl@0
    37
private:
sl@0
    38
	TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
sl@0
    39
	TInt SendEvent(TRawEvent* aEvent);
sl@0
    40
	};
sl@0
    41
sl@0
    42
sl@0
    43
/* DLL Factory Function */
sl@0
    44
sl@0
    45
DECLARE_STANDARD_LDD()
sl@0
    46
	{
sl@0
    47
	return new DEventFactory;
sl@0
    48
	}
sl@0
    49
sl@0
    50
sl@0
    51
/* DEventFactory */
sl@0
    52
sl@0
    53
DEventFactory::DEventFactory() :DLogicalDevice()
sl@0
    54
	{
sl@0
    55
	iVersion=REventDD::VersionRequired();	//Set version number for this device
sl@0
    56
	}
sl@0
    57
sl@0
    58
TInt DEventFactory::Install()
sl@0
    59
	{
sl@0
    60
	return SetName(&REventDD::DriverName());
sl@0
    61
	}
sl@0
    62
sl@0
    63
void DEventFactory::GetCaps(TDes8& aDes) const
sl@0
    64
	{
sl@0
    65
	Kern::InfoCopy(aDes,KNullDesC8);
sl@0
    66
	}
sl@0
    67
sl@0
    68
TInt DEventFactory::Create(DLogicalChannelBase*& aChannel)
sl@0
    69
	{
sl@0
    70
	aChannel=new DEventDD;
sl@0
    71
	return aChannel?KErrNone:KErrNoMemory;
sl@0
    72
	}
sl@0
    73
sl@0
    74
sl@0
    75
/* DEventDD */	// Logical Channel
sl@0
    76
sl@0
    77
TInt DEventDD::Request(TInt aReqNo,TAny* a1,TAny* a2)
sl@0
    78
	{
sl@0
    79
	// Decode the message type and dispatch it to the relevent handler function...
sl@0
    80
	// only using synchronous control messages
sl@0
    81
	if (static_cast<TUint>(aReqNo)<static_cast<TUint>(KMaxTInt))
sl@0
    82
		return DoControl(aReqNo,a1,a2);
sl@0
    83
	return KErrNotSupported;
sl@0
    84
	}
sl@0
    85
sl@0
    86
/**
sl@0
    87
  Process synchronous 'control' requests
sl@0
    88
*/
sl@0
    89
TInt DEventDD::DoControl(TInt aFunction,TAny* a1,TAny* /*a2*/)
sl@0
    90
	{
sl@0
    91
	TInt ret=KErrNotSupported;
sl@0
    92
sl@0
    93
	switch (aFunction)
sl@0
    94
		{
sl@0
    95
	case REventDD::ESendEvent:
sl@0
    96
		ret=SendEvent(static_cast<TRawEvent*>(a1));
sl@0
    97
		break;
sl@0
    98
	default:;
sl@0
    99
		}
sl@0
   100
	return ret;
sl@0
   101
	}
sl@0
   102
sl@0
   103
TInt DEventDD::SendEvent(TRawEvent* aEvent)
sl@0
   104
	{
sl@0
   105
	TRawEvent event;
sl@0
   106
	kumemget(&event,aEvent,sizeof(TRawEvent));	//fetch event from user memory
sl@0
   107
	NKern::ThreadEnterCS();
sl@0
   108
	TInt err=Kern::AddEvent(event);
sl@0
   109
	NKern::ThreadLeaveCS();
sl@0
   110
	return err;
sl@0
   111
	}