diff --git a/src/controllers/dinput/p3converter.h b/src/controllers/dinput/p3converter.h new file mode 100644 index 0000000..34af30e --- /dev/null +++ b/src/controllers/dinput/p3converter.h @@ -0,0 +1,60 @@ +#ifndef __DINPUT_P3CONVERTER_H__ +#define __DINPUT_P3CONVERTER_H__ +#include +#include "dpad_angle.h" + +uint8_t p3converter_processReport(Controller *c, size_t length) +{ + process_dpad_angle(c, 5); + + if (bit(c->buffer + 5, 6)) + c->controlData.buttons |= SCE_CTRL_CROSS; + if (bit(c->buffer + 5, 5)) + c->controlData.buttons |= SCE_CTRL_CIRCLE; + if (bit(c->buffer + 5, 4)) + c->controlData.buttons |= SCE_CTRL_TRIANGLE; + if (bit(c->buffer + 5, 7)) + c->controlData.buttons |= SCE_CTRL_SQUARE; + + + + if (bit(c->buffer + 6, 2)) + c->controlData.buttons |= SCE_CTRL_L1; + if (bit(c->buffer + 6, 3)) + c->controlData.buttons |= SCE_CTRL_R1; + if (bit(c->buffer + 6, 6)) + c->controlData.buttons |= SCE_CTRL_L3; + if (bit(c->buffer + 6, 7)) + c->controlData.buttons |= SCE_CTRL_R3; + + if (bit(c->buffer + 6, 0)) + { + c->controlData.buttons |= SCE_CTRL_LTRIGGER; + c->controlData.lt = 0xFF; + } + + if (bit(c->buffer + 6, 1)) + { + c->controlData.buttons |= SCE_CTRL_RTRIGGER; + c->controlData.rt = 0xFF; + } + + if (bit(c->buffer + 6, 5)) + c->controlData.buttons |= SCE_CTRL_START; + if (bit(c->buffer + 6, 4)) + c->controlData.buttons |= SCE_CTRL_SELECT; + + if (bit(c->buffer + 6, 2) && bit(c->buffer + 6, 3) && bit(c->buffer + 6, 5)) // L+R+START combo + { + c->controlData.buttons |= SCE_CTRL_PSBUTTON; + c->controlData.buttons &= ~SCE_CTRL_START; + } + + c->controlData.leftX = c->buffer[2]; + c->controlData.leftY = c->buffer[3]; + c->controlData.rightX = c->buffer[0]; + c->controlData.rightY = c->buffer[1]; + return 1; +} + +#endif diff --git a/src/controllers/dinput_controller.c b/src/controllers/dinput_controller.c index ce3ec2e..6eeebd2 100644 --- a/src/controllers/dinput_controller.c +++ b/src/controllers/dinput_controller.c @@ -10,6 +10,7 @@ #include "dinput/psclassic.h" #include "dinput/horidiva.h" #include "dinput/raphnetpsx.h" +#include "dinput/p3converter.h" uint8_t DinputController_probe(Controller *c, int device_id, int port, int vendor, int product) { @@ -117,6 +118,10 @@ uint8_t DinputController_processReport(Controller *c, size_t length) { return raphnetpsx_processReport(c, length); } + else if (c->vendor == 0x0e8f && c->product == 0x0003) // PIII Converter Model: 538 + { + return p3converter_processReport(c, length); + } else { return 0; diff --git a/src/devicelist.c b/src/devicelist.c index 7fb6233..cf8dd34 100644 --- a/src/devicelist.c +++ b/src/devicelist.c @@ -108,5 +108,6 @@ gamepad_t _devices[] = {{PAD_XBOX360, 0x045e, 0x028e}, // Microsoft X-Box 360 p {PAD_DINPUT, 0x054c, 0x0cda}, // Playstation Classic {PAD_DINPUT, 0x0f0d, 0x0049}, // Hori ps3 mini diva {PAD_DINPUT, 0x289b, 0x0044}, // Raphnet Technologies PSX to USB v.1.0 + {PAD_DINPUT, 0x0e8f, 0x0003}, // PIII Converter Model: 538 {PAD_UNKNOWN, 0x0000, 0x0000}}; // Null