Skip to content
Merged
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ add_executable(${PROJECT_NAME}
handlers/zuiki.c
handlers/santroller.c
handlers/b2l.c
handlers/ddr_grandprix.c

${PICO_TINYUSB_PATH}/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ make all -j$(nproc)
* icedragon.io Snek Board (DDR, GF, DM)
* StepManiaX
* LTEK
* Konami DDR GRAND PRIX Controller (BF110)
* Born to Lead (B2L)
* Gamo2 PHOENIXWAN
* RedOctane X-Plorer
Expand Down
5 changes: 5 additions & 0 deletions handlers/__handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "handlers/zuiki.h"
#include "handlers/santroller.h"
#include "handlers/b2l.h"
#include "handlers/ddr_grandprix.h"

uint64_t prev_output_report_time = 0;
uint64_t prev_btn_sampling_time = 0;
Expand Down Expand Up @@ -102,6 +103,10 @@ handler_type determine_handler(uint8_t dev_addr)
{
rtn = HANDLER_B2L;
}
else if (is_DDR_GRANDPRIX(dev_addr))
{
rtn = HANDLER_DDR_GRANDPRIX;
}

return rtn;
}
Expand Down
2 changes: 2 additions & 0 deletions handlers/__handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ typedef enum
HANDLER_B2L,
HANDLER_STAC2,

HANDLER_DDR_GRANDPRIX,

} handler_type;

handler_type determine_handler(uint8_t dev_addr);
Expand Down
33 changes: 33 additions & 0 deletions handlers/ddr_grandprix.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "ddr_grandprix.h"
#include <string.h>
#include "input_report.h"

bool is_DDR_GRANDPRIX(uint8_t dev_addr)
{
uint16_t vid, pid;
tuh_vid_pid_get(dev_addr, &vid, &pid);

return (vid == DDR_GRANDPRIX_VID && pid == DDR_GRANDPRIX_PID);
}

void processDDR_GRANDPRIX(uint8_t const *report, uint16_t len)
{
if (len >= sizeof(ddr_grandprix_report_t))
{
ddr_grandprix_report_t new_ddr_state = {0};
memcpy(&new_ddr_state, report, sizeof(new_ddr_state));

reset_report();

input_report.short_report.select = new_ddr_state.btn_l;
input_report.short_report.start = new_ddr_state.btn_r;

input_report.short_report.dpad_up = new_ddr_state.dpad_up;
input_report.short_report.dpad_right = new_ddr_state.dpad_right;
input_report.short_report.dpad_down = new_ddr_state.dpad_down;
input_report.short_report.dpad_left = new_ddr_state.dpad_left;

input_report.short_report.btn_east = new_ddr_state.btn_circle;
input_report.short_report.btn_south = new_ddr_state.btn_cross;
}
}
42 changes: 42 additions & 0 deletions handlers/ddr_grandprix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef _DDR_GRANDPRIX_H_
#define _DDR_GRANDPRIX_H_

#include <stdint.h>

#include "tusb.h"

#include "common_types.h"

#define DDR_GRANDPRIX_VID 0x1CCF
#define DDR_GRANDPRIX_PID 0x1020

#pragma pack(push, 1)

typedef struct
{
int8_t x; // X axis (-127 to 127)
int8_t y; // Y axis (-127 to 127)

// Buttons as bitfields
uint16_t btn_l : 1; // Button 1 (L button)
uint16_t btn_r : 1; // Button 2 (R button)
uint16_t dpad_up : 1; // Button 3 (Up)
uint16_t dpad_right : 1; // Button 4 (Right)
uint16_t dpad_down : 1; // Button 5 (Down)
uint16_t dpad_left : 1; // Button 6 (Left)
uint16_t _reserved1 : 2; // padding

uint16_t btn_circle : 1; // Button 9 (Circle)
uint16_t btn_cross : 1; // Button 10 (Cross)
uint16_t _reserved2 : 6; // padding to

uint8_t padding; // extra padding
} ddr_grandprix_report_t;

#pragma pack(pop)

bool is_DDR_GRANDPRIX(uint8_t dev_addr);

void processDDR_GRANDPRIX(uint8_t const *report, uint16_t len);

#endif
2 changes: 2 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "handlers/zuiki.h"
#include "handlers/santroller.h"
#include "handlers/b2l.h"
#include "handlers/ddr_grandprix.h"

//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTYPES
Expand Down Expand Up @@ -504,6 +505,7 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons
DISPATCH_NEW_REPORT(FUSION_HID)
DISPATCH_NEW_REPORT(SANTROLLER)
DISPATCH_NEW_REPORT(B2L)
DISPATCH_NEW_REPORT(DDR_GRANDPRIX)
default:
DebugPrintf("Unknown handler type for dev %d:%d", dev_addr, instance);
DebugOutputBuffer("RPT:", report, len);
Expand Down