InputManager: Support multiple mice via raw input
Only on Windows for now.
This commit is contained in:
@ -207,8 +207,8 @@ bool GunCon::Transfer(const u8 data_in, u8* data_out)
|
||||
void GunCon::UpdatePosition()
|
||||
{
|
||||
float display_x, display_y;
|
||||
const auto& [window_x, window_y] =
|
||||
(m_has_relative_binds) ? GetAbsolutePositionFromRelativeAxes() : InputManager::GetPointerAbsolutePosition(0);
|
||||
const auto& [window_x, window_y] = (m_has_relative_binds) ? GetAbsolutePositionFromRelativeAxes() :
|
||||
InputManager::GetPointerAbsolutePosition(m_cursor_index);
|
||||
g_gpu->ConvertScreenCoordinatesToDisplayCoordinates(window_x, window_y, &display_x, &display_y);
|
||||
|
||||
// are we within the active display area?
|
||||
@ -245,7 +245,7 @@ bool GunCon::CanUseSoftwareCursor() const
|
||||
|
||||
u32 GunCon::GetSoftwarePointerIndex() const
|
||||
{
|
||||
return m_has_relative_binds ? (InputManager::MAX_POINTER_DEVICES + m_index) : 0;
|
||||
return m_has_relative_binds ? (InputManager::MAX_POINTER_DEVICES + m_index) : m_cursor_index;
|
||||
}
|
||||
|
||||
void GunCon::UpdateSoftwarePointerPosition()
|
||||
@ -273,6 +273,7 @@ static const Controller::ControllerBindingInfo s_binding_info[] = {
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
{"Pointer", TRANSLATE_NOOP("GunCon", "Pointer/Aiming"), ICON_PF_MOUSE, static_cast<u32>(GunCon::Binding::ButtonCount), InputBindingInfo::Type::AbsolutePointer, GenericInputBinding::Unknown},
|
||||
BUTTON("Trigger", TRANSLATE_NOOP("GunCon", "Trigger"), ICON_PF_CROSS, GunCon::Binding::Trigger, GenericInputBinding::R2),
|
||||
BUTTON("ShootOffscreen", TRANSLATE_NOOP("GunCon", "Shoot Offscreen"), nullptr, GunCon::Binding::ShootOffscreen, GenericInputBinding::L2),
|
||||
BUTTON("A", TRANSLATE_NOOP("GunCon", "A"), ICON_PF_BUTTON_A, GunCon::Binding::A, GenericInputBinding::Cross),
|
||||
@ -306,9 +307,9 @@ const Controller::ControllerInfo GunCon::INFO = {
|
||||
ControllerType::GunCon, "GunCon", TRANSLATE_NOOP("ControllerType", "GunCon"), nullptr,
|
||||
s_binding_info, s_settings, Controller::VibrationCapabilities::NoVibration};
|
||||
|
||||
void GunCon::LoadSettings(SettingsInterface& si, const char* section)
|
||||
void GunCon::LoadSettings(SettingsInterface& si, const char* section, bool initial)
|
||||
{
|
||||
Controller::LoadSettings(si, section);
|
||||
Controller::LoadSettings(si, section, initial);
|
||||
|
||||
m_x_scale = si.GetFloatValue(section, "XScale", 1.0f);
|
||||
|
||||
@ -334,13 +335,15 @@ void GunCon::LoadSettings(SettingsInterface& si, const char* section)
|
||||
|
||||
m_has_relative_binds = (si.ContainsValue(section, "RelativeLeft") || si.ContainsValue(section, "RelativeRight") ||
|
||||
si.ContainsValue(section, "RelativeUp") || si.ContainsValue(section, "RelativeDown"));
|
||||
m_cursor_index =
|
||||
static_cast<u8>(InputManager::GetIndexFromPointerBinding(si.GetStringValue(section, "Pointer")).value_or(0));
|
||||
|
||||
const s32 new_pointer_index = GetSoftwarePointerIndex();
|
||||
|
||||
if (prev_pointer_index != new_pointer_index || m_cursor_path != cursor_path || m_cursor_scale != cursor_scale ||
|
||||
m_cursor_color != cursor_color)
|
||||
{
|
||||
if (prev_pointer_index != new_pointer_index &&
|
||||
if (!initial && prev_pointer_index != new_pointer_index &&
|
||||
static_cast<u32>(prev_pointer_index) < InputManager::MAX_SOFTWARE_CURSORS)
|
||||
{
|
||||
ImGuiManager::ClearSoftwareCursor(prev_pointer_index);
|
||||
|
||||
Reference in New Issue
Block a user