First public contribution.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <kernel/kernel.h>
20 Logical Device (factory class) for 'EventDD'
22 class DEventFactory : public DLogicalDevice
26 //Pure virtual funcitons from DLogicalDevice
28 void GetCaps(TDes8& aDes) const;
29 TInt Create(DLogicalChannelBase*& aChannel);
32 class DEventDD : public DLogicalChannelBase
35 //Pure virtual function from DLogicalChannelBase
36 TInt Request(TInt aReqNo,TAny* a1,TAny* a2);
38 TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
39 TInt SendEvent(TRawEvent* aEvent);
43 /* DLL Factory Function */
45 DECLARE_STANDARD_LDD()
47 return new DEventFactory;
53 DEventFactory::DEventFactory() :DLogicalDevice()
55 iVersion=REventDD::VersionRequired(); //Set version number for this device
58 TInt DEventFactory::Install()
60 return SetName(&REventDD::DriverName());
63 void DEventFactory::GetCaps(TDes8& aDes) const
65 Kern::InfoCopy(aDes,KNullDesC8);
68 TInt DEventFactory::Create(DLogicalChannelBase*& aChannel)
70 aChannel=new DEventDD;
71 return aChannel?KErrNone:KErrNoMemory;
75 /* DEventDD */ // Logical Channel
77 TInt DEventDD::Request(TInt aReqNo,TAny* a1,TAny* a2)
79 // Decode the message type and dispatch it to the relevent handler function...
80 // only using synchronous control messages
81 if (static_cast<TUint>(aReqNo)<static_cast<TUint>(KMaxTInt))
82 return DoControl(aReqNo,a1,a2);
83 return KErrNotSupported;
87 Process synchronous 'control' requests
89 TInt DEventDD::DoControl(TInt aFunction,TAny* a1,TAny* /*a2*/)
91 TInt ret=KErrNotSupported;
95 case REventDD::ESendEvent:
96 ret=SendEvent(static_cast<TRawEvent*>(a1));
103 TInt DEventDD::SendEvent(TRawEvent* aEvent)
106 kumemget(&event,aEvent,sizeof(TRawEvent)); //fetch event from user memory
107 NKern::ThreadEnterCS();
108 TInt err=Kern::AddEvent(event);
109 NKern::ThreadLeaveCS();