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
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ file (GLOB CXBXR_HEADER_COMMON
"${CXBXR_ROOT_DIR}/src/common/CxbxDebugger.h"
"${CXBXR_ROOT_DIR}/src/common/EmuEEPROM.h"
"${CXBXR_ROOT_DIR}/src/common/Error.h"
"${CXBXR_ROOT_DIR}/src/common/input/Button.h"
"${CXBXR_ROOT_DIR}/src/common/input/DInputKeyboardCodes.h"
"${CXBXR_ROOT_DIR}/src/common/input/DInputKeyboardMouse.h"
"${CXBXR_ROOT_DIR}/src/common/input/EmuDevice.h"
"${CXBXR_ROOT_DIR}/src/common/input/layout_xbox_controller.h"
"${CXBXR_ROOT_DIR}/src/common/input/InputDevice.h"
"${CXBXR_ROOT_DIR}/src/common/input/InputManager.h"
"${CXBXR_ROOT_DIR}/src/common/input/InputWindow.h"
"${CXBXR_ROOT_DIR}/src/common/input/SdlJoystick.h"
"${CXBXR_ROOT_DIR}/src/common/input/XInputPad.h"
"${CXBXR_ROOT_DIR}/src/common/IPCHybrid.hpp"
Expand Down Expand Up @@ -108,6 +106,9 @@ file (GLOB CXBXR_HEADER_COMMON

# GUI v1
file (GLOB CXBXR_HEADER_GUIv1
"${CXBXR_ROOT_DIR}/src/common/input/Button.h"
"${CXBXR_ROOT_DIR}/src/common/input/EmuDevice.h"
"${CXBXR_ROOT_DIR}/src/common/input/InputWindow.h"
"${CXBXR_ROOT_DIR}/src/gui/DbgConsole.h"
"${CXBXR_ROOT_DIR}/src/gui/DlgAbout.h"
"${CXBXR_ROOT_DIR}/src/gui/DlgAudioConfig.h"
Expand Down Expand Up @@ -203,12 +204,9 @@ file (GLOB CXBXR_SOURCE_COMMON
"${CXBXR_ROOT_DIR}/src/common/CxbxDebugger.cpp"
"${CXBXR_ROOT_DIR}/src/common/EmuEEPROM.cpp"
"${CXBXR_ROOT_DIR}/src/common/Error.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/Button.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/DInputKeyboardMouse.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/EmuDevice.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/InputDevice.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/InputManager.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/InputWindow.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/SdlJoystick.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/XInputPad.cpp"
"${CXBXR_ROOT_DIR}/src/common/Logging.cpp"
Expand All @@ -233,6 +231,9 @@ file (GLOB CXBXR_SOURCE_COMMON

# GUI v1
file (GLOB CXBXR_SOURCE_GUIv1
"${CXBXR_ROOT_DIR}/src/common/input/Button.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/EmuDevice.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/InputWindow.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DlgAbout.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DlgAudioConfig.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DlgInputConfig.cpp"
Expand Down
2 changes: 1 addition & 1 deletion projects/cxbx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ set(WINS_LIB
XINPUT9_1_0
Iphlpapi
wpcap
SDL2
)

target_link_libraries(cxbx
PUBLIC XbSymbolDatabase
subhook
libtomcrypt
SDL2

${WINS_LIB}
)
Expand Down
3 changes: 2 additions & 1 deletion src/common/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
#include "core\kernel\support\Emu.h"
#include "EmuShared.h"
#include <filesystem>
#include "common\input\EmuDevice.h"
#include "common\input\InputManager.h"
#include "common\input\layout_xbox_controller.h"

// TODO: Implement Qt support when real CPU emulation is available.
#ifndef QT_VERSION // NOTE: Non-Qt will be using current directory for data
Expand Down
1 change: 1 addition & 0 deletions src/common/input/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "Button.h"
#include "InputWindow.h"
#include "layout_xbox_controller.h" // TODO: Needs a better fix for custom input device support.
#include "..\..\gui\ResCxbx.h"


Expand Down
57 changes: 1 addition & 56 deletions src/common/input/EmuDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,64 +27,9 @@

#include"Button.h"
#include "InputManager.h"
#include "layout_xbox_controller.h"
#include "..\..\gui\ResCxbx.h"

static int button_xbox_ctrl_id[XBOX_CTRL_NUM_BUTTONS] = {
IDC_SET_DPAD_UP,
IDC_SET_DPAD_DOWN,
IDC_SET_DPAD_LEFT,
IDC_SET_DPAD_RIGHT,
IDC_SET_START,
IDC_SET_BACK,
IDC_SET_LTHUMB,
IDC_SET_RTHUMB,
IDC_SET_A,
IDC_SET_B,
IDC_SET_X,
IDC_SET_Y,
IDC_SET_BLACK,
IDC_SET_WHITE,
IDC_SET_LTRIGGER,
IDC_SET_RTRIGGER,
IDC_SET_LEFT_POSX,
IDC_SET_LEFT_NEGX,
IDC_SET_LEFT_POSY,
IDC_SET_LEFT_NEGY,
IDC_SET_RIGHT_POSX,
IDC_SET_RIGHT_NEGX,
IDC_SET_RIGHT_POSY,
IDC_SET_RIGHT_NEGY,
IDC_SET_MOTOR,
};

const char* button_xbox_ctrl_names[XBOX_CTRL_NUM_BUTTONS][3] = {
"D Pad Up", "Pad N", "UP",
"D Pad Down", "Pad S", "DOWN",
"D Pad Left", "Pad W", "LEFT",
"D Pad Right", "Pad E", "RIGHT",
"Start", "Start", "RETURN",
"Back", "Back", "SPACE",
"L Thumb", "Thumb L", "B",
"R Thumb", "Thumb R", "M",
"A", "Button A", "S",
"B", "Button B", "D",
"X", "Button X", "W",
"Y", "Button Y", "E",
"Black", "Shoulder R", "C",
"White", "Shoulder L", "X",
"L Trigger", "Trigger L", "Q",
"R Trigger", "Trigger R", "R",
"Left Axis X+", "Left X+", "H",
"Left Axis X-", "Left X-", "F",
"Left Axis Y+", "Left Y+", "T",
"Left Axis Y-", "Left Y-", "G",
"Right Axis X+", "Right X+", "L",
"Right Axis X-", "Right X-", "J",
"Right Axis Y+", "Right Y+", "I",
"Right Axis Y-", "Right Y-", "K",
"Motor", "LeftRight", "",
};


EmuDevice::EmuDevice(int type, HWND hwnd)
{
Expand Down
3 changes: 0 additions & 3 deletions src/common/input/EmuDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
#include "Button.h"
#include "common\util\CxbxUtil.h"

extern const char* button_xbox_ctrl_names[XBOX_CTRL_NUM_BUTTONS][3];
extern int dev_num_buttons[to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)];


/* Represents the guest device currently being configured in the gui */
class EmuDevice
Expand Down
17 changes: 17 additions & 0 deletions src/common/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ namespace xboxkrnl
#include "core\hle\XAPI\Xapi.h"
#include "core\hle\XAPI\XapiCxbxr.h"

int Gui2XboxPortArray[4] = {
3,
4,
1,
2
};

int dev_num_buttons[to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)] = {
XBOX_CTRL_NUM_BUTTONS,
0,
0,
0,
0,
0,
0,
};

extern CXBX_CONTROLLER_HOST_BRIDGE g_XboxControllerHostBridge[4]; // hle xinput


Expand Down
2 changes: 2 additions & 0 deletions src/common/input/InputManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#undef SetPort
#endif

extern int dev_num_buttons[to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)];

#pragma pack(1)

// xpad in/out buffers stripped of the first two bytes
Expand Down
9 changes: 0 additions & 9 deletions src/common/input/InputWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@

constexpr ControlState INPUT_DETECT_THRESHOLD = 0.55; // arbitrary number, using what Dolphin uses
InputWindow* g_InputWindow = nullptr;
int dev_num_buttons[to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)] = {
XBOX_CTRL_NUM_BUTTONS,
0,
0,
0,
0,
0,
0,
};


void InputWindow::Initialize(HWND hwnd, int port_num, int dev_type)
Expand Down
88 changes: 88 additions & 0 deletions src/common/input/layout_xbox_controller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
// ******************************************************************
// *
// * This file is part of the Cxbx project.
// *
// * Cxbx and Cxbe are free software; you can redistribute them
// * and/or modify them under the terms of the GNU General Public
// * License as published by the Free Software Foundation; either
// * version 2 of the license, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have recieved a copy of the GNU General Public License
// * along with this program; see the file COPYING.
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * (c) 2019 ergo720
// *
// * All rights reserved
// *
// ******************************************************************

#pragma once

#ifndef CXBXR_EMU_EXPORTS
#include "gui/ResCxbx.h"

static int button_xbox_ctrl_id[XBOX_CTRL_NUM_BUTTONS] = {
IDC_SET_DPAD_UP,
IDC_SET_DPAD_DOWN,
IDC_SET_DPAD_LEFT,
IDC_SET_DPAD_RIGHT,
IDC_SET_START,
IDC_SET_BACK,
IDC_SET_LTHUMB,
IDC_SET_RTHUMB,
IDC_SET_A,
IDC_SET_B,
IDC_SET_X,
IDC_SET_Y,
IDC_SET_BLACK,
IDC_SET_WHITE,
IDC_SET_LTRIGGER,
IDC_SET_RTRIGGER,
IDC_SET_LEFT_POSX,
IDC_SET_LEFT_NEGX,
IDC_SET_LEFT_POSY,
IDC_SET_LEFT_NEGY,
IDC_SET_RIGHT_POSX,
IDC_SET_RIGHT_NEGX,
IDC_SET_RIGHT_POSY,
IDC_SET_RIGHT_NEGY,
IDC_SET_MOTOR,
};
#endif

static const char* button_xbox_ctrl_names[XBOX_CTRL_NUM_BUTTONS][3] = {
"D Pad Up", "Pad N", "UP",
"D Pad Down", "Pad S", "DOWN",
"D Pad Left", "Pad W", "LEFT",
"D Pad Right", "Pad E", "RIGHT",
"Start", "Start", "RETURN",
"Back", "Back", "SPACE",
"L Thumb", "Thumb L", "B",
"R Thumb", "Thumb R", "M",
"A", "Button A", "S",
"B", "Button B", "D",
"X", "Button X", "W",
"Y", "Button Y", "E",
"Black", "Shoulder R", "C",
"White", "Shoulder L", "X",
"L Trigger", "Trigger L", "Q",
"R Trigger", "Trigger R", "R",
"Left Axis X+", "Left X+", "H",
"Left Axis X-", "Left X-", "F",
"Left Axis Y+", "Left Y+", "T",
"Left Axis Y-", "Left Y-", "G",
"Right Axis X+", "Right X+", "L",
"Right Axis X-", "Right X-", "J",
"Right Axis Y+", "Right Y+", "I",
"Right Axis Y-", "Right Y-", "K",
"Motor", "LeftRight", "",
};
7 changes: 0 additions & 7 deletions src/gui/DlgInputConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@
static INT_PTR CALLBACK DlgInputConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
HWND g_ChildWnd = NULL;

int Gui2XboxPortArray[4] = {
3,
4,
1,
2
};


void SyncInputSettings(int port_num, int dev_type)
{
Expand Down