|
18 | 18 |
|
19 | 19 | LOG_CHANNEL(evdev_log, "evdev");
|
20 | 20 |
|
| 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 | + |
21 | 48 | evdev_joystick_handler::evdev_joystick_handler()
|
22 | 49 | : PadHandlerBase(pad_handler::evdev)
|
23 | 50 | {
|
@@ -110,7 +137,12 @@ bool evdev_joystick_handler::Init()
|
110 | 137 | if (m_is_init)
|
111 | 138 | return true;
|
112 | 139 |
|
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()); |
114 | 146 |
|
115 | 147 | if (!m_pos_axis_config.exist())
|
116 | 148 | m_pos_axis_config.save();
|
@@ -783,7 +815,7 @@ std::shared_ptr<evdev_joystick_handler::EvdevDevice> evdev_joystick_handler::add
|
783 | 815 | // Let's log axis information while we are in the settings in order to identify problems more easily.
|
784 | 816 | for (const auto& [code, axis_name] : axis_list)
|
785 | 817 | {
|
786 |
| - if (const input_absinfo *info = libevdev_get_abs_info(dev, code)) |
| 818 | + if (const input_absinfo* info = libevdev_get_abs_info(dev, code)) |
787 | 819 | {
|
788 | 820 | const char* code_name = libevdev_event_code_get_name(EV_ABS, code);
|
789 | 821 | 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
|
857 | 889 | // A device must not mix regular directional axes and accelerometer axes on the same event node.
|
858 | 890 | for (const auto& [code, axis_name] : axis_list)
|
859 | 891 | {
|
860 |
| - if (const input_absinfo *info = libevdev_get_abs_info(dev, code)) |
| 892 | + if (const input_absinfo* info = libevdev_get_abs_info(dev, code)) |
861 | 893 | {
|
862 | 894 | const bool is_accel = code == ABS_X || code == ABS_Y || code == ABS_Z;
|
863 | 895 | const char* code_name = libevdev_event_code_get_name(EV_ABS, code);
|
|
0 commit comments