2015-06-25 17:15:33 +02:00
|
|
|
/*
|
|
|
|
* Human Input Devices
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Kevin Koltzau
|
2015-06-25 21:26:53 +02:00
|
|
|
* Copyright (C) 2015 Aric Stewart
|
2015-06-25 17:15:33 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2022-01-31 10:11:01 +01:00
|
|
|
#include <stdlib.h>
|
2015-06-25 17:15:33 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2015-06-25 21:26:53 +02:00
|
|
|
#include "winternl.h"
|
|
|
|
#include "winioctl.h"
|
|
|
|
#include "ddk/wdm.h"
|
2015-06-25 17:15:33 +02:00
|
|
|
|
2015-06-30 14:40:13 +02:00
|
|
|
#include "hidusage.h"
|
2021-02-18 11:44:18 +01:00
|
|
|
#include "initguid.h"
|
2015-06-25 17:15:33 +02:00
|
|
|
#include "ddk/hidclass.h"
|
2015-06-30 14:40:27 +02:00
|
|
|
#include "ddk/hidsdi.h"
|
2015-06-25 17:15:33 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(hid);
|
|
|
|
|
2019-03-29 22:18:31 +01:00
|
|
|
static BOOL sync_ioctl(HANDLE file, DWORD code, void *in_buf, DWORD in_len, void *out_buf, DWORD out_len)
|
2019-03-13 05:52:09 +01:00
|
|
|
{
|
|
|
|
OVERLAPPED ovl = {0};
|
2019-03-29 22:18:31 +01:00
|
|
|
DWORD ret_len;
|
2019-03-13 05:52:09 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
2019-03-29 22:18:31 +01:00
|
|
|
ret = DeviceIoControl(file, code, in_buf, in_len, out_buf, out_len, &ret_len, &ovl);
|
2019-03-13 05:52:09 +01:00
|
|
|
if (!ret && GetLastError() == ERROR_IO_PENDING)
|
2019-03-29 22:18:31 +01:00
|
|
|
ret = GetOverlappedResult(file, &ovl, &ret_len, TRUE);
|
2019-03-13 05:52:09 +01:00
|
|
|
CloseHandle(ovl.hEvent);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_FreePreparsedData( PHIDP_PREPARSED_DATA preparsed_data )
|
2015-06-30 14:40:13 +02:00
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "preparsed_data %p.\n", preparsed_data );
|
2022-01-31 10:11:01 +01:00
|
|
|
free( preparsed_data );
|
2015-06-30 14:40:13 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_GetAttributes( HANDLE file, PHIDD_ATTRIBUTES attributes )
|
2015-06-30 14:40:27 +02:00
|
|
|
{
|
|
|
|
HID_COLLECTION_INFORMATION info;
|
|
|
|
BOOLEAN ret;
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, attributes %p.\n", file, attributes );
|
2015-06-30 14:40:27 +02:00
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
ret = sync_ioctl( file, IOCTL_HID_GET_COLLECTION_INFORMATION, NULL, 0, &info, sizeof(HID_COLLECTION_INFORMATION) );
|
2015-06-30 14:40:27 +02:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
attributes->Size = sizeof(HIDD_ATTRIBUTES);
|
|
|
|
attributes->VendorID = info.VendorID;
|
|
|
|
attributes->ProductID = info.ProductID;
|
|
|
|
attributes->VersionNumber = info.VersionNumber;
|
2015-06-30 14:40:27 +02:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_GetFeature( HANDLE file, void *report_buf, ULONG report_len )
|
2015-06-25 17:15:33 +02:00
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, report_buf %p, report_len %lu.\n", file, report_buf, report_len );
|
|
|
|
return sync_ioctl( file, IOCTL_HID_GET_FEATURE, NULL, 0, report_buf, report_len );
|
2015-06-25 17:15:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI HidD_GetHidGuid(LPGUID guid)
|
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "guid %s.\n", debugstr_guid( guid ) );
|
2015-06-25 17:15:33 +02:00
|
|
|
*guid = GUID_DEVINTERFACE_HID;
|
|
|
|
}
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_GetInputReport( HANDLE file, void *report_buf, ULONG report_len )
|
2015-06-30 14:40:22 +02:00
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, report_buf %p, report_len %lu.\n", file, report_buf, report_len );
|
|
|
|
return sync_ioctl( file, IOCTL_HID_GET_INPUT_REPORT, NULL, 0, report_buf, report_len );
|
2015-06-30 14:40:22 +02:00
|
|
|
}
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_GetManufacturerString( HANDLE file, void *buffer, ULONG buffer_len )
|
2015-06-25 17:15:33 +02:00
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, buffer %p, buffer_len %lu.\n", file, buffer, buffer_len );
|
|
|
|
return sync_ioctl( file, IOCTL_HID_GET_MANUFACTURER_STRING, NULL, 0, buffer, buffer_len );
|
2015-06-25 17:15:33 +02:00
|
|
|
}
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_GetNumInputBuffers( HANDLE file, ULONG *num_buffer )
|
2017-01-25 14:04:20 +01:00
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, num_buffer %p.\n", file, num_buffer );
|
|
|
|
return sync_ioctl( file, IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS, NULL, 0, num_buffer, sizeof(*num_buffer) );
|
2017-01-25 14:04:20 +01:00
|
|
|
}
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_SetFeature( HANDLE file, void *report_buf, ULONG report_len )
|
2015-06-25 17:15:33 +02:00
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, report_buf %p, report_len %lu.\n", file, report_buf, report_len );
|
|
|
|
return sync_ioctl( file, IOCTL_HID_SET_FEATURE, report_buf, report_len, NULL, 0 );
|
2015-06-25 17:15:33 +02:00
|
|
|
}
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_SetNumInputBuffers( HANDLE file, ULONG num_buffer )
|
2016-04-05 15:41:19 +02:00
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, num_buffer %lu.\n", file, num_buffer );
|
|
|
|
return sync_ioctl( file, IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS, &num_buffer, sizeof(num_buffer), NULL, 0 );
|
2016-04-05 15:41:19 +02:00
|
|
|
}
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_GetProductString( HANDLE file, void *buffer, ULONG buffer_len )
|
2015-06-25 17:15:33 +02:00
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, buffer %p, buffer_len %lu.\n", file, buffer, buffer_len );
|
|
|
|
return sync_ioctl( file, IOCTL_HID_GET_PRODUCT_STRING, NULL, 0, buffer, buffer_len );
|
2015-06-25 17:15:33 +02:00
|
|
|
}
|
2015-06-30 14:40:13 +02:00
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_GetSerialNumberString( HANDLE file, void *buffer, ULONG buffer_len )
|
2015-10-29 20:23:06 +01:00
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, buffer %p, buffer_len %lu.\n", file, buffer, buffer_len );
|
|
|
|
return sync_ioctl( file, IOCTL_HID_GET_SERIALNUMBER_STRING, NULL, 0, buffer, buffer_len );
|
2015-10-29 20:23:06 +01:00
|
|
|
}
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_GetPreparsedData( HANDLE file, PHIDP_PREPARSED_DATA *preparsed_data )
|
2015-06-30 14:40:13 +02:00
|
|
|
{
|
|
|
|
HID_COLLECTION_INFORMATION info;
|
|
|
|
PHIDP_PREPARSED_DATA data;
|
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, preparsed_data %p.\n", file, preparsed_data );
|
2015-06-30 14:40:13 +02:00
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
if (!sync_ioctl( file, IOCTL_HID_GET_COLLECTION_INFORMATION, NULL, 0, &info, sizeof(info) ))
|
2015-06-30 14:40:13 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2022-01-31 10:11:01 +01:00
|
|
|
if (!(data = malloc( info.DescriptorSize ))) return FALSE;
|
2015-06-30 14:40:13 +02:00
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
if (!sync_ioctl( file, IOCTL_HID_GET_COLLECTION_DESCRIPTOR, NULL, 0, data, info.DescriptorSize ))
|
2015-06-30 14:40:13 +02:00
|
|
|
{
|
2022-01-31 10:11:01 +01:00
|
|
|
free( data );
|
2015-06-30 14:40:13 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2022-01-31 10:11:00 +01:00
|
|
|
*preparsed_data = data;
|
2015-06-30 14:40:13 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2016-10-26 19:46:12 +02:00
|
|
|
|
2022-01-31 10:11:00 +01:00
|
|
|
BOOLEAN WINAPI HidD_SetOutputReport( HANDLE file, void *report_buf, ULONG report_len )
|
2016-10-26 19:46:12 +02:00
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, report_buf %p, report_len %lu.\n", file, report_buf, report_len );
|
|
|
|
return sync_ioctl( file, IOCTL_HID_SET_OUTPUT_REPORT, report_buf, report_len, NULL, 0 );
|
2016-10-26 19:46:12 +02:00
|
|
|
}
|
2019-04-07 05:20:17 +02:00
|
|
|
|
|
|
|
BOOLEAN WINAPI HidD_GetIndexedString(HANDLE file, ULONG index, void *buffer, ULONG length)
|
|
|
|
{
|
2022-01-31 10:11:00 +01:00
|
|
|
TRACE( "file %p, index %lu, buffer %p, length %lu.\n", file, index, buffer, length );
|
2019-04-07 05:20:17 +02:00
|
|
|
return sync_ioctl(file, IOCTL_HID_GET_INDEXED_STRING, &index, sizeof(index), buffer, length);
|
|
|
|
}
|
2019-04-07 05:20:18 +02:00
|
|
|
|
|
|
|
BOOLEAN WINAPI HidD_FlushQueue(HANDLE file)
|
|
|
|
{
|
|
|
|
TRACE("file %p.\n", file);
|
|
|
|
return sync_ioctl(file, IOCTL_HID_FLUSH_QUEUE, NULL, 0, NULL, 0);
|
|
|
|
}
|