mirror of
https://github.com/nefarius/ViGEmBus.git
synced 2025-08-10 00:52:17 +00:00
Add user-data paramater to notification callback
This commit is contained in:
@@ -111,6 +111,7 @@ extern "C" {
|
||||
EVT_VIGEM_X360_NOTIFICATION(
|
||||
PVIGEM_CLIENT Client,
|
||||
PVIGEM_TARGET Target,
|
||||
LPVOID UserData,
|
||||
UCHAR LargeMotor,
|
||||
UCHAR SmallMotor,
|
||||
UCHAR LedNumber
|
||||
@@ -124,6 +125,7 @@ extern "C" {
|
||||
EVT_VIGEM_DS4_NOTIFICATION(
|
||||
PVIGEM_CLIENT Client,
|
||||
PVIGEM_TARGET Target,
|
||||
LPVOID UserData,
|
||||
UCHAR LargeMotor,
|
||||
UCHAR SmallMotor,
|
||||
DS4_LIGHTBAR_COLOR LightbarColor
|
||||
@@ -291,10 +293,11 @@ extern "C" {
|
||||
* \param vigem The driver connection object.
|
||||
* \param target The target device object.
|
||||
* \param notification The notification callback.
|
||||
* \param userData The user data passed to the notification callback.
|
||||
*
|
||||
* \return A VIGEM_ERROR.
|
||||
*/
|
||||
VIGEM_API VIGEM_ERROR vigem_target_x360_register_notification(PVIGEM_CLIENT vigem, PVIGEM_TARGET target, PFN_VIGEM_X360_NOTIFICATION notification);
|
||||
VIGEM_API VIGEM_ERROR vigem_target_x360_register_notification(PVIGEM_CLIENT vigem, PVIGEM_TARGET target, PFN_VIGEM_X360_NOTIFICATION notification, LPVOID userData);
|
||||
|
||||
/**
|
||||
* \fn VIGEM_ERROR vigem_target_ds4_register_notification(PVIGEM_CLIENT vigem, PVIGEM_TARGET target, PVIGEM_DS4_NOTIFICATION notification);
|
||||
@@ -309,10 +312,11 @@ extern "C" {
|
||||
* \param vigem The driver connection object.
|
||||
* \param target The target device object.
|
||||
* \param notification The notification callback.
|
||||
* \param userData The user data passed to the notification callback.
|
||||
*
|
||||
* \return A VIGEM_ERROR.
|
||||
*/
|
||||
VIGEM_API VIGEM_ERROR vigem_target_ds4_register_notification(PVIGEM_CLIENT vigem, PVIGEM_TARGET target, PFN_VIGEM_DS4_NOTIFICATION notification);
|
||||
VIGEM_API VIGEM_ERROR vigem_target_ds4_register_notification(PVIGEM_CLIENT vigem, PVIGEM_TARGET target, PFN_VIGEM_DS4_NOTIFICATION notification, LPVOID userData);
|
||||
|
||||
/**
|
||||
* \fn void vigem_target_x360_unregister_notification(PVIGEM_TARGET target);
|
||||
|
||||
@@ -65,6 +65,7 @@ typedef struct _VIGEM_TARGET_T
|
||||
USHORT ProductId;
|
||||
VIGEM_TARGET_TYPE Type;
|
||||
FARPROC Notification;
|
||||
LPVOID NotificationUserData;
|
||||
|
||||
bool closingNotificationThreads;
|
||||
HANDLE cancelNotificationThreadEvent;
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
void ProcessNotificationRequest(PVIGEM_CLIENT client, PVIGEM_TARGET target) override
|
||||
{
|
||||
if(target->Notification != nullptr)
|
||||
PFN_VIGEM_X360_NOTIFICATION(target->Notification)(client, target,
|
||||
PFN_VIGEM_X360_NOTIFICATION(target->Notification)(client, target, target->NotificationUserData,
|
||||
((PXUSB_REQUEST_NOTIFICATION)lpPayloadBuffer)->LargeMotor,
|
||||
((PXUSB_REQUEST_NOTIFICATION)lpPayloadBuffer)->SmallMotor,
|
||||
((PXUSB_REQUEST_NOTIFICATION)lpPayloadBuffer)->LedNumber
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
void ProcessNotificationRequest(PVIGEM_CLIENT client, PVIGEM_TARGET target) override
|
||||
{
|
||||
if (target->Notification != nullptr)
|
||||
PFN_VIGEM_DS4_NOTIFICATION(target->Notification)(client, target,
|
||||
PFN_VIGEM_DS4_NOTIFICATION(target->Notification)(client, target, target->NotificationUserData,
|
||||
((PDS4_REQUEST_NOTIFICATION)lpPayloadBuffer)->Report.LargeMotor,
|
||||
((PDS4_REQUEST_NOTIFICATION)lpPayloadBuffer)->Report.SmallMotor,
|
||||
((PDS4_REQUEST_NOTIFICATION)lpPayloadBuffer)->Report.LightbarColor
|
||||
@@ -658,7 +658,8 @@ void vigem_notification_thread_worker(
|
||||
VIGEM_ERROR vigem_target_x360_register_notification(
|
||||
PVIGEM_CLIENT vigem,
|
||||
PVIGEM_TARGET target,
|
||||
PFN_VIGEM_X360_NOTIFICATION notification
|
||||
PFN_VIGEM_X360_NOTIFICATION notification,
|
||||
LPVOID userData
|
||||
)
|
||||
{
|
||||
if (!vigem)
|
||||
@@ -677,6 +678,7 @@ VIGEM_ERROR vigem_target_x360_register_notification(
|
||||
return VIGEM_ERROR_CALLBACK_ALREADY_REGISTERED;
|
||||
|
||||
target->Notification = reinterpret_cast<FARPROC>(notification);
|
||||
target->NotificationUserData = userData;
|
||||
|
||||
if (target->cancelNotificationThreadEvent == 0)
|
||||
target->cancelNotificationThreadEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
|
||||
@@ -704,7 +706,8 @@ VIGEM_ERROR vigem_target_x360_register_notification(
|
||||
VIGEM_ERROR vigem_target_ds4_register_notification(
|
||||
PVIGEM_CLIENT vigem,
|
||||
PVIGEM_TARGET target,
|
||||
PFN_VIGEM_DS4_NOTIFICATION notification
|
||||
PFN_VIGEM_DS4_NOTIFICATION notification,
|
||||
LPVOID userData
|
||||
)
|
||||
{
|
||||
if (!vigem)
|
||||
@@ -723,6 +726,7 @@ VIGEM_ERROR vigem_target_ds4_register_notification(
|
||||
return VIGEM_ERROR_CALLBACK_ALREADY_REGISTERED;
|
||||
|
||||
target->Notification = reinterpret_cast<FARPROC>(notification);
|
||||
target->NotificationUserData = userData;
|
||||
|
||||
if (target->cancelNotificationThreadEvent == 0)
|
||||
target->cancelNotificationThreadEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
|
||||
@@ -767,6 +771,7 @@ void vigem_target_x360_unregister_notification(PVIGEM_TARGET target)
|
||||
}
|
||||
|
||||
target->Notification = nullptr;
|
||||
target->NotificationUserData = nullptr;
|
||||
}
|
||||
|
||||
void vigem_target_ds4_unregister_notification(PVIGEM_TARGET target)
|
||||
|
||||
Reference in New Issue
Block a user