From bc722fec5f4307d69e655975ab23a9f3fbf8769f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Sun, 23 Sep 2018 14:58:25 +0200 Subject: [PATCH] Finished implementation of "vigem_target_x360_get_user_index" --- include/ViGEm/km/BusShared.h | 9 +++++++-- src/ViGEmClient.cpp | 13 +++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/ViGEm/km/BusShared.h b/include/ViGEm/km/BusShared.h index 7fb9663..2e401ba 100644 --- a/include/ViGEm/km/BusShared.h +++ b/include/ViGEm/km/BusShared.h @@ -23,8 +23,13 @@ SOFTWARE. */ +// +// GUID identifying the bus device. Used by client library to detect and communicate. +// +// IMPORTANT: make sure to change this value if you fork it or introduce +// breaking changes! +// // {96E42B22-F5E9-42F8-B043-ED0F932F014F} -// ReSharper disable once CppMissingIncludeGuard DEFINE_GUID(GUID_DEVINTERFACE_BUSENUM_VIGEM, 0x96E42B22, 0xF5E9, 0x42F8, 0xB0, 0x43, 0xED, 0x0F, 0x93, 0x2F, 0x01, 0x4F); @@ -41,7 +46,7 @@ DEFINE_GUID(GUID_DEVINTERFACE_BUSENUM_VIGEM, // access is permitted and success reported. If they mismatch, an // error is reported and the user-mode library skips this instance. // -#define VIGEM_COMMON_VERSION 0x0001 +#define VIGEM_COMMON_VERSION 0x0002 #define FILE_DEVICE_BUSENUM FILE_DEVICE_BUS_EXTENDER #define BUSENUM_IOCTL(_index_) CTL_CODE(FILE_DEVICE_BUSENUM, _index_, METHOD_BUFFERED, FILE_READ_DATA) diff --git a/src/ViGEmClient.cpp b/src/ViGEmClient.cpp index 28373a4..0e069ff 100644 --- a/src/ViGEmClient.cpp +++ b/src/ViGEmClient.cpp @@ -35,6 +35,8 @@ SOFTWARE. #include #include +#include + #define VIGEM_TARGETS_MAX USHRT_MAX // @@ -778,12 +780,11 @@ VIGEM_ERROR vigem_target_x360_get_user_index( return VIGEM_ERROR_INVALID_TARGET; } - // TODO: handle userindex out-of-range situation here - //if (error == ???) - //{ - // CloseHandle(lOverlapped.hEvent); - // return VIGEM_ERROR_XUSB_USERINDEX_OUT_OF_RANGE; - //} + if (error == ERROR_INVALID_DEVICE_OBJECT_PARAMETER) + { + CloseHandle(lOverlapped.hEvent); + return VIGEM_ERROR_XUSB_USERINDEX_OUT_OF_RANGE; + } } CloseHandle(lOverlapped.hEvent);