ControllerInterface: Adjust sort priorities to ensure default keyboard-mouse device is first.
This commit is contained in:
parent
04c246d11f
commit
42e73547eb
|
@ -4,6 +4,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -147,6 +148,7 @@ public:
|
||||||
// A higher priority means it will be one of the first ones (smaller index), making it more
|
// A higher priority means it will be one of the first ones (smaller index), making it more
|
||||||
// likely to be index 0, which is automatically set as the default device when there isn't one.
|
// likely to be index 0, which is automatically set as the default device when there isn't one.
|
||||||
// Every platform should have at least one device with priority >= 0.
|
// Every platform should have at least one device with priority >= 0.
|
||||||
|
static constexpr int DEFAULT_DEVICE_SORT_PRIORITY = std::numeric_limits<int>::max();
|
||||||
virtual int GetSortPriority() const { return 0; }
|
virtual int GetSortPriority() const { return 0; }
|
||||||
|
|
||||||
const std::vector<Input*>& Inputs() const { return m_inputs; }
|
const std::vector<Input*>& Inputs() const { return m_inputs; }
|
||||||
|
|
|
@ -271,7 +271,7 @@ std::string KeyboardMouse::GetSource() const
|
||||||
// Give this device a higher priority to make sure it shows first
|
// Give this device a higher priority to make sure it shows first
|
||||||
int KeyboardMouse::GetSortPriority() const
|
int KeyboardMouse::GetSortPriority() const
|
||||||
{
|
{
|
||||||
return 5;
|
return DEFAULT_DEVICE_SORT_PRIORITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyboardMouse::IsVirtualDevice() const
|
bool KeyboardMouse::IsVirtualDevice() const
|
||||||
|
|
|
@ -69,6 +69,7 @@ public:
|
||||||
|
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::string GetSource() const override;
|
std::string GetSource() const override;
|
||||||
|
int GetSortPriority() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MainThreadInitialization(void* view);
|
void MainThreadInitialization(void* view);
|
||||||
|
|
|
@ -283,6 +283,11 @@ std::string KeyboardAndMouse::GetSource() const
|
||||||
return Quartz::GetSourceName();
|
return Quartz::GetSourceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int KeyboardAndMouse::GetSortPriority() const
|
||||||
|
{
|
||||||
|
return DEFAULT_DEVICE_SORT_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
ControlState KeyboardAndMouse::Cursor::GetState() const
|
ControlState KeyboardAndMouse::Cursor::GetState() const
|
||||||
{
|
{
|
||||||
return std::max(0.0, ControlState(m_axis) / (m_positive ? 1.0 : -1.0));
|
return std::max(0.0, ControlState(m_axis) / (m_positive ? 1.0 : -1.0));
|
||||||
|
|
|
@ -414,6 +414,11 @@ std::string KeyboardMouse::GetSource() const
|
||||||
return std::string(SOURCE_NAME);
|
return std::string(SOURCE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int KeyboardMouse::GetSortPriority() const
|
||||||
|
{
|
||||||
|
return DEFAULT_DEVICE_SORT_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
KeyboardMouse::Key::Key(Display* const display, KeyCode keycode, const char* keyboard)
|
KeyboardMouse::Key::Key(Display* const display, KeyCode keycode, const char* keyboard)
|
||||||
: m_display(display), m_keyboard(keyboard), m_keycode(keycode)
|
: m_display(display), m_keyboard(keyboard), m_keycode(keycode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,6 +120,7 @@ public:
|
||||||
|
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::string GetSource() const override;
|
std::string GetSource() const override;
|
||||||
|
int GetSortPriority() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Window m_window;
|
Window m_window;
|
||||||
|
|
Loading…
Reference in New Issue