Modified bluedot driver to use HidDevice class
This commit is contained in:
@@ -4,51 +4,38 @@
|
||||
|
||||
REGISTER_LIGHTS_DRIVER_CLASS(HidBlueDot);
|
||||
|
||||
LightsDriver_HidBlueDot::LightsDriver_HidBlueDot()
|
||||
LightsDriver_HidBlueDot::LightsDriver_HidBlueDot() : dev{VID, PID}
|
||||
{
|
||||
memset(m_iCabData, 0x00, sizeof(m_iCabData));
|
||||
memset(m_iPadData, 0x00, sizeof(m_iPadData));
|
||||
|
||||
m_iCabData[1] = 0x01;
|
||||
m_iPadData[1] = 0x02;
|
||||
|
||||
// Open the device using the VID, PID,
|
||||
// and optionally the Serial number.
|
||||
handle = hid_open(VID, PID, NULL);
|
||||
|
||||
if (!handle) {
|
||||
LOG->Warn("HID BlueDot device not found.");
|
||||
hid_exit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LightsDriver_HidBlueDot::~LightsDriver_HidBlueDot()
|
||||
{
|
||||
// Close the device
|
||||
hid_close(handle);
|
||||
|
||||
// Finalize the hidapi library
|
||||
hid_exit();
|
||||
}
|
||||
|
||||
void LightsDriver_HidBlueDot::SetPadLight(PadLightIndex index, bool value)
|
||||
{
|
||||
m_iPadData[2] &= ~(1 << index);
|
||||
m_iPadData[2] |= (1 << index);
|
||||
};
|
||||
|
||||
void LightsDriver_HidBlueDot::SetCabinetLight(CabinetLightIndex index, bool value)
|
||||
{
|
||||
m_iCabData[2] &= ~(1 << index);
|
||||
m_iCabData[2] |= (1 << index);
|
||||
SetLight((unsigned char*)m_iCabData, (int)index, value);
|
||||
};
|
||||
|
||||
void LightsDriver_HidBlueDot::SetPadLight(PadLightIndex index, bool value)
|
||||
{
|
||||
SetLight((unsigned char*)m_iPadData, (int)index, value);
|
||||
};
|
||||
|
||||
void LightsDriver_HidBlueDot::SetLight(unsigned char* buffer, int index, bool value)
|
||||
{
|
||||
buffer[2] &= ~(1 << index);
|
||||
buffer[2] |= (1 << index);
|
||||
};
|
||||
|
||||
void LightsDriver_HidBlueDot::Set(const LightsState *ls)
|
||||
{
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
//! Set cabinet lights.
|
||||
SetCabinetLight(m_Marquee_UpLeft, ls->m_bCabinetLights[LIGHT_MARQUEE_UP_LEFT]);
|
||||
SetCabinetLight(m_Marquee_UpRight, ls->m_bCabinetLights[LIGHT_MARQUEE_UP_RIGHT]);
|
||||
@@ -57,8 +44,8 @@ void LightsDriver_HidBlueDot::Set(const LightsState *ls)
|
||||
SetCabinetLight(m_Buttons_Left, ls->m_bGameButtonLights[PLAYER_1][GAME_BUTTON_START]);
|
||||
SetCabinetLight(m_Buttons_Right, ls->m_bGameButtonLights[PLAYER_2][GAME_BUTTON_START]);
|
||||
SetCabinetLight(m_Bass, ls->m_bCabinetLights[LIGHT_BASS_LEFT] || ls->m_bCabinetLights[LIGHT_BASS_RIGHT]);
|
||||
|
||||
hid_write(handle, (unsigned char *)&m_iCabData, 3);
|
||||
|
||||
dev.Write((unsigned char*)&m_iCabData, 3);
|
||||
|
||||
//! Set pad lights.
|
||||
SetPadLight(m_PadP1_Left, ls->m_bGameButtonLights[PLAYER_1][DANCE_BUTTON_LEFT]);
|
||||
@@ -70,5 +57,5 @@ void LightsDriver_HidBlueDot::Set(const LightsState *ls)
|
||||
SetPadLight(m_PadP2_Up, ls->m_bGameButtonLights[PLAYER_2][DANCE_BUTTON_UP]);
|
||||
SetPadLight(m_PadP2_Down, ls->m_bGameButtonLights[PLAYER_2][DANCE_BUTTON_DOWN]);
|
||||
|
||||
hid_write(handle, (unsigned char *)&m_iPadData, 3);
|
||||
dev.Write((unsigned char*)&m_iPadData, 3);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define LightsDriver_HidBlueDot_H
|
||||
|
||||
#include "arch/Lights/LightsDriver.h"
|
||||
#include "hidapi.h"
|
||||
#include "archutils/Common/HidDevice.h"
|
||||
|
||||
#define VID 0x04BD
|
||||
#define PID 0xBD
|
||||
@@ -35,8 +35,9 @@ private:
|
||||
|
||||
uint8_t m_iCabData[3];
|
||||
uint8_t m_iPadData[3];
|
||||
hid_device* handle;
|
||||
HidDevice dev;
|
||||
|
||||
void SetLight(unsigned char* buffer, int index, bool value);
|
||||
void SetPadLight(PadLightIndex index, bool value);
|
||||
void SetCabinetLight(CabinetLightIndex index, bool value);
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user