diff --git a/Xb2XInput/Xb2XInput.cpp b/Xb2XInput/Xb2XInput.cpp index 4b28f8f..146ddc1 100644 --- a/Xb2XInput/Xb2XInput.cpp +++ b/Xb2XInput/Xb2XInput.cpp @@ -127,6 +127,7 @@ bool StartupDeleteEntry() // lower 12 bits are controller index into XboxController::controllers_ #define ID_CONTROLLER_GUIDEBTN 0x2000 #define ID_CONTROLLER_VIBRATION 0x4000 +#define ID_CONTROLLER_REMAP 0x8000 WCHAR tray_text[128]; @@ -178,6 +179,12 @@ void SysTrayShowContextMenu() InsertMenuA(hControllerMenu, 0xFFFFFFFF, MF_BYPOSITION | MF_STRING | MF_GRAYED, ID_TRAY_SEP, combo.c_str()); } + InsertMenu(hControllerMenu, 0xFFFFFFFF, MF_BYPOSITION | MF_STRING | + (controller.RemapEnabled() ? MF_CHECKED : MF_UNCHECKED), ID_CONTROLLER_REMAP + i, L"Enable button remappings"); + + auto remapCount = "- " + std::to_string(controller.Settings().button_remap.size()) + " buttons remapped"; + InsertMenuA(hControllerMenu, 0xFFFFFFFF, MF_BYPOSITION | MF_STRING | MF_GRAYED, ID_TRAY_SEP, remapCount.c_str()); + InsertMenu(hControllerMenu, 0xFFFFFFFF, MF_SEPARATOR, ID_TRAY_SEP, L"SEP"); // Insert current deadzone adjustments into context menu @@ -233,7 +240,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: wmId = LOWORD(wParam); - if (wmId & ID_CONTROLLER_GUIDEBTN || wmId & ID_CONTROLLER_VIBRATION) + if (wmId & ID_CONTROLLER_GUIDEBTN || wmId & ID_CONTROLLER_VIBRATION || wmId & ID_CONTROLLER_REMAP) { auto controllerId = wmId & 0xFFF; auto& pads = XboxController::GetControllers(); @@ -244,6 +251,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) controller.GuideEnabled(!controller.GuideEnabled()); if (wmId & ID_CONTROLLER_VIBRATION) controller.VibrationEnabled(!controller.VibrationEnabled()); + if (wmId & ID_CONTROLLER_REMAP) + controller.RemapEnabled(!controller.RemapEnabled()); } } else diff --git a/Xb2XInput/Xb2XInput.rc b/Xb2XInput/Xb2XInput.rc index ea9f2ec..927d8aa 100644 Binary files a/Xb2XInput/Xb2XInput.rc and b/Xb2XInput/Xb2XInput.rc differ diff --git a/Xb2XInput/XboxController.cpp b/Xb2XInput/XboxController.cpp index 7d81ecf..31b3e69 100644 --- a/Xb2XInput/XboxController.cpp +++ b/Xb2XInput/XboxController.cpp @@ -546,7 +546,7 @@ bool XboxController::update() deadZoneCalc(&triggerbuf, NULL, input_prev_.Gamepad.bAnalogButtons[OGXINPUT_GAMEPAD_RIGHT_TRIGGER], 0, settings_.deadzone.bRightTrigger, 0xFF); gamepad_.bRightTrigger = triggerbuf; - if (settings_.button_remap.size()) + if (settings_.remap_enabled && settings_.button_remap.size()) { auto buttons = gamepad_.wButtons; gamepad_.wButtons = 0; diff --git a/Xb2XInput/XboxController.hpp b/Xb2XInput/XboxController.hpp index d8759ad..5e9d6ed 100644 --- a/Xb2XInput/XboxController.hpp +++ b/Xb2XInput/XboxController.hpp @@ -139,6 +139,11 @@ class XboxController bool VibrationEnabled() { return settings_.vibration_enabled; } void VibrationEnabled(bool value); + bool RemapEnabled() { return settings_.remap_enabled; } + void RemapEnabled(bool value) { settings_.remap_enabled = value; } + + const UserSettings& Settings() { return settings_; } + XboxController(libusb_device_handle* handle, uint8_t* usb_ports, int num_ports); ~XboxController(); int GetProductId() const { return usb_product_; }