mirror of https://github.com/AxioDL/boo.git
* More DS3 work
This commit is contained in:
parent
2234d7f143
commit
4d644327cd
|
@ -24,7 +24,7 @@ public:
|
||||||
virtual ~CDeviceBase();
|
virtual ~CDeviceBase();
|
||||||
void closeDevice();
|
void closeDevice();
|
||||||
virtual void deviceDisconnected()=0;
|
virtual void deviceDisconnected()=0;
|
||||||
virtual void deviceError(const char* error) {fprintf(stderr, "%s\n", error);}
|
virtual void deviceError(const char* error, ...);
|
||||||
|
|
||||||
/* Low-Level API */
|
/* Low-Level API */
|
||||||
bool sendUSBInterruptTransfer(uint8_t pipe, const uint8_t* data, size_t length);
|
bool sendUSBInterruptTransfer(uint8_t pipe, const uint8_t* data, size_t length);
|
||||||
|
|
|
@ -30,7 +30,9 @@ union SDualshockOutReport
|
||||||
{
|
{
|
||||||
uint8_t reportId;
|
uint8_t reportId;
|
||||||
SDualshockRumble rumble;
|
SDualshockRumble rumble;
|
||||||
uint8_t padding[4];
|
uint8_t gyro1;
|
||||||
|
uint8_t gyro2;
|
||||||
|
uint8_t padding[2];
|
||||||
uint8_t leds;
|
uint8_t leds;
|
||||||
SDualshockLED led[4];
|
SDualshockLED led[4];
|
||||||
SDualshockLED reserved;
|
SDualshockLED reserved;
|
||||||
|
@ -102,6 +104,7 @@ struct SDualshockControllerState
|
||||||
uint8_t m_reserved5[9];
|
uint8_t m_reserved5[9];
|
||||||
uint16_t m_accelerometer[3];
|
uint16_t m_accelerometer[3];
|
||||||
uint16_t m_gyrometerZ;
|
uint16_t m_gyrometerZ;
|
||||||
|
// INTERNAL, set by libBoo, do not modify directly!
|
||||||
float accPitch;
|
float accPitch;
|
||||||
float accYaw;
|
float accYaw;
|
||||||
float gyroZ;
|
float gyroZ;
|
||||||
|
@ -112,7 +115,7 @@ struct IDualshockControllerCallback
|
||||||
{
|
{
|
||||||
CDualshockController* ctrl = nullptr;
|
CDualshockController* ctrl = nullptr;
|
||||||
virtual void controllerDisconnected() {}
|
virtual void controllerDisconnected() {}
|
||||||
virtual void controllerUpdate(const SDualshockControllerState& state) {}
|
virtual void controllerUpdate(const SDualshockControllerState&) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDualshockController final : public CDeviceBase
|
class CDualshockController final : public CDeviceBase
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "inputdev/CDeviceBase.hpp"
|
#include "inputdev/CDeviceBase.hpp"
|
||||||
#include "inputdev/CDeviceToken.hpp"
|
#include "inputdev/CDeviceToken.hpp"
|
||||||
#include "IHIDDevice.hpp"
|
#include "IHIDDevice.hpp"
|
||||||
|
#include <cstdarg>
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
||||||
|
@ -33,6 +34,14 @@ void CDeviceBase::closeDevice()
|
||||||
m_token->_deviceClose();
|
m_token->_deviceClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDeviceBase::deviceError(const char* error, ...)
|
||||||
|
{
|
||||||
|
va_list vl;
|
||||||
|
va_start(vl, error);
|
||||||
|
vfprintf(stderr, error, vl);
|
||||||
|
va_end(vl);
|
||||||
|
}
|
||||||
|
|
||||||
bool CDeviceBase::sendUSBInterruptTransfer(uint8_t pipe, const uint8_t* data, size_t length)
|
bool CDeviceBase::sendUSBInterruptTransfer(uint8_t pipe, const uint8_t* data, size_t length)
|
||||||
{
|
{
|
||||||
if (m_hidDev)
|
if (m_hidDev)
|
||||||
|
|
|
@ -29,8 +29,7 @@ void hexdump(void *ptr, int buflen) {
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
||||||
static const uint8_t defaultReport[35] = {
|
static const uint8_t defaultReport[35] = {
|
||||||
0x01,
|
0x01, 0xff, 0x00, 0xff, 0x00,
|
||||||
0xff, 0x00, 0xff, 0x00,
|
|
||||||
0xff, 0x80, 0x00, 0x00, 0x00,
|
0xff, 0x80, 0x00, 0x00, 0x00,
|
||||||
0xff, 0x27, 0x10, 0x00, 0x32,
|
0xff, 0x27, 0x10, 0x00, 0x32,
|
||||||
0xff, 0x27, 0x10, 0x00, 0x32,
|
0xff, 0x27, 0x10, 0x00, 0x32,
|
||||||
|
@ -62,7 +61,11 @@ void CDualshockController::deviceDisconnected()
|
||||||
void CDualshockController::initialCycle()
|
void CDualshockController::initialCycle()
|
||||||
{
|
{
|
||||||
uint8_t setupCommand[4] = {0x42, 0x0c, 0x00, 0x00}; //Tells controller to start sending changes on in pipe
|
uint8_t setupCommand[4] = {0x42, 0x0c, 0x00, 0x00}; //Tells controller to start sending changes on in pipe
|
||||||
sendHIDReport(setupCommand, sizeof(setupCommand), 0x03F4);
|
if (!sendHIDReport(setupCommand, sizeof(setupCommand), 0x03F4))
|
||||||
|
{
|
||||||
|
deviceError("Unable to send complete packet! Request size %x\n", sizeof(setupCommand));
|
||||||
|
return;
|
||||||
|
}
|
||||||
uint8_t btAddr[8];
|
uint8_t btAddr[8];
|
||||||
receiveReport(btAddr, sizeof(btAddr), 0x03F5);
|
receiveReport(btAddr, sizeof(btAddr), 0x03F5);
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
|
@ -113,9 +116,9 @@ void CDualshockController::transferCycle()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (state.m_reserved5[8] == 0xC0)
|
if (state.m_reserved5[8] & 0x80)
|
||||||
m_rumbleRequest &= ~DS3_MOTOR_RIGHT;
|
m_rumbleRequest &= ~DS3_MOTOR_RIGHT;
|
||||||
if (state.m_reserved5[7] == 0x01)
|
if (state.m_reserved5[7] & 0x01)
|
||||||
m_rumbleRequest &= ~DS3_MOTOR_LEFT;
|
m_rumbleRequest &= ~DS3_MOTOR_LEFT;
|
||||||
m_rumbleState = m_rumbleRequest;
|
m_rumbleState = m_rumbleRequest;
|
||||||
const double zeroG = 511.5; // 1.65/3.3*1023 (1,65V);
|
const double zeroG = 511.5; // 1.65/3.3*1023 (1,65V);
|
||||||
|
|
|
@ -47,7 +47,7 @@ class CHIDListenerUdev final : public IHIDListener
|
||||||
|
|
||||||
int vid = 0, pid = 0;
|
int vid = 0, pid = 0;
|
||||||
udev_list_entry* attrs = udev_device_get_properties_list_entry(device);
|
udev_list_entry* attrs = udev_device_get_properties_list_entry(device);
|
||||||
#if 0
|
#if 1
|
||||||
udev_list_entry* att = NULL;
|
udev_list_entry* att = NULL;
|
||||||
udev_list_entry_foreach(att, attrs)
|
udev_list_entry_foreach(att, attrs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,6 +73,7 @@ class CDualshockControllerCallback : public IDualshockControllerCallback
|
||||||
/*
|
/*
|
||||||
else
|
else
|
||||||
ctrl->stopRumble(DS3_MOTOR_RIGHT | DS3_MOTOR_LEFT);*/
|
ctrl->stopRumble(DS3_MOTOR_RIGHT | DS3_MOTOR_LEFT);*/
|
||||||
|
|
||||||
printf("CONTROLLER UPDATE %d %d\n", state.m_leftStick[0], state.m_leftStick[1]);
|
printf("CONTROLLER UPDATE %d %d\n", state.m_leftStick[0], state.m_leftStick[1]);
|
||||||
printf(" %d %d\n", state.m_rightStick[0], state.m_rightStick[1]);
|
printf(" %d %d\n", state.m_rightStick[0], state.m_rightStick[1]);
|
||||||
printf(" %f %f %f\n", state.accPitch, state.accYaw, state.gyroZ);
|
printf(" %f %f %f\n", state.accPitch, state.accYaw, state.gyroZ);
|
||||||
|
|
Loading…
Reference in New Issue