Skip to content

Commit fcb6bc7

Browse files
committed
evdev: log positive axis config
1 parent 9c5b3a2 commit fcb6bc7

File tree

2 files changed

+38
-28
lines changed

2 files changed

+38
-28
lines changed

rpcs3/Input/evdev_joystick_handler.cpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,33 @@
1818

1919
LOG_CHANNEL(evdev_log, "evdev");
2020

21+
bool positive_axis::load()
22+
{
23+
if (fs::file cfg_file{ cfg_name, fs::read })
24+
{
25+
return from_string(cfg_file.to_string());
26+
}
27+
28+
from_default();
29+
return false;
30+
}
31+
32+
void positive_axis::save() const
33+
{
34+
fs::pending_file file(cfg_name);
35+
36+
if (file.file)
37+
{
38+
file.file.write(to_string());
39+
file.commit();
40+
}
41+
}
42+
43+
bool positive_axis::exist() const
44+
{
45+
return fs::is_file(cfg_name);
46+
}
47+
2148
evdev_joystick_handler::evdev_joystick_handler()
2249
: PadHandlerBase(pad_handler::evdev)
2350
{
@@ -110,7 +137,12 @@ bool evdev_joystick_handler::Init()
110137
if (m_is_init)
111138
return true;
112139

113-
m_pos_axis_config.load();
140+
if (!m_pos_axis_config.load())
141+
{
142+
evdev_log.notice("positive_axis config missing. Using defaults");
143+
}
144+
145+
evdev_log.notice("positive_axis config=\n%s", m_pos_axis_config.to_string());
114146

115147
if (!m_pos_axis_config.exist())
116148
m_pos_axis_config.save();
@@ -783,7 +815,7 @@ std::shared_ptr<evdev_joystick_handler::EvdevDevice> evdev_joystick_handler::add
783815
// Let's log axis information while we are in the settings in order to identify problems more easily.
784816
for (const auto& [code, axis_name] : axis_list)
785817
{
786-
if (const input_absinfo *info = libevdev_get_abs_info(dev, code))
818+
if (const input_absinfo* info = libevdev_get_abs_info(dev, code))
787819
{
788820
const char* code_name = libevdev_event_code_get_name(EV_ABS, code);
789821
evdev_log.notice("Axis info for %s: %s (%s) => minimum=%d, maximum=%d, fuzz=%d, flat=%d, resolution=%d",
@@ -857,7 +889,7 @@ std::shared_ptr<evdev_joystick_handler::EvdevDevice> evdev_joystick_handler::add
857889
// A device must not mix regular directional axes and accelerometer axes on the same event node.
858890
for (const auto& [code, axis_name] : axis_list)
859891
{
860-
if (const input_absinfo *info = libevdev_get_abs_info(dev, code))
892+
if (const input_absinfo* info = libevdev_get_abs_info(dev, code))
861893
{
862894
const bool is_accel = code == ABS_X || code == ABS_Y || code == ABS_Z;
863895
const char* code_name = libevdev_event_code_get_name(EV_ABS, code);

rpcs3/Input/evdev_joystick_handler.h

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,9 @@ struct positive_axis : cfg::node
5757
cfg::_bool abs_mt_tool_x{ this, "ABS_MT_TOOL_X", false };
5858
cfg::_bool abs_mt_tool_y{ this, "ABS_MT_TOOL_Y", false };
5959

60-
bool load()
61-
{
62-
if (fs::file cfg_file{ cfg_name, fs::read })
63-
{
64-
return from_string(cfg_file.to_string());
65-
}
66-
67-
return false;
68-
}
69-
70-
void save()
71-
{
72-
fs::pending_file file(cfg_name);
73-
74-
if (file.file)
75-
{
76-
file.file.write(to_string());
77-
file.commit();
78-
}
79-
}
80-
81-
bool exist()
82-
{
83-
return fs::is_file(cfg_name);
84-
}
60+
bool load();
61+
void save() const;
62+
bool exist() const;
8563
};
8664

8765
class evdev_joystick_handler final : public PadHandlerBase

0 commit comments

Comments
 (0)