Fixed wrong SBC subtype + fixed off by two bytes rumble struct + removed rumble hack + switched to interrupt transfers
This commit is contained in:
parent
1886819a35
commit
5a01ce5297
|
@ -420,7 +420,7 @@ bool InputDeviceManager::UpdateInputXpad(std::shared_ptr<InputDevice>& Device, v
|
|||
return false;
|
||||
}
|
||||
|
||||
XpadInput* in_buf = reinterpret_cast<XpadInput*>(static_cast<uint8_t*>(Buffer) + 2);
|
||||
XpadInput* in_buf = reinterpret_cast<XpadInput*>(static_cast<uint8_t*>(Buffer) + XID_PACKET_HEADER);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ControlState state = (bindings[i] != nullptr) ? dynamic_cast<InputDevice::Input*>(bindings[i])->GetState() : 0.0;
|
||||
if (state) {
|
||||
|
@ -463,7 +463,7 @@ bool InputDeviceManager::UpdateInputXpad(std::shared_ptr<InputDevice>& Device, v
|
|||
}
|
||||
else {
|
||||
if (bindings[24] != nullptr) {
|
||||
XpadOutput* out_buf = reinterpret_cast<XpadOutput*>(static_cast<uint8_t*>(Buffer) + 2);
|
||||
XpadOutput* out_buf = reinterpret_cast<XpadOutput*>(static_cast<uint8_t*>(Buffer) + XID_PACKET_HEADER);
|
||||
dynamic_cast<InputDevice::Output*>(bindings[24])->SetState(out_buf->left_actuator_strength / static_cast<ControlState>(0xFFFF),
|
||||
out_buf->right_actuator_strength / static_cast<ControlState>(0xFFFF));
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ bool InputDeviceManager::UpdateInputSBC(std::shared_ptr<InputDevice>& Device, vo
|
|||
// 9 -> GearLever Up
|
||||
// 10 -> GearLever Down
|
||||
static uint16_t last_in_state[XBOX_NUM_PORTS] = { 0, 0, 0, 0 };
|
||||
SBCInput *in_buf = reinterpret_cast<SBCInput *>(static_cast<uint8_t *>(Buffer) + 2);
|
||||
SBCInput *in_buf = reinterpret_cast<SBCInput *>(static_cast<uint8_t *>(Buffer) + XID_PACKET_HEADER);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ControlState state = (bindings[i] != nullptr) ? dynamic_cast<InputDevice::Input *>(bindings[i])->GetState() : 0.0;
|
||||
if (state) {
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#define MU_OFFSET 4
|
||||
#define MAX_DEVS (XBOX_NUM_PORTS + XBOX_CTRL_NUM_SLOTS * XBOX_NUM_PORTS)
|
||||
|
||||
#define XID_PACKET_HEADER 2
|
||||
|
||||
extern int dev_num_buttons[to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)];
|
||||
|
||||
inline XBOX_INPUT_DEVICE input_support_list[] = {
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
#include "core\kernel\support\Emu.h"
|
||||
#include "core\hle\XAPI\Xapi.h"
|
||||
|
||||
// Sanitiy check: ensure out libusb version is high enough for libusb_get_device_descriptor to succeed
|
||||
static_assert(LIBUSB_API_VERSION >= 0x01000102);
|
||||
// Sanitiy check: ensure out libusb version is high enough for libusb_get_device_descriptor to succeed and to pass nullptr to libusb_interrupt_transfer
|
||||
static_assert(LIBUSB_API_VERSION >= 0x01000105);
|
||||
|
||||
|
||||
namespace Libusb
|
||||
|
@ -162,7 +162,7 @@ namespace Libusb
|
|||
if ((Desc->idVendor == 0x0a7b) && (Desc->idProduct == 0xd000)) {
|
||||
m_Type = XBOX_INPUT_DEVICE::HW_STEEL_BATTALION_CONTROLLER;
|
||||
m_UcType = XINPUT_DEVTYPE_STEELBATTALION;
|
||||
m_UcSubType = XINPUT_DEVSUBTYPE_GC_GAMEPAD_ALT;
|
||||
m_UcSubType = XINPUT_DEVSUBTYPE_GC_GAMEPAD;
|
||||
m_Name = "Steel battalion controller";
|
||||
m_BufferInSize = sizeof(XidSBCInput);
|
||||
m_BufferOutSize = sizeof(XidSBCOutput);
|
||||
|
@ -283,30 +283,22 @@ namespace Libusb
|
|||
|
||||
bool LibusbDevice::ExecuteIo(void *Buffer, int Direction)
|
||||
{
|
||||
// NOTE: a SET_REPORT control transfer to the SBC doesn't seem to work, the parameters might not be appropriate for it... So, we use
|
||||
// the interrupt pipes for everything instead
|
||||
*static_cast<uint8_t *>(Buffer) = 0; // write bReportId
|
||||
if (Direction == DIRECTION_IN) {
|
||||
*(static_cast<uint8_t *>(Buffer) + 1) = m_BufferInSize; // write bLength
|
||||
// submit a GET_REPORT request
|
||||
if (libusb_control_transfer(m_hDev, 0xA1, 1, 0x0100, m_IfaceNum, static_cast<uint8_t *>(Buffer), m_BufferInSize, m_IntervalIn) == m_BufferInSize) {
|
||||
if (libusb_interrupt_transfer(m_hDev, m_EndpointIn, static_cast<uint8_t *>(Buffer), m_BufferInSize, nullptr, m_IntervalIn) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_HasEndpointOut) {
|
||||
*(static_cast<uint8_t *>(Buffer) + 1) = m_BufferOutSize; // write bLength
|
||||
// https://github.com/libusb/libusb/blob/f33c9562a1dd7a0cb333fcd9a670ba14fbbfbc0e/examples/xusb.c#L300
|
||||
// For some reason libusb seems to require to constraint the actuator strenght to 0-255
|
||||
if (m_Type == XBOX_INPUT_DEVICE::HW_XBOX_CONTROLLER) {
|
||||
XidGamepadOutput *OutBuffer = static_cast<XidGamepadOutput *>(Buffer);
|
||||
OutBuffer->OutBuffer.left_actuator_strength = (OutBuffer->OutBuffer.left_actuator_strength >> 8);
|
||||
OutBuffer->OutBuffer.right_actuator_strength = (OutBuffer->OutBuffer.right_actuator_strength >> 8);
|
||||
}
|
||||
// submit a SET_REPORT request
|
||||
if (libusb_control_transfer(m_hDev, 0x21, 9, 0x0200, m_IfaceNum, static_cast<uint8_t *>(Buffer), m_BufferOutSize, m_IntervalOut) == m_BufferOutSize) {
|
||||
if (libusb_interrupt_transfer(m_hDev, m_EndpointOut, static_cast<uint8_t *>(Buffer), m_BufferOutSize, nullptr, m_IntervalOut) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -264,7 +264,7 @@ void ConstructHleInputDevice(DeviceState *dev, DeviceState *upstream, int type,
|
|||
dev->info.buff.sbc.InBuffer.sAimingY = static_cast<uint8_t>(0x7F);
|
||||
dev->info.bAutoPollDefault = true;
|
||||
dev->info.ucType = XINPUT_DEVTYPE_STEELBATTALION;
|
||||
dev->info.ucSubType = XINPUT_DEVSUBTYPE_GC_GAMEPAD_ALT;
|
||||
dev->info.ucSubType = XINPUT_DEVSUBTYPE_GC_GAMEPAD;
|
||||
dev->info.ucInputStateSize = sizeof(SBCInput);
|
||||
dev->info.ucFeedbackSize = sizeof(SBCOutput);
|
||||
if (type == to_underlying(XBOX_INPUT_DEVICE::HW_STEEL_BATTALION_CONTROLLER)) {
|
||||
|
@ -773,7 +773,7 @@ xbox::dword_xt WINAPI xbox::EMUPATCH(XInputSetState)
|
|||
int port = dev->port_idx;
|
||||
if (g_devs[port].info.hHandle == hDevice && !g_devs[port].bPendingRemoval) {
|
||||
pFeedback->Header.dwStatus = ERROR_IO_PENDING;
|
||||
g_InputDeviceManager.UpdateXboxPortInput(port, (void*)&pFeedback->Rumble, DIRECTION_OUT, to_underlying(g_devs[port].type));
|
||||
g_InputDeviceManager.UpdateXboxPortInput(port, (void*)&pFeedback->Header.bReportId, DIRECTION_OUT, to_underlying(g_devs[port].type));
|
||||
pFeedback->Header.dwStatus = ERROR_SUCCESS;
|
||||
if (pFeedback->Header.hEvent != NULL &&
|
||||
ObReferenceObjectByHandle(pFeedback->Header.hEvent, &xbox::ExEventObjectType, (PVOID*)&pFeedback->Header.IoCompletedEvent) == ERROR_SUCCESS) {
|
||||
|
|
|
@ -214,7 +214,6 @@ XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
|
|||
// ******************************************************************
|
||||
//general GAMEPAD uses subtype 0x01.
|
||||
#define XINPUT_DEVSUBTYPE_GC_GAMEPAD 0x01
|
||||
//SteelBatallion controller uses subtype 0x02
|
||||
#define XINPUT_DEVSUBTYPE_GC_GAMEPAD_ALT 0x02
|
||||
#define XINPUT_DEVSUBTYPE_GC_WHEEL 0x10
|
||||
#define XINPUT_DEVSUBTYPE_GC_ARCADE_STICK 0x20
|
||||
|
@ -243,16 +242,18 @@ XINPUT_STATE, *PXINPUT_STATE;
|
|||
// ******************************************************************
|
||||
// * XINPUT_FEEDBACK_HEADER
|
||||
// ******************************************************************
|
||||
#include "AlignPrefix1.h"
|
||||
#pragma pack(1)
|
||||
typedef struct _XINPUT_FEEDBACK_HEADER
|
||||
{
|
||||
xbox::dword_xt dwStatus;
|
||||
xbox::dword_xt dwStatus;
|
||||
HANDLE OPTIONAL hEvent;
|
||||
xbox::byte_xt Unknown1[4];
|
||||
xbox::byte_xt Unknown1[4];
|
||||
PVOID IoCompletedEvent; // PKEVENT really
|
||||
xbox::byte_xt Unknown2[50];
|
||||
xbox::byte_xt Unknown2[48];
|
||||
xbox::byte_xt bReportId;
|
||||
xbox::byte_xt bLength;
|
||||
}
|
||||
#include "AlignPosfix1.h"
|
||||
|
||||
XINPUT_FEEDBACK_HEADER, *PXINPUT_FEEDBACK_HEADER;
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -268,7 +269,7 @@ typedef struct _XINPUT_FEEDBACK
|
|||
};
|
||||
}
|
||||
XINPUT_FEEDBACK, *PXINPUT_FEEDBACK;
|
||||
|
||||
#pragma pack()
|
||||
// ******************************************************************
|
||||
// * RTL_HEAP_PARAMETERS
|
||||
// ******************************************************************
|
||||
|
|
|
@ -137,9 +137,9 @@ void LibusbInputWindow::TestInput()
|
|||
bool detect = false;
|
||||
while (now <= timeout) {
|
||||
LibusbDev->ExecuteIo(buffer, DIRECTION_IN);
|
||||
if (std::memcmp(reinterpret_cast<uint8_t *>(buffer) + 2,
|
||||
reinterpret_cast<uint8_t *>(&buffer[1]) + 2,
|
||||
sizeof(InputBuff) - 2)) {
|
||||
if (std::memcmp(reinterpret_cast<uint8_t *>(buffer) + XID_PACKET_HEADER,
|
||||
reinterpret_cast<uint8_t *>(&buffer[1]) + XID_PACKET_HEADER,
|
||||
sizeof(InputBuff) - XID_PACKET_HEADER)) {
|
||||
detect = true;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue