Review remarks

This commit is contained in:
ergo720 2021-02-08 20:14:13 +01:00
parent cd362b6383
commit 07b4738e97
12 changed files with 48 additions and 50 deletions

View File

@ -96,13 +96,13 @@ file (GLOB CXBXR_HEADER_GUIv1
"${CXBXR_ROOT_DIR}/src/common/input/EmuDevice.h" "${CXBXR_ROOT_DIR}/src/common/input/EmuDevice.h"
"${CXBXR_ROOT_DIR}/src/common/input/InputWindow.h" "${CXBXR_ROOT_DIR}/src/common/input/InputWindow.h"
"${CXBXR_ROOT_DIR}/src/gui/controllers/DlgDukeControllerConfig.h" "${CXBXR_ROOT_DIR}/src/gui/controllers/DlgDukeControllerConfig.h"
"${CXBXR_ROOT_DIR}/src/gui/controllers/DlgSBControllerConfig.h"
"${CXBXR_ROOT_DIR}/src/gui/DlgAbout.h" "${CXBXR_ROOT_DIR}/src/gui/DlgAbout.h"
"${CXBXR_ROOT_DIR}/src/gui/DlgAudioConfig.h" "${CXBXR_ROOT_DIR}/src/gui/DlgAudioConfig.h"
"${CXBXR_ROOT_DIR}/src/gui/DlgInputConfig.h" "${CXBXR_ROOT_DIR}/src/gui/DlgInputConfig.h"
"${CXBXR_ROOT_DIR}/src/gui/DlgEepromConfig.h" "${CXBXR_ROOT_DIR}/src/gui/DlgEepromConfig.h"
"${CXBXR_ROOT_DIR}/src/gui/DlgLoggingConfig.h" "${CXBXR_ROOT_DIR}/src/gui/DlgLoggingConfig.h"
"${CXBXR_ROOT_DIR}/src/gui/DlgNetworkConfig.h" "${CXBXR_ROOT_DIR}/src/gui/DlgNetworkConfig.h"
"${CXBXR_ROOT_DIR}/src/gui/controllers/DlgSBControllerConfig.h"
"${CXBXR_ROOT_DIR}/src/gui/DlgVideoConfig.h" "${CXBXR_ROOT_DIR}/src/gui/DlgVideoConfig.h"
"${CXBXR_ROOT_DIR}/src/gui/Wnd.h" "${CXBXR_ROOT_DIR}/src/gui/Wnd.h"
"${CXBXR_ROOT_DIR}/src/gui/WndMain.h" "${CXBXR_ROOT_DIR}/src/gui/WndMain.h"
@ -242,13 +242,13 @@ file (GLOB CXBXR_SOURCE_GUIv1
"${CXBXR_ROOT_DIR}/src/common/input/EmuDevice.cpp" "${CXBXR_ROOT_DIR}/src/common/input/EmuDevice.cpp"
"${CXBXR_ROOT_DIR}/src/common/input/InputWindow.cpp" "${CXBXR_ROOT_DIR}/src/common/input/InputWindow.cpp"
"${CXBXR_ROOT_DIR}/src/gui/controllers/DlgDukeControllerConfig.cpp" "${CXBXR_ROOT_DIR}/src/gui/controllers/DlgDukeControllerConfig.cpp"
"${CXBXR_ROOT_DIR}/src/gui/controllers/DlgSBControllerConfig.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DlgAbout.cpp" "${CXBXR_ROOT_DIR}/src/gui/DlgAbout.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DlgAudioConfig.cpp" "${CXBXR_ROOT_DIR}/src/gui/DlgAudioConfig.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DlgInputConfig.cpp" "${CXBXR_ROOT_DIR}/src/gui/DlgInputConfig.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DlgEepromConfig.cpp" "${CXBXR_ROOT_DIR}/src/gui/DlgEepromConfig.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DlgLoggingConfig.cpp" "${CXBXR_ROOT_DIR}/src/gui/DlgLoggingConfig.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DlgNetworkConfig.cpp" "${CXBXR_ROOT_DIR}/src/gui/DlgNetworkConfig.cpp"
"${CXBXR_ROOT_DIR}/src/gui/controllers/DlgSBControllerConfig.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DlgVideoConfig.cpp" "${CXBXR_ROOT_DIR}/src/gui/DlgVideoConfig.cpp"
"${CXBXR_ROOT_DIR}/src/gui/WinMain.cpp" "${CXBXR_ROOT_DIR}/src/gui/WinMain.cpp"
"${CXBXR_ROOT_DIR}/src/gui/Wnd.cpp" "${CXBXR_ROOT_DIR}/src/gui/Wnd.cpp"

View File

@ -474,27 +474,27 @@ bool Settings::LoadConfig()
std::array<std::vector<std::string>, to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)> control_names; std::array<std::vector<std::string>, to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)> control_names;
for (int device = 0; device < to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX); device++) { for (int device = 0; device < to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX); device++) {
int num_buttons = dev_num_buttons[device]; if (dev_num_buttons[device] == 0) {
if (num_buttons == 0) {
continue; continue;
} }
auto &lambda = [&control_names, &device](int num_buttons, const char *const ctrl_names[]) { auto &lambda = [&control_names, &device](int num_buttons, const char *const ctrl_names[]) {
for (int i = 0; i < num_buttons; i++) { for (int i = 0; i < num_buttons; i++) {
char control_name[BUF_NAME_LENGTH]; char control_name[XBOX_BUTTON_NAME_LENGTH];
std::sprintf(control_name, sect_input_profiles.control, ctrl_names[i]); std::sprintf(control_name, sect_input_profiles.control, ctrl_names[i]);
control_names[device].push_back(control_name); control_names[device].push_back(control_name);
} }
}; };
switch (num_buttons) switch (device)
{ {
case XBOX_CTRL_NUM_BUTTONS: case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE):
lambda(XBOX_CTRL_NUM_BUTTONS, button_xbox_ctrl_names); case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S):
lambda(dev_num_buttons[device], button_xbox_ctrl_names);
break; break;
case SBC_NUM_BUTTONS: case to_underlying(XBOX_INPUT_DEVICE::STEEL_BATTALION_CONTROLLER):
lambda(SBC_NUM_BUTTONS, button_sbc_names); lambda(dev_num_buttons[device], button_sbc_names);
break; break;
} }
@ -634,27 +634,27 @@ bool Settings::Save(std::string file_path)
std::array<std::vector<std::string>, to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)> control_names; std::array<std::vector<std::string>, to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)> control_names;
for (int device = 0; device < to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX); device++) { for (int device = 0; device < to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX); device++) {
int num_buttons = dev_num_buttons[device]; if (dev_num_buttons[device] == 0) {
if (num_buttons == 0) {
continue; continue;
} }
auto &lambda = [&control_names, &device](int num_buttons, const char *const ctrl_names[]) { auto &lambda = [&control_names, &device](int num_buttons, const char *const ctrl_names[]) {
for (int i = 0; i < num_buttons; i++) { for (int i = 0; i < num_buttons; i++) {
char control_name[BUF_NAME_LENGTH]; char control_name[XBOX_BUTTON_NAME_LENGTH];
std::sprintf(control_name, sect_input_profiles.control, ctrl_names[i]); std::sprintf(control_name, sect_input_profiles.control, ctrl_names[i]);
control_names[device].push_back(control_name); control_names[device].push_back(control_name);
} }
}; };
switch (num_buttons) switch (device)
{ {
case XBOX_CTRL_NUM_BUTTONS: case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE):
lambda(XBOX_CTRL_NUM_BUTTONS, button_xbox_ctrl_names); case to_underlying(XBOX_INPUT_DEVICE::MS_CONTROLLER_S):
lambda(dev_num_buttons[device], button_xbox_ctrl_names);
break; break;
case SBC_NUM_BUTTONS: case to_underlying(XBOX_INPUT_DEVICE::STEEL_BATTALION_CONTROLLER):
lambda(SBC_NUM_BUTTONS, button_sbc_names); lambda(dev_num_buttons[device], button_sbc_names);
break; break;
} }
@ -752,7 +752,7 @@ void Settings::SyncToEmulator()
return false; return false;
}); });
if (it != m_input_profiles[m_input_port[i].Type].end()) { if (it != m_input_profiles[m_input_port[i].Type].end()) {
char controls_name[HIGHEST_NUM_BUTTONS][30]; char controls_name[HIGHEST_NUM_BUTTONS][HOST_BUTTON_NAME_LENGTH];
for (int index = 0; index < dev_num_buttons[m_input_port[i].Type]; index++) { for (int index = 0; index < dev_num_buttons[m_input_port[i].Type]; index++) {
strncpy(controls_name[index], it->ControlList[index].c_str(), 30); strncpy(controls_name[index], it->ControlList[index].c_str(), 30);
} }

View File

@ -35,6 +35,8 @@
#define SBC_NUM_BUTTONS 56 #define SBC_NUM_BUTTONS 56
#define HIGHEST_NUM_BUTTONS SBC_NUM_BUTTONS #define HIGHEST_NUM_BUTTONS SBC_NUM_BUTTONS
#define XBOX_BUTTON_NAME_LENGTH 30
#define HOST_BUTTON_NAME_LENGTH 30
/* Represents the gui buttons of the xbox device currently being configured */ /* Represents the gui buttons of the xbox device currently being configured */
class Button class Button

View File

@ -50,7 +50,6 @@ EmuDevice::EmuDevice(int type, HWND hwnd, void *wnd)
case to_underlying(XBOX_INPUT_DEVICE::STEEL_BATTALION_CONTROLLER): { case to_underlying(XBOX_INPUT_DEVICE::STEEL_BATTALION_CONTROLLER): {
for (size_t i = 0; i < ARRAY_SIZE(button_sbc_id); i++) { for (size_t i = 0; i < ARRAY_SIZE(button_sbc_id); i++) {
printf("button id: %d, button idx: %d\n", button_sbc_id[i], i);
m_buttons.push_back(new Button(button_sbc_id[i], i, hwnd, wnd)); m_buttons.push_back(new Button(button_sbc_id[i], i, hwnd, wnd));
// Install the subclass for the button control // Install the subclass for the button control

View File

@ -323,7 +323,7 @@ void InputDeviceManager::DisconnectDevice(int port, int usb_port, bool ack)
void InputDeviceManager::BindHostDevice(int port, int usb_port, int type) void InputDeviceManager::BindHostDevice(int port, int usb_port, int type)
{ {
char dev_name[50]; char dev_name[50];
char dev_control_names[HIGHEST_NUM_BUTTONS][30]; char dev_control_names[HIGHEST_NUM_BUTTONS][HOST_BUTTON_NAME_LENGTH];
g_EmuShared->GetInputDevNameSettings(dev_name, port); g_EmuShared->GetInputDevNameSettings(dev_name, port);
g_EmuShared->GetInputBindingsSettings(dev_control_names, dev_num_buttons[type], port); g_EmuShared->GetInputBindingsSettings(dev_control_names, dev_num_buttons[type], port);

View File

@ -39,6 +39,13 @@
extern int dev_num_buttons[to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)]; extern int dev_num_buttons[to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)];
inline XBOX_INPUT_DEVICE input_support_list[] = {
XBOX_INPUT_DEVICE::DEVICE_INVALID,
XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE,
XBOX_INPUT_DEVICE::MS_CONTROLLER_S,
XBOX_INPUT_DEVICE::STEEL_BATTALION_CONTROLLER,
};
#pragma pack(1) #pragma pack(1)
// xpad in/out buffers stripped of the first two bytes // xpad in/out buffers stripped of the first two bytes

View File

@ -158,7 +158,7 @@ void InputWindow::BindButton(int ControlID)
// Don't block the message processing loop // Don't block the message processing loop
std::thread([this, dev, ControlID]() { std::thread([this, dev, ControlID]() {
EnableWindow(m_hwnd_window, FALSE); EnableWindow(m_hwnd_window, FALSE);
char current_text[30]; char current_text[HOST_BUTTON_NAME_LENGTH];
Button* xbox_button = m_DeviceConfig->FindButtonById(ControlID); Button* xbox_button = m_DeviceConfig->FindButtonById(ControlID);
xbox_button->GetText(current_text, sizeof(current_text)); xbox_button->GetText(current_text, sizeof(current_text));
xbox_button->UpdateText("..."); xbox_button->UpdateText("...");
@ -227,7 +227,7 @@ bool InputWindow::SaveProfile(const std::string& name)
profile.ProfileName = name; profile.ProfileName = name;
profile.DeviceName = m_host_dev; profile.DeviceName = m_host_dev;
for (int index = 0; index < m_max_num_buttons; index++) { for (int index = 0; index < m_max_num_buttons; index++) {
char dev_button[30]; char dev_button[HOST_BUTTON_NAME_LENGTH];
m_DeviceConfig->FindButtonByIndex(index)->GetText(dev_button, sizeof(dev_button)); m_DeviceConfig->FindButtonByIndex(index)->GetText(dev_button, sizeof(dev_button));
profile.ControlList.push_back(dev_button); profile.ControlList.push_back(dev_button);
} }

View File

@ -27,8 +27,6 @@
#pragma once #pragma once
#define BUF_NAME_LENGTH 30
#ifndef CXBXR_EMU_EXPORTS #ifndef CXBXR_EMU_EXPORTS
#include "gui/resource/ResCxbx.h" #include "gui/resource/ResCxbx.h"
@ -215,7 +213,7 @@ constexpr bool check_button_name_size(unsigned max_num_buttons)
{ {
case XBOX_CTRL_NUM_BUTTONS: { case XBOX_CTRL_NUM_BUTTONS: {
for (unsigned i = 0; i < max_num_buttons; i++) { for (unsigned i = 0; i < max_num_buttons; i++) {
if (std::char_traits<char>::length(button_xbox_ctrl_names[i]) > (BUF_NAME_LENGTH - 1)) { if (std::char_traits<char>::length(button_xbox_ctrl_names[i]) > (XBOX_BUTTON_NAME_LENGTH - 1)) {
return false; return false;
} }
} }
@ -224,7 +222,7 @@ constexpr bool check_button_name_size(unsigned max_num_buttons)
case SBC_NUM_BUTTONS: { case SBC_NUM_BUTTONS: {
for (unsigned i = 0; i < max_num_buttons; i++) { for (unsigned i = 0; i < max_num_buttons; i++) {
if (std::char_traits<char>::length(button_sbc_names[i]) > (BUF_NAME_LENGTH - 1)) { if (std::char_traits<char>::length(button_sbc_names[i]) > (XBOX_BUTTON_NAME_LENGTH - 1)) {
return false; return false;
} }
} }

View File

@ -130,21 +130,21 @@ class EmuShared : public Mutex
void SetInputDevTypeSettings(const int* type, int port) { Lock(); m_DeviceType[port] = *type; Unlock(); } void SetInputDevTypeSettings(const int* type, int port) { Lock(); m_DeviceType[port] = *type; Unlock(); }
void GetInputDevNameSettings(char* name, int port) { Lock(); strncpy(name, m_DeviceName[port], 50); Unlock(); } void GetInputDevNameSettings(char* name, int port) { Lock(); strncpy(name, m_DeviceName[port], 50); Unlock(); }
void SetInputDevNameSettings(const char* name, int port) { Lock(); strncpy(m_DeviceName[port], name, 50); Unlock(); } void SetInputDevNameSettings(const char* name, int port) { Lock(); strncpy(m_DeviceName[port], name, 50); Unlock(); }
void GetInputBindingsSettings(char button_str[][30], int max_num_buttons, int port) void GetInputBindingsSettings(char button_str[][HOST_BUTTON_NAME_LENGTH], int max_num_buttons, int port)
{ {
assert(max_num_buttons <= HIGHEST_NUM_BUTTONS); assert(max_num_buttons <= HIGHEST_NUM_BUTTONS);
Lock(); Lock();
for (int i = 0; i < max_num_buttons; i++) { for (int i = 0; i < max_num_buttons; i++) {
strncpy(button_str[i], m_DeviceControlNames[port][i], 30); strncpy(button_str[i], m_DeviceControlNames[port][i], HOST_BUTTON_NAME_LENGTH);
} }
Unlock(); Unlock();
} }
void SetInputBindingsSettings(const char button_str[][30], int max_num_buttons, int port) void SetInputBindingsSettings(const char button_str[][HOST_BUTTON_NAME_LENGTH], int max_num_buttons, int port)
{ {
assert(max_num_buttons <= HIGHEST_NUM_BUTTONS); assert(max_num_buttons <= HIGHEST_NUM_BUTTONS);
Lock(); Lock();
for (int i = 0; i < max_num_buttons; i++) { for (int i = 0; i < max_num_buttons; i++) {
strncpy(m_DeviceControlNames[port][i], button_str[i], 30); strncpy(m_DeviceControlNames[port][i], button_str[i], HOST_BUTTON_NAME_LENGTH);
} }
Unlock(); Unlock();
} }
@ -303,7 +303,7 @@ class EmuShared : public Mutex
bool m_bReserved4; bool m_bReserved4;
unsigned int m_dwKrnlProcID; // Only used for kernel mode level. unsigned int m_dwKrnlProcID; // Only used for kernel mode level.
int m_DeviceType[4]; int m_DeviceType[4];
char m_DeviceControlNames[4][HIGHEST_NUM_BUTTONS][30]; char m_DeviceControlNames[4][HIGHEST_NUM_BUTTONS][HOST_BUTTON_NAME_LENGTH];
char m_DeviceName[4][50]; char m_DeviceName[4][50];
long m_MoAxisRange; long m_MoAxisRange;
long m_MoWheelRange; long m_MoWheelRange;

View File

@ -51,14 +51,14 @@ xbox::PXPP_DEVICE_TYPE g_DeviceType_SBC = nullptr;
// Flag is unset after initialize devices is done by simulate LLE USB thread. // Flag is unset after initialize devices is done by simulate LLE USB thread.
std::atomic<bool> g_bIsDevicesInitializing = true; std::atomic<bool> g_bIsDevicesInitializing = true;
std::atomic<bool> g_bIsDevicesEmulating = false; std::atomic<bool> g_bIsDevicesEmulating = false;
static CXBX_XINPUT_IN_STATE InState[4]; static CXBX_XINPUT_IN_STATE g_InState[4];
// Global bridge for xbox controller to host, 4 elements for 4 ports. // Global bridge for xbox controller to host, 4 elements for 4 ports.
CXBX_CONTROLLER_HOST_BRIDGE g_XboxControllerHostBridge[4] = { CXBX_CONTROLLER_HOST_BRIDGE g_XboxControllerHostBridge[4] = {
{ NULL, PORT_INVALID, XBOX_INPUT_DEVICE::DEVICE_INVALID, &InState[0], false, false, false, { 0, 0, 0, 0, 0 } }, { NULL, PORT_INVALID, XBOX_INPUT_DEVICE::DEVICE_INVALID, &g_InState[0], false, false, false, { 0, 0, 0, 0, 0 } },
{ NULL, PORT_INVALID, XBOX_INPUT_DEVICE::DEVICE_INVALID, &InState[1], false, false, false, { 0, 0, 0, 0, 0 } }, { NULL, PORT_INVALID, XBOX_INPUT_DEVICE::DEVICE_INVALID, &g_InState[1], false, false, false, { 0, 0, 0, 0, 0 } },
{ NULL, PORT_INVALID, XBOX_INPUT_DEVICE::DEVICE_INVALID, &InState[2], false, false, false, { 0, 0, 0, 0, 0 } }, { NULL, PORT_INVALID, XBOX_INPUT_DEVICE::DEVICE_INVALID, &g_InState[2], false, false, false, { 0, 0, 0, 0, 0 } },
{ NULL, PORT_INVALID, XBOX_INPUT_DEVICE::DEVICE_INVALID, &InState[3], false, false, false, { 0, 0, 0, 0, 0 } }, { NULL, PORT_INVALID, XBOX_INPUT_DEVICE::DEVICE_INVALID, &g_InState[3], false, false, false, { 0, 0, 0, 0, 0 } },
}; };
@ -100,7 +100,7 @@ bool operator!=(xbox::PXPP_DEVICE_TYPE XppType, XBOX_INPUT_DEVICE XidType)
bool ConstructHleInputDevice(int Type, int Port) bool ConstructHleInputDevice(int Type, int Port)
{ {
g_bIsDevicesEmulating = true; g_bIsDevicesEmulating = true;
bool ret; bool ret = true;
switch (Type) switch (Type)
{ {
@ -115,7 +115,6 @@ bool ConstructHleInputDevice(int Type, int Port)
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucInputStateSize = sizeof(XpadInput); g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucInputStateSize = sizeof(XpadInput);
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucFeedbackSize = sizeof(XpadOutput); g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucFeedbackSize = sizeof(XpadOutput);
g_XboxControllerHostBridge[Port].XboxDeviceInfo.dwPacketNumber = 0; g_XboxControllerHostBridge[Port].XboxDeviceInfo.dwPacketNumber = 0;
ret = true;
} }
break; break;
@ -130,7 +129,6 @@ bool ConstructHleInputDevice(int Type, int Port)
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucInputStateSize = sizeof(XpadInput); g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucInputStateSize = sizeof(XpadInput);
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucFeedbackSize = sizeof(XpadOutput); g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucFeedbackSize = sizeof(XpadOutput);
g_XboxControllerHostBridge[Port].XboxDeviceInfo.dwPacketNumber = 0; g_XboxControllerHostBridge[Port].XboxDeviceInfo.dwPacketNumber = 0;
ret = true;
} }
break; break;
@ -148,7 +146,6 @@ bool ConstructHleInputDevice(int Type, int Port)
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucInputStateSize = sizeof(SBCInput); g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucInputStateSize = sizeof(SBCInput);
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucFeedbackSize = sizeof(SBCOutput); g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucFeedbackSize = sizeof(SBCOutput);
g_XboxControllerHostBridge[Port].XboxDeviceInfo.dwPacketNumber = 0; g_XboxControllerHostBridge[Port].XboxDeviceInfo.dwPacketNumber = 0;
ret = true;
} }
break; break;
@ -184,7 +181,7 @@ void DestructHleInputDevice(int Port)
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucInputStateSize = 0; g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucInputStateSize = 0;
g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucFeedbackSize = 0; g_XboxControllerHostBridge[Port].XboxDeviceInfo.ucFeedbackSize = 0;
g_XboxControllerHostBridge[Port].XboxDeviceInfo.dwPacketNumber = 0; g_XboxControllerHostBridge[Port].XboxDeviceInfo.dwPacketNumber = 0;
std::memset(&InState[Port], 0, sizeof(CXBX_XINPUT_IN_STATE)); std::memset(&g_InState[Port], 0, sizeof(CXBX_XINPUT_IN_STATE));
g_bIsDevicesEmulating = false; g_bIsDevicesEmulating = false;
} }

View File

@ -65,7 +65,7 @@ void SyncInputSettings(int port_num, int dev_type, bool is_opt)
return false; return false;
}); });
if (it != g_Settings->m_input_profiles[dev_type].end()) { if (it != g_Settings->m_input_profiles[dev_type].end()) {
char controls_name[HIGHEST_NUM_BUTTONS][30]; char controls_name[HIGHEST_NUM_BUTTONS][HOST_BUTTON_NAME_LENGTH];
for (int index = 0; index < dev_num_buttons[dev_type]; index++) { for (int index = 0; index < dev_num_buttons[dev_type]; index++) {
strncpy(controls_name[index], it->ControlList[index].c_str(), 30); strncpy(controls_name[index], it->ControlList[index].c_str(), 30);
} }
@ -116,12 +116,7 @@ INT_PTR CALLBACK DlgInputConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPAR
for (int i = 0, j = 0; i != 4; i++) { for (int i = 0, j = 0; i != 4; i++) {
HWND hHandle = GetDlgItem(hWndDlg, IDC_DEVICE_PORT1 + i); HWND hHandle = GetDlgItem(hWndDlg, IDC_DEVICE_PORT1 + i);
for (auto dev_type : { for (auto dev_type : input_support_list) {
XBOX_INPUT_DEVICE::DEVICE_INVALID,
XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE,
XBOX_INPUT_DEVICE::MS_CONTROLLER_S,
XBOX_INPUT_DEVICE::STEEL_BATTALION_CONTROLLER
}) {
LRESULT index = SendMessage(hHandle, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(GetInputDeviceName(to_underlying(dev_type)).c_str())); LRESULT index = SendMessage(hHandle, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(GetInputDeviceName(to_underlying(dev_type)).c_str()));
SendMessage(hHandle, CB_SETITEMDATA, index, to_underlying(dev_type)); SendMessage(hHandle, CB_SETITEMDATA, index, to_underlying(dev_type));
if (g_Settings->m_input_port[i].Type == to_underlying(dev_type)) { if (g_Settings->m_input_port[i].Type == to_underlying(dev_type)) {

View File

@ -121,7 +121,7 @@ void DukeInputWindow::UpdateRumble(int command)
switch (command) switch (command)
{ {
case RUMBLE_SET: { case RUMBLE_SET: {
char rumble[30]; char rumble[HOST_BUTTON_NAME_LENGTH];
SendMessage(m_hwnd_rumble_list, WM_GETTEXT, sizeof(rumble), reinterpret_cast<LPARAM>(rumble)); SendMessage(m_hwnd_rumble_list, WM_GETTEXT, sizeof(rumble), reinterpret_cast<LPARAM>(rumble));
m_rumble = rumble; m_rumble = rumble;
} }