Merge pull request #2150 from ergo720/arcade_ctrl

Add support for the arcade joystick device to the input gui
This commit is contained in:
Luke Usher 2021-03-03 10:38:22 +00:00 committed by GitHub
commit f32a2e7d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 5 deletions

View File

@ -490,6 +490,7 @@ bool Settings::LoadConfig()
{
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE):
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S):
case to_underlying(XBOX_INPUT_DEVICE::ARCADE_STICK):
lambda(dev_num_buttons[device], button_xbox_ctrl_names);
break;
@ -650,6 +651,7 @@ bool Settings::Save(std::string file_path)
{
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE):
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S):
case to_underlying(XBOX_INPUT_DEVICE::ARCADE_STICK):
lambda(dev_num_buttons[device], button_xbox_ctrl_names);
break;

View File

@ -41,7 +41,8 @@ EmuDevice::EmuDevice(int type, HWND hwnd, void *wnd)
switch (type)
{
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE):
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S): {
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S):
case to_underlying(XBOX_INPUT_DEVICE::ARCADE_STICK): {
for (size_t i = 0; i < ARRAY_SIZE(button_xbox_ctrl_id); i++) {
m_buttons.push_back(new Button(button_xbox_ctrl_id[i], i, hwnd, wnd));
m_buttons.back()->AddTooltip(m_hwnd, m_tooltip_hwnd, tooltip_text);

View File

@ -71,6 +71,10 @@ std::string GetInputDeviceName(int dev_type)
str = "Steel battalion controller";
break;
case to_underlying(XBOX_INPUT_DEVICE::ARCADE_STICK):
str = "Arcade joystick";
break;
case to_underlying(XBOX_INPUT_DEVICE::DEVICE_INVALID):
str = "None";
break;

View File

@ -63,6 +63,7 @@ typedef enum class _XBOX_INPUT_DEVICE : int {
MEMORY_UNIT,
IR_DONGLE,
STEEL_BATTALION_CONTROLLER,
ARCADE_STICK,
DEVICE_MAX,
}
XBOX_INPUT_DEVICE;

View File

@ -64,6 +64,7 @@ int dev_num_buttons[to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)] = {
0,
0,
SBC_NUM_BUTTONS, // STEEL_BATTALION_CONTROLLER
XBOX_CTRL_NUM_BUTTONS, // ARCADE_STICK
};
extern CXBX_CONTROLLER_HOST_BRIDGE g_XboxControllerHostBridge[4]; // hle xinput
@ -360,7 +361,8 @@ bool InputDeviceManager::UpdateXboxPortInput(int usb_port, void* Buffer, int Dir
switch (xid_type)
{
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE):
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S): {
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S):
case to_underlying(XBOX_INPUT_DEVICE::ARCADE_STICK): {
has_changed = UpdateInputXpad(dev_ptr, Buffer, Direction);
}
break;

View File

@ -44,6 +44,7 @@ inline XBOX_INPUT_DEVICE input_support_list[] = {
XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE,
XBOX_INPUT_DEVICE::MS_CONTROLLER_S,
XBOX_INPUT_DEVICE::STEEL_BATTALION_CONTROLLER,
XBOX_INPUT_DEVICE::ARCADE_STICK,
};
#pragma pack(1)

View File

@ -67,7 +67,8 @@ bool operator==(xbox::PXPP_DEVICE_TYPE XppType, XBOX_INPUT_DEVICE XidType)
switch (XidType)
{
case XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE:
case XBOX_INPUT_DEVICE::MS_CONTROLLER_S: {
case XBOX_INPUT_DEVICE::MS_CONTROLLER_S:
case XBOX_INPUT_DEVICE::ARCADE_STICK: {
if (XppType == g_DeviceType_Gamepad) {
return true;
}
@ -149,6 +150,20 @@ bool ConstructHleInputDevice(int Type, int Port)
}
break;
case to_underlying(XBOX_INPUT_DEVICE::ARCADE_STICK): {
g_XboxControllerHostBridge[Port].XboxPort = Port;
g_XboxControllerHostBridge[Port].XboxType = XBOX_INPUT_DEVICE::ARCADE_STICK;
g_XboxControllerHostBridge[Port].bPendingRemoval = false;
g_XboxControllerHostBridge[Port].bSignaled = false;
g_XboxControllerHostBridge[Port].bIoInProgress = false;
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucType = XINPUT_DEVTYPE_GAMEPAD;
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucSubType = XINPUT_DEVSUBTYPE_GC_ARCADE_STICK;
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucInputStateSize = sizeof(XpadInput);
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucFeedbackSize = sizeof(XpadOutput);
g_XboxControllerHostBridge[Port].XboxDeviceInfo.dwPacketNumber = 0;
}
break;
case to_underlying(XBOX_INPUT_DEVICE::LIGHT_GUN):
case to_underlying(XBOX_INPUT_DEVICE::STEERING_WHEEL):
case to_underlying(XBOX_INPUT_DEVICE::MEMORY_UNIT):

View File

@ -195,7 +195,8 @@ INT_PTR CALLBACK DlgInputConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPAR
switch (DeviceType)
{
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE):
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S): {
case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S):
case to_underlying(XBOX_INPUT_DEVICE::ARCADE_STICK): {
DialogBoxParam(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_XID_DUKE_CFG), hWndDlg, DlgXidControllerConfigProc,
(DeviceType << 8) | port);
}

View File

@ -72,6 +72,11 @@ void DukeInputWindow::Initialize(HWND hwnd, int port_num, int dev_type)
}
break;
case to_underlying(XBOX_INPUT_DEVICE::ARCADE_STICK): {
title += "Arcade joystick at port ";
}
break;
}
SendMessage(m_hwnd_window, WM_SETTEXT, 0,
reinterpret_cast<LPARAM>((title + std::to_string(PORT_INC(m_port_num))).c_str()));
@ -250,7 +255,8 @@ INT_PTR CALLBACK DlgXidControllerConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wPar
// Ensure that the controller type is valid
assert(dev_type == to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE) ||
dev_type == to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S));
dev_type == to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S) ||
dev_type == to_underlying(XBOX_INPUT_DEVICE::ARCADE_STICK));
g_InputWindow = new DukeInputWindow;
g_InputWindow->Initialize(hWndDlg, port_num, dev_type);