1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/eventdd.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,111 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <kernel/kernel.h>
1.20 +#include "eventdd.h"
1.21 +
1.22 +/**
1.23 + Logical Device (factory class) for 'EventDD'
1.24 +*/
1.25 +class DEventFactory : public DLogicalDevice
1.26 + {
1.27 +public:
1.28 + DEventFactory();
1.29 + //Pure virtual funcitons from DLogicalDevice
1.30 + TInt Install();
1.31 + void GetCaps(TDes8& aDes) const;
1.32 + TInt Create(DLogicalChannelBase*& aChannel);
1.33 + };
1.34 +
1.35 +class DEventDD : public DLogicalChannelBase
1.36 + {
1.37 +public:
1.38 + //Pure virtual function from DLogicalChannelBase
1.39 + TInt Request(TInt aReqNo,TAny* a1,TAny* a2);
1.40 +private:
1.41 + TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
1.42 + TInt SendEvent(TRawEvent* aEvent);
1.43 + };
1.44 +
1.45 +
1.46 +/* DLL Factory Function */
1.47 +
1.48 +DECLARE_STANDARD_LDD()
1.49 + {
1.50 + return new DEventFactory;
1.51 + }
1.52 +
1.53 +
1.54 +/* DEventFactory */
1.55 +
1.56 +DEventFactory::DEventFactory() :DLogicalDevice()
1.57 + {
1.58 + iVersion=REventDD::VersionRequired(); //Set version number for this device
1.59 + }
1.60 +
1.61 +TInt DEventFactory::Install()
1.62 + {
1.63 + return SetName(&REventDD::DriverName());
1.64 + }
1.65 +
1.66 +void DEventFactory::GetCaps(TDes8& aDes) const
1.67 + {
1.68 + Kern::InfoCopy(aDes,KNullDesC8);
1.69 + }
1.70 +
1.71 +TInt DEventFactory::Create(DLogicalChannelBase*& aChannel)
1.72 + {
1.73 + aChannel=new DEventDD;
1.74 + return aChannel?KErrNone:KErrNoMemory;
1.75 + }
1.76 +
1.77 +
1.78 +/* DEventDD */ // Logical Channel
1.79 +
1.80 +TInt DEventDD::Request(TInt aReqNo,TAny* a1,TAny* a2)
1.81 + {
1.82 + // Decode the message type and dispatch it to the relevent handler function...
1.83 + // only using synchronous control messages
1.84 + if (static_cast<TUint>(aReqNo)<static_cast<TUint>(KMaxTInt))
1.85 + return DoControl(aReqNo,a1,a2);
1.86 + return KErrNotSupported;
1.87 + }
1.88 +
1.89 +/**
1.90 + Process synchronous 'control' requests
1.91 +*/
1.92 +TInt DEventDD::DoControl(TInt aFunction,TAny* a1,TAny* /*a2*/)
1.93 + {
1.94 + TInt ret=KErrNotSupported;
1.95 +
1.96 + switch (aFunction)
1.97 + {
1.98 + case REventDD::ESendEvent:
1.99 + ret=SendEvent(static_cast<TRawEvent*>(a1));
1.100 + break;
1.101 + default:;
1.102 + }
1.103 + return ret;
1.104 + }
1.105 +
1.106 +TInt DEventDD::SendEvent(TRawEvent* aEvent)
1.107 + {
1.108 + TRawEvent event;
1.109 + kumemget(&event,aEvent,sizeof(TRawEvent)); //fetch event from user memory
1.110 + NKern::ThreadEnterCS();
1.111 + TInt err=Kern::AddEvent(event);
1.112 + NKern::ThreadLeaveCS();
1.113 + return err;
1.114 + }