clang format pass

This commit is contained in:
Katharine Chui 2025-05-01 10:18:21 +02:00
parent dc25f9e08e
commit 0729f7d078
10 changed files with 1225 additions and 1214 deletions

View file

@ -7,7 +7,6 @@
// shifter input ref // shifter input ref
// https://github.com/sonik-br/lgff_wheel_adapter/blob/d97f7823154818e1b3edff6d51498a122c302728/pico_lgff_wheel_adapter/reports.h#L265-L310 // https://github.com/sonik-br/lgff_wheel_adapter/blob/d97f7823154818e1b3edff6d51498a122c302728/pico_lgff_wheel_adapter/reports.h#L265-L310
#include "stdafx.h" #include "stdafx.h"
#ifdef HAVE_SDL3 #ifdef HAVE_SDL3
@ -66,8 +65,7 @@ usb_device_logitech_g27::usb_device_logitech_g27(u32 controller_index, const std
SDL_HapticDirection direction = { SDL_HapticDirection direction = {
.type = SDL_HAPTIC_POLAR, .type = SDL_HAPTIC_POLAR,
.dir = {27000, 0} .dir = {27000, 0}};
};
default_spring_effect.type = SDL_HAPTIC_SPRING; default_spring_effect.type = SDL_HAPTIC_SPRING;
default_spring_effect.condition.direction = direction; default_spring_effect.condition.direction = direction;
default_spring_effect.condition.length = SDL_HAPTIC_INFINITY; default_spring_effect.condition.length = SDL_HAPTIC_INFINITY;
@ -101,7 +99,8 @@ usb_device_logitech_g27::usb_device_logitech_g27(u32 controller_index, const std
} }
} }
bool usb_device_logitech_g27::open_device(){ bool usb_device_logitech_g27::open_device()
{
return enabled; return enabled;
} }
@ -268,7 +267,6 @@ void usb_device_logitech_g27::sdl_refresh()
uint32_t led_product_id = g_cfg_logitech_g27.led_device_type_id.get() & 0xFFFF; uint32_t led_product_id = g_cfg_logitech_g27.led_device_type_id.get() & 0xFFFF;
g_cfg_logitech_g27.m_mutex.unlock(); g_cfg_logitech_g27.m_mutex.unlock();
SDL_Joystick* new_led_joystick_handle = nullptr; SDL_Joystick* new_led_joystick_handle = nullptr;
SDL_Haptic* new_haptic_handle = nullptr; SDL_Haptic* new_haptic_handle = nullptr;
std::map<uint32_t, std::vector<SDL_Joystick*>> new_joysticks; std::map<uint32_t, std::vector<SDL_Joystick*>> new_joysticks;
@ -833,8 +831,7 @@ void usb_device_logitech_g27::interrupt_transfer(u32 buf_size, u8* buf, u32 endp
SDL_HapticDirection direction = { SDL_HapticDirection direction = {
.type = SDL_HAPTIC_POLAR, .type = SDL_HAPTIC_POLAR,
.dir = {27000, 0} .dir = {27000, 0}};
};
if (reverse_effects) if (reverse_effects)
{ {
direction.dir[0] = 9000; direction.dir[0] = 9000;
@ -934,7 +931,8 @@ void usb_device_logitech_g27::interrupt_transfer(u32 buf_size, u8* buf, u32 endp
case 0x0c: case 0x0c:
{ {
// Download/Download play/Refresh // Download/Download play/Refresh
for (int i = 0;i < 4;i++){ for (int i = 0; i < 4; i++)
{
SDL_HapticEffect new_effect = {0}; SDL_HapticEffect new_effect = {0};
// hack: need to reduce Download play spams for some drivers // hack: need to reduce Download play spams for some drivers
bool update_hack = false; bool update_hack = false;
@ -1433,7 +1431,8 @@ void usb_device_logitech_g27::interrupt_transfer(u32 buf_size, u8* buf, u32 endp
left_coeff = coeff; left_coeff = coeff;
} }
// for (int i = 0;i < 3;i++){ // for (int i = 0;i < 3;i++){
for (int i = 0;i < 1;i++){ for (int i = 0; i < 1; i++)
{
// TODO direction cfg // TODO direction cfg
default_spring_effect.condition.right_sat[i] = saturation; default_spring_effect.condition.right_sat[i] = saturation;
default_spring_effect.condition.left_sat[i] = saturation; default_spring_effect.condition.left_sat[i] = saturation;

View file

@ -118,6 +118,7 @@ public:
char thread_name[64]; char thread_name[64];
SDL_Thread* thread = nullptr; SDL_Thread* thread = nullptr;
void sdl_refresh(); void sdl_refresh();
private: private:
u32 m_controller_index; u32 m_controller_index;

View file

@ -10,7 +10,8 @@ emulated_logitech_g27_config g_cfg_logitech_g27;
LOG_CHANNEL(cfg_log, "CFG"); LOG_CHANNEL(cfg_log, "CFG");
void emulated_logitech_g27_config::fill_defaults(){ void emulated_logitech_g27_config::fill_defaults()
{
// a shifter-less g29 with a xbox 360 controller shifter place holder... // a shifter-less g29 with a xbox 360 controller shifter place holder...
m_mutex.lock(); m_mutex.lock();
@ -97,7 +98,8 @@ void emulated_logitech_g27_config::fill_defaults(){
m_mutex.unlock(); m_mutex.unlock();
} }
void emulated_logitech_g27_config::save(){ void emulated_logitech_g27_config::save()
{
m_mutex.lock(); m_mutex.lock();
const std::string cfg_name = fmt::format("%s%s.yml", fs::get_config_dir(true), "LogitechG27"); const std::string cfg_name = fmt::format("%s%s.yml", fs::get_config_dir(true), "LogitechG27");
cfg_log.notice("Saving LogitechG27 config: %s", cfg_name); cfg_log.notice("Saving LogitechG27 config: %s", cfg_name);
@ -112,7 +114,6 @@ void emulated_logitech_g27_config::save(){
cfg_log.error("Failed to save LogitechG27 config to '%s' (error=%s)", cfg_name, fs::g_tls_error); cfg_log.error("Failed to save LogitechG27 config to '%s' (error=%s)", cfg_name, fs::g_tls_error);
} }
m_mutex.unlock(); m_mutex.unlock();
} }
bool emulated_logitech_g27_config::load() bool emulated_logitech_g27_config::load()

View file

@ -4,7 +4,8 @@
#include <mutex> #include <mutex>
struct emulated_logitech_g27_config : cfg::node { struct emulated_logitech_g27_config : cfg::node
{
std::mutex m_mutex; std::mutex m_mutex;
bool load(); bool load();
void save(); void save();

View file

@ -118,7 +118,8 @@ bool sdl_instance::initialize()
default: default:
break; break;
} }
}, nullptr); },
nullptr);
m_initialized = true; m_initialized = true;
instance_mutex.unlock(); instance_mutex.unlock();

View file

@ -12,6 +12,7 @@ public:
bool initialize(); bool initialize();
void pump_events(); void pump_events();
private: private:
bool m_initialized = false; bool m_initialized = false;
std::mutex instance_mutex; std::mutex instance_mutex;

View file

@ -20,7 +20,8 @@ LOG_CHANNEL(logitech_g27_cfg_log, "LOGIG27");
#define DEFAULT_STATUS " " #define DEFAULT_STATUS " "
struct joystick_state { struct joystick_state
{
std::vector<int16_t> axes; std::vector<int16_t> axes;
std::vector<bool> buttons; std::vector<bool> buttons;
std::vector<hat_component> hats; std::vector<hat_component> hats;
@ -65,7 +66,8 @@ public:
private: private:
uint32_t device_type_id; uint32_t device_type_id;
QLabel* display_box; QLabel* display_box;
void update_display(){ void update_display()
{
char text_buf[32]; char text_buf[32];
sprintf(text_buf, "%04x:%04x", device_type_id >> 16, device_type_id & 0xFFFF); sprintf(text_buf, "%04x:%04x", device_type_id >> 16, device_type_id & 0xFFFF);
display_box->setText(QString(text_buf)); display_box->setText(QString(text_buf));
@ -153,19 +155,22 @@ public:
this->led_device->set_device_type_id(this->mapping.device_type_id); this->led_device->set_device_type_id(this->mapping.device_type_id);
}); });
connect(map_button, &QPushButton::clicked, this, [this](){ connect(map_button, &QPushButton::clicked, this, [this]()
{
this->mapping_in_progress = true; this->mapping_in_progress = true;
this->timeout_msec = 5500; this->timeout_msec = 5500;
this->setting_dialog->disable(); this->setting_dialog->disable();
this->last_joystick_states = this->setting_dialog->get_joystick_states(); this->last_joystick_states = this->setting_dialog->get_joystick_states();
}); });
connect(unmap_button, &QPushButton::clicked, this, [this](){ connect(unmap_button, &QPushButton::clicked, this, [this]()
{
this->mapping.device_type_id = 0; this->mapping.device_type_id = 0;
update_display(); update_display();
}); });
connect(reverse_checkbox, &QCheckBox::clicked, this, [this](){ connect(reverse_checkbox, &QCheckBox::clicked, this, [this]()
{
this->mapping.reverse = this->reverse_checkbox->isChecked(); this->mapping.reverse = this->reverse_checkbox->isChecked();
}); });
@ -326,7 +331,8 @@ private:
emulated_logitech_g27_settings_dialog* setting_dialog; emulated_logitech_g27_settings_dialog* setting_dialog;
void update_display(){ void update_display()
{
char text_buf[64]; char text_buf[64];
const char* type_string = nullptr; const char* type_string = nullptr;
switch (mapping.type) switch (mapping.type)
@ -500,8 +506,7 @@ void emulated_logitech_g27_settings_dialog::load_ui_state_from_config()
.id = static_cast<uint8_t>(g_cfg_logitech_g27.name##_id.get()), \ .id = static_cast<uint8_t>(g_cfg_logitech_g27.name##_id.get()), \
.hat = static_cast<hat_component>(g_cfg_logitech_g27.name##_hat.get()), \ .hat = static_cast<hat_component>(g_cfg_logitech_g27.name##_hat.get()), \
.reverse = g_cfg_logitech_g27.name##_reverse.get(), \ .reverse = g_cfg_logitech_g27.name##_reverse.get(), \
.positive_axis = false \ .positive_axis = false}; \
}; \
name->set_mapping(m); \ name->set_mapping(m); \
} }
@ -635,8 +640,7 @@ emulated_logitech_g27_settings_dialog::emulated_logitech_g27_settings_dialog(QWi
.id = static_cast<uint8_t>(g_cfg_logitech_g27.name##_id.get()), \ .id = static_cast<uint8_t>(g_cfg_logitech_g27.name##_id.get()), \
.hat = static_cast<hat_component>(g_cfg_logitech_g27.name##_hat.get()), \ .hat = static_cast<hat_component>(g_cfg_logitech_g27.name##_hat.get()), \
.reverse = g_cfg_logitech_g27.name##_reverse.get(), \ .reverse = g_cfg_logitech_g27.name##_reverse.get(), \
.positive_axis = false \ .positive_axis = false}; \
}; \
name = new Mapping(mapping_widget, this, ffb_device, led_device, m, is_axis, display_name, flip_axis_display); \ name = new Mapping(mapping_widget, this, ffb_device, led_device, m, is_axis, display_name, flip_axis_display); \
mapping_layout->addWidget(name); \ mapping_layout->addWidget(name); \
} }
@ -891,11 +895,13 @@ void emulated_logitech_g27_settings_dialog::toggle_state(bool enable)
mapping_scroll_area->verticalScrollBar()->setSliderPosition(slider_position); mapping_scroll_area->verticalScrollBar()->setSliderPosition(slider_position);
} }
void emulated_logitech_g27_settings_dialog::enable(){ void emulated_logitech_g27_settings_dialog::enable()
{
toggle_state(true); toggle_state(true);
} }
void emulated_logitech_g27_settings_dialog::disable(){ void emulated_logitech_g27_settings_dialog::disable()
{
toggle_state(false); toggle_state(false);
} }

View file

@ -32,6 +32,7 @@ public:
void enable(); void enable();
void set_state_text(const char*); void set_state_text(const char*);
const std::map<uint32_t, joystick_state>& get_joystick_states(); const std::map<uint32_t, joystick_state>& get_joystick_states();
private: private:
void toggle_state(bool enable); void toggle_state(bool enable);
void load_ui_state_from_config(); void load_ui_state_from_config();