You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
This commit is contained in:
@@ -59,7 +59,6 @@ JoypadLinux::Joypad::Joypad() {
|
||||
}
|
||||
|
||||
JoypadLinux::Joypad::~Joypad() {
|
||||
|
||||
for (int i = 0; i < MAX_ABS; i++) {
|
||||
if (abs_info[i]) {
|
||||
memdelete(abs_info[i]);
|
||||
@@ -94,7 +93,6 @@ JoypadLinux::~JoypadLinux() {
|
||||
}
|
||||
|
||||
void JoypadLinux::joy_thread_func(void *p_user) {
|
||||
|
||||
if (p_user) {
|
||||
JoypadLinux *joy = (JoypadLinux *)p_user;
|
||||
joy->run_joypad_thread();
|
||||
@@ -115,7 +113,6 @@ void JoypadLinux::run_joypad_thread() {
|
||||
|
||||
#ifdef UDEV_ENABLED
|
||||
void JoypadLinux::enumerate_joypads(udev *p_udev) {
|
||||
|
||||
udev_enumerate *enumerate;
|
||||
udev_list_entry *devices, *dev_list_entry;
|
||||
udev_device *dev;
|
||||
@@ -126,13 +123,11 @@ void JoypadLinux::enumerate_joypads(udev *p_udev) {
|
||||
udev_enumerate_scan_devices(enumerate);
|
||||
devices = udev_enumerate_get_list_entry(enumerate);
|
||||
udev_list_entry_foreach(dev_list_entry, devices) {
|
||||
|
||||
const char *path = udev_list_entry_get_name(dev_list_entry);
|
||||
dev = udev_device_new_from_syspath(p_udev, path);
|
||||
const char *devnode = udev_device_get_devnode(dev);
|
||||
|
||||
if (devnode) {
|
||||
|
||||
String devnode_str = devnode;
|
||||
if (devnode_str.find(ignore_str) == -1) {
|
||||
MutexLock lock(joy_mutex);
|
||||
@@ -145,7 +140,6 @@ void JoypadLinux::enumerate_joypads(udev *p_udev) {
|
||||
}
|
||||
|
||||
void JoypadLinux::monitor_joypads(udev *p_udev) {
|
||||
|
||||
udev_device *dev = nullptr;
|
||||
udev_monitor *mon = udev_monitor_new_from_netlink(p_udev, "udev");
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", nullptr);
|
||||
@@ -153,7 +147,6 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
|
||||
int fd = udev_monitor_get_fd(mon);
|
||||
|
||||
while (!exit_udev) {
|
||||
|
||||
fd_set fds;
|
||||
struct timeval tv;
|
||||
int ret;
|
||||
@@ -172,15 +165,12 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
|
||||
dev = udev_monitor_receive_device(mon);
|
||||
|
||||
if (dev && udev_device_get_devnode(dev) != 0) {
|
||||
|
||||
MutexLock lock(joy_mutex);
|
||||
String action = udev_device_get_action(dev);
|
||||
const char *devnode = udev_device_get_devnode(dev);
|
||||
if (devnode) {
|
||||
|
||||
String devnode_str = devnode;
|
||||
if (devnode_str.find(ignore_str) == -1) {
|
||||
|
||||
if (action == "add")
|
||||
open_joypad(devnode);
|
||||
else if (String(action) == "remove")
|
||||
@@ -198,7 +188,6 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
|
||||
#endif
|
||||
|
||||
void JoypadLinux::monitor_joypads() {
|
||||
|
||||
while (!exit_udev) {
|
||||
{
|
||||
MutexLock lock(joy_mutex);
|
||||
@@ -216,9 +205,7 @@ void JoypadLinux::monitor_joypads() {
|
||||
}
|
||||
|
||||
int JoypadLinux::get_joy_from_path(String p_path) const {
|
||||
|
||||
for (int i = 0; i < JOYPADS_MAX; i++) {
|
||||
|
||||
if (joypads[i].devpath == p_path) {
|
||||
return i;
|
||||
}
|
||||
@@ -229,7 +216,6 @@ int JoypadLinux::get_joy_from_path(String p_path) const {
|
||||
void JoypadLinux::close_joypad(int p_id) {
|
||||
if (p_id == -1) {
|
||||
for (int i = 0; i < JOYPADS_MAX; i++) {
|
||||
|
||||
close_joypad(i);
|
||||
};
|
||||
return;
|
||||
@@ -239,7 +225,6 @@ void JoypadLinux::close_joypad(int p_id) {
|
||||
Joypad &joy = joypads[p_id];
|
||||
|
||||
if (joy.fd != -1) {
|
||||
|
||||
close(joy.fd);
|
||||
joy.fd = -1;
|
||||
attached_devices.remove(attached_devices.find(joy.devpath));
|
||||
@@ -248,7 +233,6 @@ void JoypadLinux::close_joypad(int p_id) {
|
||||
}
|
||||
|
||||
static String _hex_str(uint8_t p_byte) {
|
||||
|
||||
static const char *dict = "0123456789abcdef";
|
||||
char ret[3];
|
||||
ret[2] = 0;
|
||||
@@ -260,7 +244,6 @@ static String _hex_str(uint8_t p_byte) {
|
||||
}
|
||||
|
||||
void JoypadLinux::setup_joypad_properties(int p_id) {
|
||||
|
||||
Joypad *joy = &joypads[p_id];
|
||||
|
||||
unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
|
||||
@@ -274,16 +257,12 @@ void JoypadLinux::setup_joypad_properties(int p_id) {
|
||||
return;
|
||||
}
|
||||
for (int i = BTN_JOYSTICK; i < KEY_MAX; ++i) {
|
||||
|
||||
if (test_bit(i, keybit)) {
|
||||
|
||||
joy->key_map[i] = num_buttons++;
|
||||
}
|
||||
}
|
||||
for (int i = BTN_MISC; i < BTN_JOYSTICK; ++i) {
|
||||
|
||||
if (test_bit(i, keybit)) {
|
||||
|
||||
joy->key_map[i] = num_buttons++;
|
||||
}
|
||||
}
|
||||
@@ -294,7 +273,6 @@ void JoypadLinux::setup_joypad_properties(int p_id) {
|
||||
continue;
|
||||
}
|
||||
if (test_bit(i, absbit)) {
|
||||
|
||||
joy->abs_map[i] = num_axes++;
|
||||
joy->abs_info[i] = memnew(input_absinfo);
|
||||
if (ioctl(joy->fd, EVIOCGABS(i), joy->abs_info[i]) < 0) {
|
||||
@@ -315,11 +293,9 @@ void JoypadLinux::setup_joypad_properties(int p_id) {
|
||||
}
|
||||
|
||||
void JoypadLinux::open_joypad(const char *p_path) {
|
||||
|
||||
int joy_num = input->get_unused_joy_id();
|
||||
int fd = open(p_path, O_RDWR | O_NONBLOCK);
|
||||
if (fd != -1 && joy_num != -1) {
|
||||
|
||||
unsigned long evbit[NBITS(EV_MAX)] = { 0 };
|
||||
unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
|
||||
unsigned long absbit[NBITS(ABS_MAX)] = { 0 };
|
||||
@@ -369,7 +345,6 @@ void JoypadLinux::open_joypad(const char *p_path) {
|
||||
setup_joypad_properties(joy_num);
|
||||
sprintf(uid, "%04x%04x", BSWAP16(inpid.bustype), 0);
|
||||
if (inpid.vendor && inpid.product && inpid.version) {
|
||||
|
||||
uint16_t vendor = BSWAP16(inpid.vendor);
|
||||
uint16_t product = BSWAP16(inpid.product);
|
||||
uint16_t version = BSWAP16(inpid.version);
|
||||
@@ -380,7 +355,6 @@ void JoypadLinux::open_joypad(const char *p_path) {
|
||||
String uidname = uid;
|
||||
int uidlen = MIN(name.length(), 11);
|
||||
for (int i = 0; i < uidlen; i++) {
|
||||
|
||||
uidname = uidname + _hex_str(name[i]);
|
||||
}
|
||||
uidname += "00";
|
||||
@@ -437,7 +411,6 @@ void JoypadLinux::joypad_vibration_stop(int p_id, uint64_t p_timestamp) {
|
||||
}
|
||||
|
||||
Input::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const {
|
||||
|
||||
int min = p_abs->minimum;
|
||||
int max = p_abs->maximum;
|
||||
Input::JoyAxis jx;
|
||||
@@ -457,12 +430,10 @@ Input::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value
|
||||
}
|
||||
|
||||
void JoypadLinux::process_joypads() {
|
||||
|
||||
if (joy_mutex.try_lock() != OK) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < JOYPADS_MAX; i++) {
|
||||
|
||||
if (joypads[i].fd == -1)
|
||||
continue;
|
||||
|
||||
@@ -474,7 +445,6 @@ void JoypadLinux::process_joypads() {
|
||||
while ((len = read(joy->fd, events, (sizeof events))) > 0) {
|
||||
len /= sizeof(events[0]);
|
||||
for (int j = 0; j < len; j++) {
|
||||
|
||||
input_event &ev = events[j];
|
||||
|
||||
// ev may be tainted and out of MAX_KEY range, which will cause
|
||||
|
||||
Reference in New Issue
Block a user