import "wtypes.idl";
import "oaidl.idl";
import "sti.idl";

typedef struct _STI_USD_CAPS {
	DWORD dwVersion;
	DWORD dwGenericCaps;
} STI_USD_CAPS, *PSTI_USD_CAPS;

/* Possible values for dwGenericCaps: */
#define STI_USD_GENCAP_NATIVE_PUSHSUPPORT STI_GENCAP_NOTIFICATIONS

typedef struct IStiUSD *PSTIUSD;
typedef struct IStiDeviceControl *PSTIDEVICECONTROL;

[
	object,
	uuid(0C9BB460-51AC-11D0-90EA-00AA0060F86C),
	pointer_default(unique)
]
interface IStiUSD : IUnknown
{
	HRESULT Initialize(PSTIDEVICECONTROL pDcb, DWORD dwStiVersion, HKEY hParametersKey);
	HRESULT GetCapabilities(PSTI_USD_CAPS pUsdCaps);
	HRESULT GetStatus(PSTI_DEVICE_STATUS pDevStatus);
	HRESULT DeviceReset();
	HRESULT Diagnostic(LPSTI_DIAG pBuffer);
	HRESULT Escape(STI_RAW_CONTROL_CODE EscapeFunction, LPVOID lpInData, DWORD cbInDataSize, LPVOID pOutData, DWORD dwOutDataSize, LPDWORD pdwActualData);
	HRESULT GetLastError(LPDWORD pdwLastDeviceError);
	HRESULT LockDevice();
	HRESULT UnlockDevice();
	HRESULT RawReadData(LPVOID lpBuffer, LPDWORD lpdwNumberOfBytes, OVERLAPPED *lpOverlapped);
	HRESULT RawWriteData(LPVOID lpBuffer, DWORD nNumberOfBytes, OVERLAPPED *lpOverlapped);
	HRESULT RawReadCommand(LPVOID lpBuffer, LPDWORD lpdwNumberOfBytes, OVERLAPPED *lpOverlapped);
	HRESULT RawWriteCommand(LPVOID lpBuffer, DWORD nNumberOfBytes, OVERLAPPED *lpOverlapped);
	HRESULT SetNotificationHandle(HANDLE hEvent);
	HRESULT GetNotificationData(LPSTINOTIFY pBuffer);
	HRESULT GetLastErrorInfo(STI_ERROR_INFOW *pLastErrorInfo);
}

[
	object,
	uuid(128A9860-52DC-11D0-9EDF-444553540000),
	pointer_default(unique)
]
interface IStiDeviceControl : IUnknown
{
	HRESULT Initialize(DWORD dwDeviceType, DWORD dwMode, LPCWSTR pwszPortName, DWORD dwFlags);
	HRESULT RawReadData(LPVOID lpBuffer, LPDWORD lpdwNumberOfBytes, OVERLAPPED *lpOverlapped);
	HRESULT RawWriteData(LPVOID lpBuffer, DWORD nNumberOfBytes, OVERLAPPED *lpOverlapped);
	HRESULT RawReadCommand(LPVOID lpBuffer, LPDWORD lpdwNumberOfBytes, OVERLAPPED *lpOverlapped);
	HRESULT RawWriteCommand(LPVOID lpBuffer, DWORD nNumberOfBytes, OVERLAPPED *lpOverlapped);
	HRESULT RawDeviceControl(STI_RAW_CONTROL_CODE EscapeFunction, LPVOID lpInData, DWORD cbInDataSize, LPVOID pOutData, DWORD dwOutDataSize, LPDWORD pdwActualData);
	HRESULT GetLastError(LPDWORD lpdwLastError);
	HRESULT GetMyDevicePortName(LPWSTR lpszDevicePath, DWORD cwDevicePathSize);
	HRESULT GetMyDeviceHandle(HANDLE *lph);
	HRESULT GetMyDeviceOpenMode(LPDWORD pdwOpenMode);
	HRESULT WriteToErrorLog(DWORD dwMessageType, LPCWSTR pszMessage, DWORD dwErrorCode);
}
