mirror of
https://github.com/nefarius/ViGEmBus.git
synced 2025-08-10 00:52:17 +00:00
No comment
This commit is contained in:
@@ -55,12 +55,15 @@ SOFTWARE.
|
||||
#include <ratio>
|
||||
#include <thread>
|
||||
|
||||
#include "Internal.h"
|
||||
|
||||
#include "NotificationRequestPool.h"
|
||||
|
||||
//
|
||||
// TODO: this is... not optimal. Improve in the future.
|
||||
//
|
||||
#define VIGEM_TARGETS_MAX USHRT_MAX
|
||||
|
||||
#define VIGEM_INVERTED_CALL_THREAD_COUNT 20
|
||||
|
||||
|
||||
typedef BOOL(WINAPI *MINIDUMPWRITEDUMP)(
|
||||
@@ -75,45 +78,7 @@ typedef BOOL(WINAPI *MINIDUMPWRITEDUMP)(
|
||||
|
||||
LONG WINAPI vigem_internal_exception_handler(struct _EXCEPTION_POINTERS* apExceptionInfo);
|
||||
|
||||
//
|
||||
// Represents a driver connection object.
|
||||
//
|
||||
typedef struct _VIGEM_CLIENT_T
|
||||
{
|
||||
HANDLE hBusDevice;
|
||||
|
||||
} VIGEM_CLIENT;
|
||||
|
||||
//
|
||||
// Represents the (connection) state of a target device object.
|
||||
//
|
||||
typedef enum _VIGEM_TARGET_STATE
|
||||
{
|
||||
VIGEM_TARGET_NEW,
|
||||
VIGEM_TARGET_INITIALIZED,
|
||||
VIGEM_TARGET_CONNECTED,
|
||||
VIGEM_TARGET_DISCONNECTED
|
||||
} VIGEM_TARGET_STATE, *PVIGEM_TARGET_STATE;
|
||||
|
||||
//
|
||||
// Represents a virtual gamepad object.
|
||||
//
|
||||
typedef struct _VIGEM_TARGET_T
|
||||
{
|
||||
ULONG Size;
|
||||
ULONG SerialNo;
|
||||
VIGEM_TARGET_STATE State;
|
||||
USHORT VendorId;
|
||||
USHORT ProductId;
|
||||
VIGEM_TARGET_TYPE Type;
|
||||
DWORD_PTR Notification;
|
||||
|
||||
boost::shared_ptr<boost::asio::io_service> io_svc;
|
||||
boost::shared_ptr<boost::asio::io_service::work> worker;
|
||||
boost::shared_ptr<boost::thread_group> worker_threads;
|
||||
boost::shared_ptr<boost::mutex> enqueue_lock;
|
||||
|
||||
} VIGEM_TARGET;
|
||||
|
||||
//
|
||||
// Initializes a virtual gamepad object.
|
||||
@@ -138,6 +103,9 @@ PVIGEM_TARGET FORCEINLINE VIGEM_TARGET_ALLOC_INIT(
|
||||
target->worker_threads.reset(new boost::thread_group());
|
||||
target->enqueue_lock.reset(new boost::mutex());
|
||||
|
||||
for (auto& WaitHandle : target->WaitHandles)
|
||||
WaitHandle = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -625,8 +593,26 @@ VIGEM_ERROR vigem_target_x360_register_notification(
|
||||
|
||||
target->Notification = reinterpret_cast<DWORD_PTR>(notification);
|
||||
|
||||
for (int i = 1; i <= VIGEM_INVERTED_CALL_THREAD_COUNT; i++)
|
||||
target->worker_threads->create_thread(boost::bind(&vigem_internal_x360_notification_worker, target, vigem));
|
||||
//for (auto i = 0; i < /* VIGEM_INVERTED_CALL_THREAD_COUNT */ 1; i++)
|
||||
//{
|
||||
// auto req = new XusbNotificationRequest(
|
||||
// vigem->hBusDevice,
|
||||
// target->SerialNo,
|
||||
// target->WaitHandles[i]
|
||||
// );
|
||||
// target->notify_req.emplace_back(req);
|
||||
// //target->worker_threads->create_thread(*req);
|
||||
//}
|
||||
|
||||
target->pool = std::make_shared<NotificationRequestPool>(
|
||||
vigem->hBusDevice,
|
||||
target->SerialNo,
|
||||
PFN_VIGEM_X360_NOTIFICATION(target->Notification)
|
||||
);
|
||||
|
||||
|
||||
//for (int i = 1; i <= VIGEM_INVERTED_CALL_THREAD_COUNT; i++)
|
||||
// target->worker_threads->create_thread(boost::bind(&vigem_internal_x360_notification_worker, target, vigem));
|
||||
|
||||
return VIGEM_ERROR_NONE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user