Skip to content

Commit

Permalink
Added support for the DirectInput property DIPROP_VIDPID since some a…
Browse files Browse the repository at this point in the history
…pplications require that it be available for reading.
  • Loading branch information
samuelgr committed Dec 1, 2022
1 parent b0b4d8b commit 293a5cd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Include/Xidi/ControllerIdentification.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,18 @@ namespace Xidi
xguid.Data4[7] = ((controllerId >> 24) & 0xff);
return xguid;
}

/// Retrieves the 16-bit product identifier for Xidi virtual controllers.
/// @return Product identifier for all virtual controllers.
constexpr inline WORD VirtualControllerProductId(void)
{
return (WORD)(kVirtualControllerProductGuid.Data1 >> 16);
}

/// Retrieves the 16-bit vendor identifier for Xidi virtual controllers.
/// @return Vendor identifier for all virtual controllers.
constexpr inline WORD VirtualControllerVendorId(void)
{
return (WORD)(kVirtualControllerProductGuid.Data1);
}
}
11 changes: 9 additions & 2 deletions Source/VirtualDirectInputDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ namespace Xidi
case ((size_t)&DIPROP_DEADZONE):
case ((size_t)&DIPROP_GRANULARITY):
case ((size_t)&DIPROP_SATURATION):
// Axis mode, deadzone, granularity, and saturation all use DIPROPDWORD.
case ((size_t)&DIPROP_VIDPID):
// Axis mode, deadzone, granularity, saturation, and vendor/product ID all use DIPROPDWORD.
if (sizeof(DIPROPDWORD) != pdiph->dwSize)
{
Message::OutputFormatted(Message::ESeverity::Warning, L"Rejected invalid property header for %s: Incorrect size for DIPROPDWORD (expected %u, got %u).", PropertyGuidString(rguidProp), (unsigned int)sizeof(DIPROPDWORD), (unsigned int)pdiph->dwSize);
Expand Down Expand Up @@ -1577,13 +1578,19 @@ namespace Xidi
((LPDIPROPRANGE)pdiph)->lMax = kRange.second;
} while (false);
LOG_PROPERTY_INVOCATION_DIPROPRANGE_AND_RETURN(DI_OK, kMethodSeverity, rguidProp, pdiph);

case ((size_t)&DIPROP_SATURATION):
if (Controller::EElementType::Axis != element.type)
LOG_PROPERTY_INVOCATION_NO_VALUE_AND_RETURN(DIERR_INVALIDPARAM, kMethodSeverity, rguidProp);
((LPDIPROPDWORD)pdiph)->dwData = controller->GetAxisSaturation(element.axis);
LOG_PROPERTY_INVOCATION_DIPROPDWORD_AND_RETURN(DI_OK, kMethodSeverity, rguidProp, pdiph);

case ((size_t)&DIPROP_VIDPID):
if (Controller::EElementType::WholeController != element.type)
LOG_PROPERTY_INVOCATION_NO_VALUE_AND_RETURN(DIERR_INVALIDPARAM, kMethodSeverity, rguidProp);
((LPDIPROPDWORD)pdiph)->dwData = ((DWORD)VirtualControllerProductId() << 16) | ((DWORD)VirtualControllerVendorId());
LOG_PROPERTY_INVOCATION_DIPROPDWORD_AND_RETURN(DI_OK, kMethodSeverity, rguidProp, pdiph);

default:
LOG_PROPERTY_INVOCATION_NO_VALUE_AND_RETURN(DIERR_UNSUPPORTED, kMethodSeverity, rguidProp);
}
Expand Down

0 comments on commit 293a5cd

Please sign in to comment.