Merge remote-tracking branch 'GliniakRepo/disablePositiveVibes' into canary_pr
This commit is contained in:
commit
006f3adad3
|
@ -31,6 +31,7 @@
|
||||||
#include "xenia/emulator.h"
|
#include "xenia/emulator.h"
|
||||||
#include "xenia/gpu/command_processor.h"
|
#include "xenia/gpu/command_processor.h"
|
||||||
#include "xenia/gpu/graphics_system.h"
|
#include "xenia/gpu/graphics_system.h"
|
||||||
|
#include "xenia/hid/input_system.h"
|
||||||
#include "xenia/ui/file_picker.h"
|
#include "xenia/ui/file_picker.h"
|
||||||
#include "xenia/ui/graphics_provider.h"
|
#include "xenia/ui/graphics_provider.h"
|
||||||
#include "xenia/ui/imgui_dialog.h"
|
#include "xenia/ui/imgui_dialog.h"
|
||||||
|
@ -586,6 +587,15 @@ bool EmulatorWindow::Initialize() {
|
||||||
}
|
}
|
||||||
main_menu->AddChild(std::move(display_menu));
|
main_menu->AddChild(std::move(display_menu));
|
||||||
|
|
||||||
|
// HID menu.
|
||||||
|
auto hid_menu = MenuItem::Create(MenuItem::Type::kPopup, "&HID");
|
||||||
|
{
|
||||||
|
hid_menu->AddChild(MenuItem::Create(
|
||||||
|
MenuItem::Type::kString, "&Toggle controller vibration", "",
|
||||||
|
std::bind(&EmulatorWindow::ToggleControllerVibration, this)));
|
||||||
|
}
|
||||||
|
main_menu->AddChild(std::move(hid_menu));
|
||||||
|
|
||||||
// Help menu.
|
// Help menu.
|
||||||
auto help_menu = MenuItem::Create(MenuItem::Type::kPopup, "&Help");
|
auto help_menu = MenuItem::Create(MenuItem::Type::kPopup, "&Help");
|
||||||
{
|
{
|
||||||
|
@ -936,6 +946,10 @@ void EmulatorWindow::ToggleDisplayConfigDialog() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmulatorWindow::ToggleControllerVibration() {
|
||||||
|
emulator()->input_system()->ToggleVibration();
|
||||||
|
}
|
||||||
|
|
||||||
void EmulatorWindow::ShowCompatibility() {
|
void EmulatorWindow::ShowCompatibility() {
|
||||||
const std::string_view base_url =
|
const std::string_view base_url =
|
||||||
"https://github.com/xenia-project/game-compatibility/issues";
|
"https://github.com/xenia-project/game-compatibility/issues";
|
||||||
|
|
|
@ -139,6 +139,7 @@ class EmulatorWindow {
|
||||||
void GpuTraceFrame();
|
void GpuTraceFrame();
|
||||||
void GpuClearCaches();
|
void GpuClearCaches();
|
||||||
void ToggleDisplayConfigDialog();
|
void ToggleDisplayConfigDialog();
|
||||||
|
void ToggleControllerVibration();
|
||||||
void ShowCompatibility();
|
void ShowCompatibility();
|
||||||
void ShowFAQ();
|
void ShowFAQ();
|
||||||
void ShowBuildCommit();
|
void ShowBuildCommit();
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace hid {
|
namespace hid {
|
||||||
|
|
||||||
|
DEFINE_bool(vibration, true, "Toggle controller vibration.", "HID");
|
||||||
|
|
||||||
InputSystem::InputSystem(xe::ui::Window* window) : window_(window) {}
|
InputSystem::InputSystem(xe::ui::Window* window) : window_(window) {}
|
||||||
|
|
||||||
InputSystem::~InputSystem() = default;
|
InputSystem::~InputSystem() = default;
|
||||||
|
@ -62,10 +64,10 @@ X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE* out_state) {
|
||||||
X_RESULT InputSystem::SetState(uint32_t user_index,
|
X_RESULT InputSystem::SetState(uint32_t user_index,
|
||||||
X_INPUT_VIBRATION* vibration) {
|
X_INPUT_VIBRATION* vibration) {
|
||||||
SCOPE_profile_cpu_f("hid");
|
SCOPE_profile_cpu_f("hid");
|
||||||
|
X_INPUT_VIBRATION modified_vibration = ModifyVibrationLevel(vibration);
|
||||||
bool any_connected = false;
|
bool any_connected = false;
|
||||||
for (auto& driver : drivers_) {
|
for (auto& driver : drivers_) {
|
||||||
X_RESULT result = driver->SetState(user_index, vibration);
|
X_RESULT result = driver->SetState(user_index, &modified_vibration);
|
||||||
if (result != X_ERROR_DEVICE_NOT_CONNECTED) {
|
if (result != X_ERROR_DEVICE_NOT_CONNECTED) {
|
||||||
any_connected = true;
|
any_connected = true;
|
||||||
}
|
}
|
||||||
|
@ -93,5 +95,28 @@ X_RESULT InputSystem::GetKeystroke(uint32_t user_index, uint32_t flags,
|
||||||
return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
|
return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputSystem::ToggleVibration() {
|
||||||
|
OVERRIDE_bool(vibration, !cvars::vibration);
|
||||||
|
// Send instant update to vibration state to prevent awaiting for next tick.
|
||||||
|
X_INPUT_VIBRATION vibration = X_INPUT_VIBRATION();
|
||||||
|
|
||||||
|
for (uint8_t user_index = 0; user_index < 4; user_index++) {
|
||||||
|
SetState(user_index, &vibration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
X_INPUT_VIBRATION InputSystem::ModifyVibrationLevel(
|
||||||
|
X_INPUT_VIBRATION* vibration) {
|
||||||
|
X_INPUT_VIBRATION modified_vibration = *vibration;
|
||||||
|
if (cvars::vibration) {
|
||||||
|
return modified_vibration;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(Gliniak): Use modifier instead of boolean value.
|
||||||
|
modified_vibration.left_motor_speed = 0;
|
||||||
|
modified_vibration.right_motor_speed = 0;
|
||||||
|
return modified_vibration;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace hid
|
} // namespace hid
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
|
@ -44,10 +44,14 @@ class InputSystem {
|
||||||
X_RESULT GetKeystroke(uint32_t user_index, uint32_t flags,
|
X_RESULT GetKeystroke(uint32_t user_index, uint32_t flags,
|
||||||
X_INPUT_KEYSTROKE* out_keystroke);
|
X_INPUT_KEYSTROKE* out_keystroke);
|
||||||
|
|
||||||
|
void ToggleVibration();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
xe::ui::Window* window_ = nullptr;
|
xe::ui::Window* window_ = nullptr;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<InputDriver>> drivers_;
|
std::vector<std::unique_ptr<InputDriver>> drivers_;
|
||||||
|
|
||||||
|
X_INPUT_VIBRATION ModifyVibrationLevel(X_INPUT_VIBRATION* vibration);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace hid
|
} // namespace hid
|
||||||
|
|
Loading…
Reference in New Issue