Use hidapi wrapper for HyperX mousemat controller

This commit is contained in:
Adam Honse
2023-01-28 11:46:31 -06:00
parent e30fbdef71
commit 4c67d849b4
3 changed files with 18 additions and 14 deletions

View File

@@ -11,15 +11,16 @@
#include <cstring>
HyperXMousematController::HyperXMousematController(hid_device* dev_handle, const char* path)
HyperXMousematController::HyperXMousematController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, const char* path)
{
wrapper = hid_wrapper;
dev = dev_handle;
location = path;
}
HyperXMousematController::~HyperXMousematController()
{
hid_close(dev);
wrapper.hid_close(dev);
}
std::string HyperXMousematController::GetDeviceLocation()
@@ -30,7 +31,7 @@ std::string HyperXMousematController::GetDeviceLocation()
std::string HyperXMousematController::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
int ret = wrapper.hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
@@ -71,7 +72,7 @@ void HyperXMousematController::SendDirect
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 65);
wrapper.hid_send_feature_report(dev, buf, 65);
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -94,7 +95,7 @@ void HyperXMousematController::SendDirect
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 65);
wrapper.hid_send_feature_report(dev, buf, 65);
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -114,5 +115,5 @@ void HyperXMousematController::SendDirect
buf[(i * 4) + 4] = RGBGetBValue(color_data[16 + i]);
}
hid_send_feature_report(dev, buf, 65);
wrapper.hid_send_feature_report(dev, buf, 65);
}