Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Konami DDR Pad #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 45 additions & 8 deletions Xb2XInput/XboxController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ std::vector<std::pair<int, int>> xbox_devices =
{0x0F30, 0x0202}, // Joytech Advanced Controller
{0x0F30, 0x8888}, // BigBen XBMiniPad Controller
{0x102C, 0xFF0C}, // Joytech Wireless Advanced Controller
{0x12AB, 0x0004}, // Konami DDR Pad
{0x12AB, 0x8809}, // Konami DDR Pad
{0xFFFF, 0xFFFF}, // PowerWave Xbox Controller (The ID's may look sketchy but this controller actually uses it)
};

Expand Down Expand Up @@ -393,14 +395,32 @@ void CALLBACK XboxController::OnVigemNotification(PVIGEM_CLIENT Client, PVIGEM_T
LargeMotor = SmallMotor = 0;

memset(&controller.output_prev_, 0, sizeof(XboxOutputReport));
controller.output_prev_.bSize = sizeof(XboxOutputReport);
controller.output_prev_.bReportId = XBOX_OUTPUT_REPORT_ID_RUMBLE;
controller.output_prev_.bSize = 2 + sizeof(controller.output_prev_.Rumble);
controller.output_prev_.Rumble.wLeftMotorSpeed = _byteswap_ushort(LargeMotor); // why do these need to be byteswapped???
controller.output_prev_.Rumble.wRightMotorSpeed = _byteswap_ushort(SmallMotor);

{
std::lock_guard<std::mutex> guard(usb_mutex_);
libusb_control_transfer(controller.usb_handle_, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
HID_SET_REPORT, (HID_REPORT_TYPE_OUTPUT << 8) | 0x00, 0, (unsigned char*)&controller.output_prev_, sizeof(XboxOutputReport), 1000);
HID_SET_REPORT, (HID_REPORT_TYPE_OUTPUT << 8) | 0x00, 0, (unsigned char*)&controller.output_prev_, controller.output_prev_.bSize, 1000);
}

memset(&controller.output_prev_, 0, sizeof(XboxOutputReport));
controller.output_prev_.bReportId = XBOX_OUTPUT_REPORT_ID_LED;
controller.output_prev_.bSize = 2 + sizeof(controller.output_prev_.LED);
switch (LedNumber) {
case 0: controller.output_prev_.LED.bAnimationId = LED_ANIMATION_ID_ON_1; break;
case 1: controller.output_prev_.LED.bAnimationId = LED_ANIMATION_ID_ON_2; break;
case 2: controller.output_prev_.LED.bAnimationId = LED_ANIMATION_ID_ON_3; break;
case 3: controller.output_prev_.LED.bAnimationId = LED_ANIMATION_ID_ON_4; break;
default: controller.output_prev_.LED.bAnimationId = LED_ANIMATION_ID_ALL_OFF;
}

{
std::lock_guard<std::mutex> guard(usb_mutex_);
libusb_control_transfer(controller.usb_handle_, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
HID_SET_REPORT, (HID_REPORT_TYPE_OUTPUT << 8) | 0x00, 0, (unsigned char*)&controller.output_prev_, controller.output_prev_.bSize, 1000);
}

break;
Expand Down Expand Up @@ -497,29 +517,46 @@ bool XboxController::update()

memset(&input_prev_, 0, sizeof(XboxInputReport));
int length = 0;
int ret = -1;

// if we have interrupt endpoints use those for better compatibility, otherwise fallback to control transfers
if (endpoint_in_)
{
extern int poll_ms;
ret = libusb_interrupt_transfer(usb_handle_, endpoint_in_, (unsigned char*)&input_prev_, sizeof(XboxInputReport), &length, poll_ms);
int ret = libusb_interrupt_transfer(usb_handle_, endpoint_in_, (unsigned char*)&input_prev_, sizeof(XboxInputReport), &length, poll_ms);
if (ret < 0)
return true; // No input available atm
{
if (ret == LIBUSB_ERROR_TIMEOUT)
return true; // No input available atm

dbgprintf(__FUNCTION__ ": libusb control transfer failed (code %d)", ret);
return false;
}
}
else
{
std::lock_guard<std::mutex> guard(usb_mutex_);
ret = libusb_control_transfer(usb_handle_, LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
length = libusb_control_transfer(usb_handle_, LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
HID_GET_REPORT, (HID_REPORT_TYPE_INPUT << 8) | 0x00, 0, (unsigned char*)&input_prev_, sizeof(XboxInputReport), 1000);

if (ret < 0)
if (length < 0)
{
dbgprintf(__FUNCTION__ ": libusb control transfer failed (code %d)", ret);
dbgprintf(__FUNCTION__ ": libusb control transfer failed (code %d)", length);
return false;
}
}

// Skip zero length packets
if (length == 0)
{
return true;
}

// Skip messages other than a controller update
if (input_prev_.bReportId != 0)
{
return true;
}

if (input_prev_.bSize != sizeof(XboxInputReport))
{
dbgprintf(__FUNCTION__ ": controller returned invalid report size %d (expected %d)", input_prev_.bSize, sizeof(XboxInputReport));
Expand Down
17 changes: 16 additions & 1 deletion Xb2XInput/XboxController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,26 @@ struct XboxInputReport {
OGXINPUT_GAMEPAD Gamepad;
};

#define XBOX_OUTPUT_REPORT_ID_RUMBLE 0
#define XBOX_OUTPUT_REPORT_ID_LED 1
#define LED_ANIMATION_ID_ALL_OFF 0
#define LED_ANIMATION_ID_ON_1 6
#define LED_ANIMATION_ID_ON_2 7
#define LED_ANIMATION_ID_ON_3 8
#define LED_ANIMATION_ID_ON_4 9

struct XboxOutputReportLED {
BYTE bAnimationId;
};

struct XboxOutputReport {
BYTE bReportId;
BYTE bSize;

OGXINPUT_RUMBLE Rumble;
union {
OGXINPUT_RUMBLE Rumble;
XboxOutputReportLED LED;
};
};

struct Deadzone {
Expand Down
2 changes: 2 additions & 0 deletions dist/x64/Drivers/install drivers.bat
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ wdi-simple --vid 0x0F30 --pid 0x0202 --type 0 --name "Joytech Advanced Controlle
wdi-simple --vid 0x0F30 --pid 0x8888 --type 0 --name "BigBen XBMiniPad Controller"
wdi-simple --vid 0x102C --pid 0xFF0C --type 0 --name "Joytech Wireless Advanced Controller"
wdi-simple --vid 0x0738 --pid 0x4522 --type 0 --name "MadCatz LumiCON"
wdi-simple --vid 0x12AB --pid 0x0004 --type 0 --name "Konami DDR Pad"
wdi-simple --vid 0x12AB --pid 0x8809 --type 0 --name "Konami DDR Pad"
wdi-simple --vid 0xFFFF --pid 0xFFFF --type 0 --name "PowerWave Xbox Controller"

echo Driver installation complete!
Expand Down
2 changes: 2 additions & 0 deletions dist/x86/Drivers/install drivers.bat
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ wdi-simple --vid 0x0F30 --pid 0x0202 --type 0 --name "Joytech Advanced Controlle
wdi-simple --vid 0x0F30 --pid 0x8888 --type 0 --name "BigBen XBMiniPad Controller"
wdi-simple --vid 0x102C --pid 0xFF0C --type 0 --name "Joytech Wireless Advanced Controller"
wdi-simple --vid 0x0738 --pid 0x4522 --type 0 --name "MadCatz LumiCON"
wdi-simple --vid 0x12AB --pid 0x0004 --type 0 --name "Konami DDR Pad"
wdi-simple --vid 0x12AB --pid 0x8809 --type 0 --name "Konami DDR Pad"
wdi-simple --vid 0xFFFF --pid 0xFFFF --type 0 --name "PowerWave Xbox Controller"

echo Driver installation complete!
Expand Down