mirror of
https://github.com/reactos/reactos.git
synced 2024-08-20 18:35:32 +00:00
implemented a couple of Hid device functions
svn path=/trunk/; revision=10453
This commit is contained in:
parent
a17d473fa8
commit
94efe6c3c1
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: hid.c,v 1.2 2004/07/12 16:04:37 weiden Exp $
|
||||
/* $Id: hid.c,v 1.3 2004/08/09 16:02:43 weiden Exp $
|
||||
*
|
||||
* PROJECT: ReactOS Hid User Library
|
||||
* FILE: lib/hid/hid.c
|
||||
|
@ -26,6 +26,8 @@
|
|||
* 07/12/2004 Created
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <ddk/hidusage.h>
|
||||
#include <ddk/hidclass.h>
|
||||
#include <ddk/hidpi.h>
|
||||
#include "internal.h"
|
||||
|
||||
|
@ -58,6 +60,67 @@ DllMain(HINSTANCE hinstDLL,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_FlushQueue EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_FlushQueue(IN HANDLE HidDeviceObject)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_HID_FLUSH_QUEUE,
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_FreePreparsedData EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_FreePreparsedData(IN PHIDP_PREPARSED_DATA PreparsedData)
|
||||
{
|
||||
return (LocalFree((HLOCAL)PreparsedData) == NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_GetAttributes EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetAttributes(IN HANDLE HidDeviceObject,
|
||||
OUT PHIDD_ATTRIBUTES Attributes)
|
||||
{
|
||||
HID_COLLECTION_INFORMATION hci;
|
||||
DWORD RetLen;
|
||||
|
||||
if(!DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_COLLECTION_INFORMATION,
|
||||
NULL, 0,
|
||||
&hci, sizeof(HID_COLLECTION_INFORMATION),
|
||||
&RetLen, NULL))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* copy the fields */
|
||||
Attributes->Size = sizeof(HIDD_ATTRIBUTES);
|
||||
Attributes->VendorID = hci.VendorID;
|
||||
Attributes->ProductID = hci.ProductID;
|
||||
Attributes->VersionNumber = hci.VersionNumber;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidP_GetButtonCaps EXPORTED
|
||||
*
|
||||
|
@ -70,7 +133,27 @@ HidP_GetButtonCaps(IN HIDP_REPORT_TYPE ReportType,
|
|||
IN OUT PULONG ButtonCapsLength,
|
||||
IN PHIDP_PREPARSED_DATA PreparsedData)
|
||||
{
|
||||
return HidP_GetSpecificButtonCaps(ReportType, 0, 0, 0, ButtonCaps, ButtonCapsLength, PreparsedData);
|
||||
return HidP_GetSpecificButtonCaps(ReportType, 0, 0, 0, ButtonCaps,
|
||||
ButtonCapsLength, PreparsedData);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_GetFeature EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetFeature(IN HANDLE HidDeviceObject,
|
||||
OUT PVOID ReportBuffer,
|
||||
IN ULONG ReportBufferLength)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_FEATURE,
|
||||
NULL, 0,
|
||||
ReportBuffer, ReportBufferLength,
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,6 +170,174 @@ HidD_GetHidGuid(OUT LPGUID HidGuid)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_GetInputReport EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetInputReport(IN HANDLE HidDeviceObject,
|
||||
IN OUT PVOID ReportBuffer,
|
||||
IN ULONG ReportBufferLength)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_INPUT_REPORT,
|
||||
NULL, 0,
|
||||
ReportBuffer, ReportBufferLength,
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_GetManufacturerString EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetManufacturerString(IN HANDLE HidDeviceObject,
|
||||
OUT PVOID Buffer,
|
||||
IN ULONG BufferLength)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_MANUFACTURER_STRING,
|
||||
NULL, 0,
|
||||
Buffer, BufferLength,
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_GetNumInputBuffers EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetNumInputBuffers(IN HANDLE HidDeviceObject,
|
||||
OUT PULONG NumberBuffers)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS,
|
||||
NULL, 0,
|
||||
NumberBuffers, sizeof(ULONG),
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_GetPhysicalDescriptor EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetPhysicalDescriptor(IN HANDLE HidDeviceObject,
|
||||
OUT PVOID Buffer,
|
||||
IN ULONG BufferLength)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_GET_PHYSICAL_DESCRIPTOR,
|
||||
NULL, 0,
|
||||
Buffer, BufferLength,
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_GetPreparsedData EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetPreparsedData(IN HANDLE HidDeviceObject,
|
||||
OUT PHIDP_PREPARSED_DATA *PreparsedData)
|
||||
{
|
||||
HID_COLLECTION_INFORMATION hci;
|
||||
DWORD RetLen;
|
||||
BOOL Ret;
|
||||
|
||||
if(PreparsedData == NULL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(!DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_COLLECTION_INFORMATION,
|
||||
NULL, 0,
|
||||
&hci, sizeof(HID_COLLECTION_INFORMATION),
|
||||
&RetLen, NULL))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*PreparsedData = LocalAlloc(LHND, hci.DescriptorSize);
|
||||
if(*PreparsedData == NULL)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Ret = DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_COLLECTION_DESCRIPTOR,
|
||||
NULL, 0,
|
||||
*PreparsedData, hci.DescriptorSize,
|
||||
&RetLen, NULL);
|
||||
|
||||
if(!Ret)
|
||||
{
|
||||
/* FIXME - Free the buffer in case we failed to get the descriptor? */
|
||||
LocalFree((HLOCAL)*PreparsedData);
|
||||
}
|
||||
#if 0
|
||||
else
|
||||
{
|
||||
/* should we truncate the memory in case RetLen < hci.DescriptorSize? */
|
||||
}
|
||||
#endif
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_GetProductString EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetProductString(IN HANDLE HidDeviceObject,
|
||||
OUT PVOID Buffer,
|
||||
IN ULONG BufferLength)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_PRODUCT_STRING,
|
||||
NULL, 0,
|
||||
Buffer, BufferLength,
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_GetSerialNumberString EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetSerialNumberString(IN HANDLE HidDeviceObject,
|
||||
OUT PVOID Buffer,
|
||||
IN ULONG BufferLength)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_SERIALNUMBER_STRING,
|
||||
NULL, 0,
|
||||
Buffer, BufferLength,
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidP_GetValueCaps EXPORTED
|
||||
*
|
||||
|
@ -99,18 +350,19 @@ HidP_GetValueCaps(IN HIDP_REPORT_TYPE ReportType,
|
|||
IN OUT PULONG ValueCapsLength,
|
||||
IN PHIDP_PREPARSED_DATA PreparsedData)
|
||||
{
|
||||
return HidP_GetSpecificValueCaps (ReportType, 0, 0, 0, ValueCaps, ValueCapsLength, PreparsedData);
|
||||
return HidP_GetSpecificValueCaps(ReportType, 0, 0, 0, ValueCaps,
|
||||
ValueCapsLength, PreparsedData);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_Hello EXPORTED
|
||||
*
|
||||
* Undocumented easter egg function. It fills the buffer with "Hello\nI hate Jello\n"
|
||||
* and returns number of bytes filled in (lstrlen(Buffer) + 1 == 20)
|
||||
* Undocumented easter egg function. It fills the buffer with "Hello\n"
|
||||
* and returns number of bytes filled in (lstrlen(Buffer) + 1 == 7)
|
||||
*
|
||||
* Bugs: - doesn't check Buffer for NULL
|
||||
* - always returns 20 even if BufferLength < 20 but doesn't produce a buffer overflow
|
||||
* - always returns 7 even if BufferLength < 7 but doesn't produce a buffer overflow
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
|
@ -119,11 +371,71 @@ ULONG DDKAPI
|
|||
HidD_Hello(OUT PCHAR Buffer,
|
||||
IN ULONG BufferLength)
|
||||
{
|
||||
const PCHAR const HelloString = "Hello\nI hate Jello\n";
|
||||
ULONG StrSize = lstrlenA(HelloString) + sizeof(CHAR);
|
||||
const PCHAR const HelloString = "Hello\n";
|
||||
ULONG StrSize = (lstrlenA(HelloString) + 1) * sizeof(CHAR);
|
||||
|
||||
if(BufferLength > 0)
|
||||
{
|
||||
memcpy(Buffer, HelloString, min(StrSize, BufferLength));
|
||||
}
|
||||
|
||||
memcpy(Buffer, HelloString, min(StrSize, BufferLength));
|
||||
return StrSize;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_SetFeature EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_SetFeature(IN HANDLE HidDeviceObject,
|
||||
IN PVOID ReportBuffer,
|
||||
IN ULONG ReportBufferLength)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_HID_SET_FEATURE,
|
||||
ReportBuffer, ReportBufferLength,
|
||||
NULL, 0,
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_SetNumInputBuffers EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_SetNumInputBuffers(IN HANDLE HidDeviceObject,
|
||||
IN ULONG NumberBuffers)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS,
|
||||
&NumberBuffers, sizeof(ULONG),
|
||||
NULL, 0,
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HidD_SetOutputReport EXPORTED
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_SetOutputReport(IN HANDLE HidDeviceObject,
|
||||
IN PVOID ReportBuffer,
|
||||
IN ULONG ReportBufferLength)
|
||||
{
|
||||
DWORD RetLen;
|
||||
return DeviceIoControl(HidDeviceObject, IOCTL_HID_SET_OUTPUT_REPORT,
|
||||
ReportBuffer, ReportBufferLength,
|
||||
NULL, 0,
|
||||
&RetLen, NULL);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: stubs.c,v 1.2 2004/07/12 16:04:37 weiden Exp $
|
||||
/* $Id: stubs.c,v 1.3 2004/08/09 16:02:43 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS Hid User Library
|
||||
|
@ -17,43 +17,6 @@
|
|||
DbgPrint("HID: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__)
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_FlushQueue(IN HANDLE HidDeviceObject)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_FreePreparsedData(IN PHIDP_PREPARSED_DATA PreparsedData)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetAttributes(IN HANDLE HidDeviceObject,
|
||||
OUT PHIDD_ATTRIBUTES Attributes)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
@ -68,20 +31,6 @@ HidD_GetConfiguration(IN HANDLE HidDeviceObject,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetFeature(IN HANDLE HidDeviceObject,
|
||||
OUT PVOID ReportBuffer,
|
||||
IN ULONG ReportBufferLength)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
@ -97,34 +46,6 @@ HidD_GetIndexedString(IN HANDLE HidDeviceObject,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetInputReport(IN HANDLE HidDeviceObject,
|
||||
IN OUT PVOID ReportBuffer,
|
||||
IN ULONG ReportBufferLength)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetManufacturerString(IN HANDLE HidDeviceObject,
|
||||
OUT PVOID Buffer,
|
||||
IN ULONG BufferLength)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
@ -139,74 +60,6 @@ HidD_GetMsGenreDescriptor(IN HANDLE HidDeviceObject,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetNumInputBuffers(IN HANDLE HidDeviceObject,
|
||||
OUT PULONG NumberBuffers)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetPhysicalDescriptor(IN HANDLE HidDeviceObject,
|
||||
OUT PVOID Buffer,
|
||||
IN ULONG BufferLength)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetPreparsedData(IN HANDLE HidDeviceObject,
|
||||
OUT PHIDP_PREPARSED_DATA *PreparsedData)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetProductString(IN HANDLE HidDeviceObject,
|
||||
OUT PVOID Buffer,
|
||||
IN ULONG BufferLength)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_GetSerialNumberString(IN HANDLE HidDeviceObject,
|
||||
OUT PVOID Buffer,
|
||||
IN ULONG BufferLength)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
@ -221,47 +74,6 @@ HidD_SetConfiguration(IN HANDLE HidDeviceObject,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_SetFeature(IN HANDLE HidDeviceObject,
|
||||
IN PVOID ReportBuffer,
|
||||
IN ULONG ReportBufferLength)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_SetNumInputBuffers(IN HANDLE HidDeviceObject,
|
||||
OUT ULONG NumberBuffers)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
HIDAPI
|
||||
BOOLEAN DDKAPI
|
||||
HidD_SetOutputReport(IN HANDLE HidDeviceObject,
|
||||
IN PVOID ReportBuffer,
|
||||
IN ULONG ReportBufferLength)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue