blob: 501a1a22f5708d7e0c33009b6ef50ad9baa44946 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <pch.h>
/*
** Driver TODO: Add code to EvtDeviceOwnershipChange to reset the device state to a default.
**
** PosCx calls this callback to signal that the ownership of the device has transitioned from one file handle
** to another. When this happens, app developers expect that the settings for the device are restored to a
** "default" state, so the driver should do what is necessary to satisfy that expectation here.
**
*/
VOID EvtDeviceOwnershipChange(_In_ WDFDEVICE Device, _In_opt_ WDFFILEOBJECT OldOwnerFileObj, _In_opt_ WDFFILEOBJECT NewOwnerFileObj)
{
UNREFERENCED_PARAMETER(Device);
UNREFERENCED_PARAMETER(OldOwnerFileObj);
UNREFERENCED_PARAMETER(NewOwnerFileObj);
// This function signals that ownership has transitioned from one file handle to another (typically from one app to another).
// As a result, the driver is expected to reset all settings to a default state.
}
/*
** Driver TODO:
**
** This part of the sample demonstrates how the driver will return data to the runtime. How this method would be called depends
** on the driver implementation.
*/
VOID EvtOnMsrScanDataRetrieved(_In_ WDFDEVICE Device)
{
// Events that the runtime can handle for a magnetic stripe reader device are:
// PosEventType::MagneticStripeReaderDataReceived -- the standard event with MSR data
// PosEventType::MagneticStripeReaderErrorOccurred -- an event that should be sent if an error occured while scanning data
// PosEventType::StatusUpdated -- an event to indicate changes to power state
//
// Additionally, the following event is sent to the runtime, but is handled entirely by PosCx
// PosEventType::ReleaseDeviceRequested
// The following shows an example of sending MSR data
MSR_DATA_RECEIVED dataReceivedEventInfo;
// Fill in all the fields in MSR_DATA_RECEIVED
// This call actually pends the data to be send to the WinRT APIs.
NTSTATUS status = PosCxPutPendingEvent(Device, MSR_INTERFACE_TAG, PosEventType::MagneticStripeReaderDataReceived, sizeof(dataReceivedEventInfo), &dataReceivedEventInfo, POS_CX_EVENT_ATTR_DATA);
if (!NT_SUCCESS(status))
{
// This should only happen in rare cases such as out of memory (or that the device or interface tag isn't found). The driver should most likely drop the event.
}
}
|