Skip to content

Commit

Permalink
Additional/mini console input modes (#643)
Browse files Browse the repository at this point in the history
* Initial implementation of mini console USB input modes. First mode: Neo Geo Mini

* Added Sega Genesis/MD Mini input mode.

* Updated MDMini enum to use value 6

* Added support for PC Engine/Turbografx 16 Mini Pad.

* Implemented PS Classic input type. Astro City and Egret II Minis are WIP.

* Removed leftover serial debugging lines.

* Implemented Egret II Gamepad input type.

* Fully implemented Astro City based on GEN/MD similarities assumption.
Redefined platform button mask defines to better align with platform button layout instead of user controller.

* Fixed issue with Select and Start being reversed on PS Classic mode

* Added display labels for minicon modes

* Original Xbox controller implementation based on xid_driver from Ryzee119/ogx360_t4

* Added "OGXBOX" label to Display status

* Fixed descriptor header dependencies causing builds to fail

* Included license to xid_driver
  • Loading branch information
mikepparks authored Dec 16, 2023
1 parent f81408b commit 7f19659
Show file tree
Hide file tree
Showing 33 changed files with 2,895 additions and 5 deletions.
15 changes: 15 additions & 0 deletions headers/gamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
#include "gamepad/descriptors/XInputDescriptors.h"
#include "gamepad/descriptors/KeyboardDescriptors.h"
#include "gamepad/descriptors/PS4Descriptors.h"
#include "gamepad/descriptors/NeogeoDescriptors.h"
#include "gamepad/descriptors/MDMiniDescriptors.h"
#include "gamepad/descriptors/PCEngineDescriptors.h"
#include "gamepad/descriptors/EgretDescriptors.h"
#include "gamepad/descriptors/AstroDescriptors.h"
#include "gamepad/descriptors/PSClassicDescriptors.h"
#include "gamepad/descriptors/XboxOriginalDescriptors.h"

#include "pico/stdlib.h"

Expand Down Expand Up @@ -72,6 +79,13 @@ class Gamepad {
XInputReport *getXInputReport();
KeyboardReport *getKeyboardReport();
PS4Report *getPS4Report();
NeogeoReport *getNeogeoReport();
MDMiniReport *getMDMiniReport();
PCEngineReport *getPCEngineReport();
EgretReport *getEgretReport();
AstroReport *getAstroReport();
PSClassicReport *getPSClassicReport();
XboxOriginalReport *getXboxOriginalReport();

/**
* @brief Check for a button press. Used by `pressed[Button]` helper methods.
Expand Down Expand Up @@ -163,6 +177,7 @@ class Gamepad {
return (options.socdMode == SOCD_MODE_BYPASS &&
(options.inputMode == INPUT_MODE_HID ||
options.inputMode == INPUT_MODE_SWITCH ||
options.inputMode == INPUT_MODE_NEOGEO ||
options.inputMode == INPUT_MODE_PS4)) ?
SOCD_MODE_NEUTRAL : options.socdMode;
};
Expand Down
139 changes: 139 additions & 0 deletions headers/gamepad/GamepadDescriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
#include "descriptors/XInputDescriptors.h"
#include "descriptors/KeyboardDescriptors.h"
#include "descriptors/PS4Descriptors.h"
#include "descriptors/NeogeoDescriptors.h"
#include "descriptors/MDMiniDescriptors.h"
#include "descriptors/PCEngineDescriptors.h"
#include "descriptors/EgretDescriptors.h"
#include "descriptors/AstroDescriptors.h"
#include "descriptors/PSClassicDescriptors.h"
#include "descriptors/XboxOriginalDescriptors.h"

#include "enums.pb.h"

Expand All @@ -38,6 +45,34 @@ static const uint8_t *getConfigurationDescriptor(uint16_t *size, InputMode mode)
*size = sizeof(ps4_configuration_descriptor);
return ps4_configuration_descriptor;

case INPUT_MODE_NEOGEO:
*size = sizeof(neogeo_configuration_descriptor);
return neogeo_configuration_descriptor;

case INPUT_MODE_MDMINI:
*size = sizeof(mdmini_configuration_descriptor);
return mdmini_configuration_descriptor;

case INPUT_MODE_PCEMINI:
*size = sizeof(pcengine_configuration_descriptor);
return pcengine_configuration_descriptor;

case INPUT_MODE_EGRET:
*size = sizeof(egret_configuration_descriptor);
return egret_configuration_descriptor;

case INPUT_MODE_ASTRO:
*size = sizeof(astro_configuration_descriptor);
return astro_configuration_descriptor;

case INPUT_MODE_PSCLASSIC:
*size = sizeof(psclassic_configuration_descriptor);
return psclassic_configuration_descriptor;

case INPUT_MODE_XBOXORIGINAL:
*size = sizeof(xboxoriginal_configuration_descriptor);
return xboxoriginal_configuration_descriptor;

default:
*size = sizeof(hid_configuration_descriptor);
return hid_configuration_descriptor;
Expand All @@ -64,6 +99,34 @@ static const uint8_t *getDeviceDescriptor(uint16_t *size, InputMode mode)
*size = sizeof(ps4_device_descriptor);
return ps4_device_descriptor;

case INPUT_MODE_NEOGEO:
*size = sizeof(neogeo_device_descriptor);
return neogeo_device_descriptor;

case INPUT_MODE_MDMINI:
*size = sizeof(mdmini_device_descriptor);
return mdmini_device_descriptor;

case INPUT_MODE_PCEMINI:
*size = sizeof(pcengine_device_descriptor);
return pcengine_device_descriptor;

case INPUT_MODE_EGRET:
*size = sizeof(egret_device_descriptor);
return egret_device_descriptor;

case INPUT_MODE_ASTRO:
*size = sizeof(astro_device_descriptor);
return astro_device_descriptor;

case INPUT_MODE_PSCLASSIC:
*size = sizeof(psclassic_device_descriptor);
return psclassic_device_descriptor;

case INPUT_MODE_XBOXORIGINAL:
*size = sizeof(xboxoriginal_device_descriptor);
return xboxoriginal_device_descriptor;

default:
*size = sizeof(hid_device_descriptor);
return hid_device_descriptor;
Expand All @@ -86,6 +149,30 @@ static const uint8_t *getHIDDescriptor(uint16_t *size, InputMode mode)
*size = sizeof(ps4_hid_descriptor);
return ps4_hid_descriptor;

case INPUT_MODE_NEOGEO:
*size = sizeof(neogeo_hid_descriptor);
return neogeo_hid_descriptor;

case INPUT_MODE_MDMINI:
*size = sizeof(mdmini_hid_descriptor);
return mdmini_hid_descriptor;

case INPUT_MODE_PCEMINI:
*size = sizeof(pcengine_hid_descriptor);
return pcengine_hid_descriptor;

case INPUT_MODE_EGRET:
*size = sizeof(egret_hid_descriptor);
return egret_hid_descriptor;

case INPUT_MODE_ASTRO:
*size = sizeof(astro_hid_descriptor);
return astro_hid_descriptor;

case INPUT_MODE_PSCLASSIC:
*size = sizeof(psclassic_hid_descriptor);
return psclassic_hid_descriptor;

default:
*size = sizeof(hid_hid_descriptor);
return hid_hid_descriptor;
Expand All @@ -108,6 +195,30 @@ static const uint8_t *getHIDReport(uint16_t *size, InputMode mode)
*size = sizeof(ps4_report_descriptor);
return ps4_report_descriptor;

case INPUT_MODE_NEOGEO:
*size = sizeof(neogeo_report_descriptor);
return neogeo_report_descriptor;

case INPUT_MODE_MDMINI:
*size = sizeof(mdmini_report_descriptor);
return mdmini_report_descriptor;

case INPUT_MODE_PCEMINI:
*size = sizeof(pcengine_report_descriptor);
return pcengine_report_descriptor;

case INPUT_MODE_EGRET:
*size = sizeof(egret_report_descriptor);
return egret_report_descriptor;

case INPUT_MODE_ASTRO:
*size = sizeof(astro_report_descriptor);
return astro_report_descriptor;

case INPUT_MODE_PSCLASSIC:
*size = sizeof(psclassic_report_descriptor);
return psclassic_report_descriptor;

default:
*size = sizeof(hid_report_descriptor);
return hid_report_descriptor;
Expand Down Expand Up @@ -171,6 +282,34 @@ static const uint16_t *getStringDescriptor(uint16_t *size, InputMode mode, uint8
str = (char *)ps4_string_descriptors[index];
break;

case INPUT_MODE_NEOGEO:
str = (char *)neogeo_string_descriptors[index];
break;

case INPUT_MODE_MDMINI:
str = (char *)mdmini_string_descriptors[index];
break;

case INPUT_MODE_PCEMINI:
str = (char *)pcengine_string_descriptors[index];
break;

case INPUT_MODE_EGRET:
str = (char *)egret_string_descriptors[index];
break;

case INPUT_MODE_ASTRO:
str = (char *)astro_string_descriptors[index];
break;

case INPUT_MODE_PSCLASSIC:
str = (char *)psclassic_string_descriptors[index];
break;

case INPUT_MODE_XBOXORIGINAL:
str = (char *)xboxoriginal_string_descriptors[index];
break;

default:
str = (char *)hid_string_descriptors[index];
break;
Expand Down
28 changes: 28 additions & 0 deletions headers/gamepad/GamepadState.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ using namespace std;
#include "gamepad/descriptors/SwitchDescriptors.h"
#include "gamepad/descriptors/XInputDescriptors.h"
#include "gamepad/descriptors/PS4Descriptors.h"
#include "gamepad/descriptors/NeogeoDescriptors.h"
#include "gamepad/descriptors/MDMiniDescriptors.h"
#include "gamepad/descriptors/PCEngineDescriptors.h"
#include "gamepad/descriptors/EgretDescriptors.h"
#include "gamepad/descriptors/AstroDescriptors.h"
#include "gamepad/descriptors/PSClassicDescriptors.h"
#include "gamepad/descriptors/XboxOriginalDescriptors.h"

#define GAMEPAD_BUTTON_COUNT 14

Expand Down Expand Up @@ -148,6 +155,27 @@ inline uint16_t GetJoystickMidValue(uint8_t mode) {
case INPUT_MODE_PS4:
return PS4_JOYSTICK_MID << 8;

case INPUT_MODE_NEOGEO:
return NEOGEO_JOYSTICK_MID << 8;

case INPUT_MODE_MDMINI:
return GAMEPAD_JOYSTICK_MID;

case INPUT_MODE_PCEMINI:
return GAMEPAD_JOYSTICK_MID;

case INPUT_MODE_EGRET:
return GAMEPAD_JOYSTICK_MID;

case INPUT_MODE_ASTRO:
return GAMEPAD_JOYSTICK_MID;

case INPUT_MODE_PSCLASSIC:
return GAMEPAD_JOYSTICK_MID;

case INPUT_MODE_XBOXORIGINAL:
return GAMEPAD_JOYSTICK_MID;

default:
return GAMEPAD_JOYSTICK_MID;
}
Expand Down
Loading

0 comments on commit 7f19659

Please sign in to comment.