mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
72 lines
2.3 KiB
C
72 lines
2.3 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include "Emu/Io/PadHandler.h"
|
||
|
|
#include <mmsystem.h>
|
||
|
|
#include "Utilities/Config.h"
|
||
|
|
|
||
|
|
struct MMJoystickConfig final : cfg::node
|
||
|
|
{
|
||
|
|
const std::string cfg_name = fs::get_config_dir() + "/config_mmjoystick.yml";
|
||
|
|
|
||
|
|
//cfg::int32_entry left_stick_left{ *this, "Left Analog Stick Left", static_cast<int>('A') };
|
||
|
|
//cfg::int32_entry left_stick_down{ *this, "Left Analog Stick Down", static_cast<int>('S') };
|
||
|
|
//cfg::int32_entry left_stick_right{ *this, "Left Analog Stick Right", static_cast<int>('D') };
|
||
|
|
//cfg::int32_entry left_stick_up{ *this, "Left Analog Stick Up", static_cast<int>('W') };
|
||
|
|
//cfg::int32_entry right_stick_left{ *this, "Right Analog Stick Left", 313 };
|
||
|
|
//cfg::int32_entry right_stick_down{ *this, "Right Analog Stick Down", 367 };
|
||
|
|
//cfg::int32_entry right_stick_right{ *this, "Right Analog Stick Right", 312 };
|
||
|
|
//cfg::int32_entry right_stick_up{ *this, "Right Analog Stick Up", 366 };
|
||
|
|
cfg::int32_entry start{ *this, "Start", JOY_BUTTON9 };
|
||
|
|
cfg::int32_entry select{ *this, "Select", JOY_BUTTON10 };
|
||
|
|
cfg::int32_entry square{ *this, "Square", JOY_BUTTON4 };
|
||
|
|
cfg::int32_entry cross{ *this, "Cross", JOY_BUTTON3 };
|
||
|
|
cfg::int32_entry circle{ *this, "Circle", JOY_BUTTON2 };
|
||
|
|
cfg::int32_entry triangle{ *this, "Triangle", JOY_BUTTON1 };
|
||
|
|
//cfg::int32_entry left{ *this, "Left", 314 };
|
||
|
|
//cfg::int32_entry down{ *this, "Down", 317 };
|
||
|
|
//cfg::int32_entry right{ *this, "Right", 316 };
|
||
|
|
//cfg::int32_entry up{ *this, "Up", 315 };
|
||
|
|
cfg::int32_entry r1{ *this, "R1", JOY_BUTTON8 };
|
||
|
|
cfg::int32_entry r2{ *this, "R2", JOY_BUTTON6 };
|
||
|
|
cfg::int32_entry r3{ *this, "R3", JOY_BUTTON12 };
|
||
|
|
cfg::int32_entry l1{ *this, "L1", JOY_BUTTON7 };
|
||
|
|
cfg::int32_entry l2{ *this, "L2", JOY_BUTTON5 };
|
||
|
|
cfg::int32_entry l3{ *this, "L3", JOY_BUTTON11 };
|
||
|
|
|
||
|
|
bool load()
|
||
|
|
{
|
||
|
|
if (fs::file cfg_file{ cfg_name, fs::read })
|
||
|
|
{
|
||
|
|
return from_string(cfg_file.to_string());
|
||
|
|
}
|
||
|
|
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
void save()
|
||
|
|
{
|
||
|
|
fs::file(cfg_name, fs::rewrite).write(to_string());
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
class MMJoystickHandler final : public PadHandlerBase
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
MMJoystickHandler();
|
||
|
|
~MMJoystickHandler();
|
||
|
|
|
||
|
|
void Init(const u32 max_connect) override;
|
||
|
|
void Close();
|
||
|
|
|
||
|
|
private:
|
||
|
|
DWORD ThreadProcedure();
|
||
|
|
static DWORD WINAPI ThreadProcProxy(LPVOID parameter);
|
||
|
|
|
||
|
|
private:
|
||
|
|
u32 supportedJoysticks;
|
||
|
|
mutable bool active;
|
||
|
|
HANDLE thread;
|
||
|
|
JOYINFOEX js_info;
|
||
|
|
JOYCAPS js_caps;
|
||
|
|
};
|