mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-07 07:25:26 +00:00
input/qt: let user choose raw mouse device
This commit is contained in:
parent
dae4eb2d0e
commit
5a08ae4f41
7 changed files with 118 additions and 13 deletions
|
|
@ -12,6 +12,8 @@ struct raw_mouse_config : cfg::node
|
|||
public:
|
||||
using cfg::node::node;
|
||||
|
||||
cfg::string device{this, "Device", ""};
|
||||
|
||||
cfg::_float<10, 1000> mouse_acceleration{ this, "Mouse Acceleration", 100.0f, true };
|
||||
|
||||
cfg::string mouse_button_1{this, "Button 1", "Button 1"};
|
||||
|
|
|
|||
|
|
@ -214,6 +214,12 @@ void raw_mouse::update_values(const RAWMOUSE& state)
|
|||
}
|
||||
#endif
|
||||
|
||||
raw_mouse_handler::raw_mouse_handler(bool ignore_config)
|
||||
: MouseHandlerBase()
|
||||
, m_ignore_config(ignore_config)
|
||||
{
|
||||
}
|
||||
|
||||
raw_mouse_handler::~raw_mouse_handler()
|
||||
{
|
||||
if (m_raw_mice.empty())
|
||||
|
|
@ -253,7 +259,16 @@ void raw_mouse_handler::Init(const u32 max_connect)
|
|||
|
||||
m_mice.clear();
|
||||
|
||||
for (u32 i = 0; i < std::min(::size32(m_raw_mice), max_connect); i++)
|
||||
// Get max device index
|
||||
u32 now_connect = 0;
|
||||
std::set<u32> connected_mice{};
|
||||
for (const auto& [handle, mouse] : m_raw_mice)
|
||||
{
|
||||
now_connect = std::max(now_connect, mouse.index());
|
||||
connected_mice.insert(mouse.index());
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < now_connect; i++)
|
||||
{
|
||||
m_mice.emplace_back(Mouse());
|
||||
}
|
||||
|
|
@ -265,7 +280,7 @@ void raw_mouse_handler::Init(const u32 max_connect)
|
|||
|
||||
for (u32 i = 0; i < m_info.now_connect; i++)
|
||||
{
|
||||
m_info.status[i] = CELL_MOUSE_STATUS_CONNECTED;
|
||||
m_info.status[i] = connected_mice.contains(i) ? CELL_MOUSE_STATUS_CONNECTED : CELL_MOUSE_STATUS_DISCONNECTED;
|
||||
m_info.mode[i] = CELL_MOUSE_INFO_TABLET_MOUSE_MODE;
|
||||
m_info.tablet_is_supported[i] = CELL_MOUSE_INFO_TABLET_NOT_SUPPORTED;
|
||||
m_info.vendor_id[0] = 0x1234;
|
||||
|
|
@ -371,9 +386,24 @@ void raw_mouse_handler::enumerate_devices(u32 max_connect)
|
|||
|
||||
const std::string device_name = wchar_to_utf8(buf.data());
|
||||
|
||||
input_log.notice("raw_mouse_handler: adding device %d: '%s'", m_raw_mice.size(), device_name);
|
||||
if (m_ignore_config)
|
||||
{
|
||||
input_log.notice("raw_mouse_handler: adding device %d: '%s'", m_raw_mice.size(), device_name);
|
||||
m_raw_mice[device.hDevice] = raw_mouse(::size32(m_raw_mice), device_name, device.hDevice, this);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_raw_mice[device.hDevice] = raw_mouse(::size32(m_raw_mice), device_name, device.hDevice, this);
|
||||
for (u32 i = 0; i < std::min(max_connect, ::size32(g_cfg_raw_mouse.players)); i++)
|
||||
{
|
||||
const auto& player = ::at32(g_cfg_raw_mouse.players, i);
|
||||
|
||||
if (player && player->device.to_string() == device_name)
|
||||
{
|
||||
input_log.notice("raw_mouse_handler: adding device %d: '%s'", m_raw_mice.size(), device_name);
|
||||
m_raw_mice[device.hDevice] = raw_mouse(i, device_name, device.hDevice, this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "Emu/Io/MouseHandler.h"
|
||||
#include "Emu/RSX/display.h"
|
||||
#include "Utilities/Config.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
|
@ -37,6 +38,9 @@ public:
|
|||
void update_values(const RAWMOUSE& state);
|
||||
#endif
|
||||
|
||||
const std::string& device_name() const { return m_device_name; }
|
||||
u32 index() const { return m_index; }
|
||||
|
||||
private:
|
||||
static std::pair<int, int> get_mouse_button(const cfg::string& button);
|
||||
|
||||
|
|
@ -57,13 +61,14 @@ private:
|
|||
|
||||
class raw_mouse_handler final : public MouseHandlerBase
|
||||
{
|
||||
using MouseHandlerBase::MouseHandlerBase;
|
||||
|
||||
public:
|
||||
raw_mouse_handler(bool ignore_config = false);
|
||||
virtual ~raw_mouse_handler();
|
||||
|
||||
void Init(const u32 max_connect) override;
|
||||
|
||||
const std::map<void*, raw_mouse>& get_mice() const { return m_raw_mice; };
|
||||
|
||||
#ifdef _WIN32
|
||||
void handle_native_event(const MSG& msg);
|
||||
#endif
|
||||
|
|
@ -71,5 +76,6 @@ public:
|
|||
private:
|
||||
void enumerate_devices(u32 max_connect);
|
||||
|
||||
bool m_ignore_config = false;
|
||||
std::map<void*, raw_mouse> m_raw_mice;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue