mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-01 18:40:09 +01:00
Use bit(foo) instead of (1 << foo)
Translates to the same thing, but the bit() helper is nicer and less likely to be typoed. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
b5f0536a4f
commit
8fecb19147
10 changed files with 24 additions and 23 deletions
|
|
@ -583,7 +583,7 @@ evdev_middlebutton_filter_button(struct evdev_device *device,
|
|||
enum evdev_middlebutton_event event;
|
||||
bool is_press = state == LIBINPUT_BUTTON_STATE_PRESSED;
|
||||
int rc;
|
||||
unsigned int bit = (button - BTN_LEFT);
|
||||
unsigned int btnbit = (button - BTN_LEFT);
|
||||
uint32_t old_mask = 0;
|
||||
|
||||
if (!device->middlebutton.enabled)
|
||||
|
|
@ -612,7 +612,7 @@ evdev_middlebutton_filter_button(struct evdev_device *device,
|
|||
}
|
||||
|
||||
if (button < BTN_LEFT ||
|
||||
bit >= sizeof(device->middlebutton.button_mask) * 8) {
|
||||
btnbit >= sizeof(device->middlebutton.button_mask) * 8) {
|
||||
evdev_log_bug_libinput(device,
|
||||
"Button mask too small for %s\n",
|
||||
libevdev_event_code_get_name(EV_KEY,
|
||||
|
|
@ -624,9 +624,9 @@ evdev_middlebutton_filter_button(struct evdev_device *device,
|
|||
|
||||
old_mask = device->middlebutton.button_mask;
|
||||
if (is_press)
|
||||
device->middlebutton.button_mask |= 1 << bit;
|
||||
device->middlebutton.button_mask |= bit(btnbit);
|
||||
else
|
||||
device->middlebutton.button_mask &= ~(1 << bit);
|
||||
device->middlebutton.button_mask &= ~bit(btnbit);
|
||||
|
||||
if (old_mask != device->middlebutton.button_mask &&
|
||||
device->middlebutton.button_mask == 0) {
|
||||
|
|
|
|||
|
|
@ -592,7 +592,7 @@ tp_process_button(struct tp_dispatch *tp,
|
|||
const struct input_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
uint32_t mask = 1 << (e->code - BTN_LEFT);
|
||||
uint32_t mask = bit(e->code - BTN_LEFT);
|
||||
|
||||
/* Ignore other buttons on clickpads */
|
||||
if (tp->buttons.is_clickpad && e->code != BTN_LEFT) {
|
||||
|
|
|
|||
|
|
@ -139,9 +139,9 @@ tp_tap_notify(struct tp_dispatch *tp,
|
|||
button = button_map[tp->tap.map][nfingers - 1];
|
||||
|
||||
if (state == LIBINPUT_BUTTON_STATE_PRESSED)
|
||||
tp->tap.buttons_pressed |= (1 << nfingers);
|
||||
tp->tap.buttons_pressed |= bit(nfingers);
|
||||
else
|
||||
tp->tap.buttons_pressed &= ~(1 << nfingers);
|
||||
tp->tap.buttons_pressed &= ~bit(nfingers);
|
||||
|
||||
evdev_pointer_notify_button(tp->device,
|
||||
time,
|
||||
|
|
@ -1603,7 +1603,7 @@ tp_release_all_taps(struct tp_dispatch *tp, uint64_t now)
|
|||
int i;
|
||||
|
||||
for (i = 1; i <= 3; i++) {
|
||||
if (tp->tap.buttons_pressed & (1 << i))
|
||||
if (tp->tap.buttons_pressed & bit(i))
|
||||
tp_tap_notify(tp, now, i, LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#define DEFAULT_TRACKPOINT_EVENT_TIMEOUT ms2us(40)
|
||||
#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_1 ms2us(200)
|
||||
#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_2 ms2us(500)
|
||||
#define FAKE_FINGER_OVERFLOW (1 << 7)
|
||||
#define FAKE_FINGER_OVERFLOW bit(7)
|
||||
#define THUMB_IGNORE_SPEED_THRESHOLD 20 /* mm/s */
|
||||
|
||||
enum notify {
|
||||
|
|
@ -198,7 +198,7 @@ tp_detect_wobbling(struct tp_dispatch *tp,
|
|||
if (dx > 0) { /* right move */
|
||||
static const char r_l_r = 0x5; /* {Right, Left, Right} */
|
||||
|
||||
t->hysteresis.x_motion_history |= (1 << 2);
|
||||
t->hysteresis.x_motion_history |= bit(2);
|
||||
if (t->hysteresis.x_motion_history == r_l_r) {
|
||||
tp->hysteresis.enabled = true;
|
||||
evdev_log_debug(tp->device,
|
||||
|
|
@ -303,10 +303,10 @@ tp_fake_finger_set(struct tp_dispatch *tp,
|
|||
|
||||
if (is_press) {
|
||||
tp->fake_touches &= ~FAKE_FINGER_OVERFLOW;
|
||||
tp->fake_touches |= 1 << shift;
|
||||
tp->fake_touches |= bit(shift);
|
||||
|
||||
} else {
|
||||
tp->fake_touches &= ~(0x1 << shift);
|
||||
tp->fake_touches &= ~bit(shift);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ pad_init_mode_buttons(struct pad_dispatch *pad,
|
|||
return 1;
|
||||
}
|
||||
|
||||
group->button_mask |= 1 << i;
|
||||
group->button_mask |= bit(i);
|
||||
|
||||
if (flags & WACOM_BUTTON_MODESWITCH) {
|
||||
struct pad_mode_toggle_button *b;
|
||||
|
|
@ -423,7 +423,7 @@ pad_init_mode_buttons(struct pad_dispatch *pad,
|
|||
return 1;
|
||||
g = (struct pad_led_group*)group;
|
||||
list_insert(&g->toggle_button_list, &b->link);
|
||||
group->toggle_button_mask |= 1 << i;
|
||||
group->toggle_button_mask |= bit(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -865,7 +865,7 @@ xy_get_direction(double x, double y)
|
|||
d1 = (int)(r + 0.9) % 8;
|
||||
d2 = (int)(r + 0.1) % 8;
|
||||
|
||||
dir = (1 << d1) | (1 << d2);
|
||||
dir = bit(d1) | bit(d2);
|
||||
}
|
||||
|
||||
return dir;
|
||||
|
|
|
|||
|
|
@ -3427,7 +3427,7 @@ libinput_tablet_pad_mode_group_has_button(struct libinput_tablet_pad_mode_group
|
|||
libinput_device_tablet_pad_get_num_buttons(group->device))
|
||||
return 0;
|
||||
|
||||
return !!(group->button_mask & (1 << button));
|
||||
return !!(group->button_mask & bit(button));
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
|
|
@ -3438,7 +3438,7 @@ libinput_tablet_pad_mode_group_has_ring(struct libinput_tablet_pad_mode_group *g
|
|||
libinput_device_tablet_pad_get_num_rings(group->device))
|
||||
return 0;
|
||||
|
||||
return !!(group->ring_mask & (1 << ring));
|
||||
return !!(group->ring_mask & bit(ring));
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
|
|
@ -3449,7 +3449,7 @@ libinput_tablet_pad_mode_group_has_strip(struct libinput_tablet_pad_mode_group *
|
|||
libinput_device_tablet_pad_get_num_strips(group->device))
|
||||
return 0;
|
||||
|
||||
return !!(group->strip_mask & (1 << strip));
|
||||
return !!(group->strip_mask & bit(strip));
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
|
|
@ -3460,7 +3460,7 @@ libinput_tablet_pad_mode_group_button_is_toggle(struct libinput_tablet_pad_mode_
|
|||
libinput_device_tablet_pad_get_num_buttons(group->device))
|
||||
return 0;
|
||||
|
||||
return !!(group->toggle_button_mask & (1 << button));
|
||||
return !!(group->toggle_button_mask & bit(button));
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT struct libinput_tablet_pad_mode_group *
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ libinput_timer_set(struct libinput_timer *timer, uint64_t expire);
|
|||
|
||||
enum timer_flags {
|
||||
TIMER_FLAG_NONE = 0,
|
||||
TIMER_FLAG_ALLOW_NEGATIVE = (1 << 0),
|
||||
TIMER_FLAG_ALLOW_NEGATIVE = bit(0),
|
||||
};
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ START_TEST(device_sendevents_config_invalid)
|
|||
device = dev->libinput_device;
|
||||
|
||||
status = libinput_device_config_send_events_set_mode(device,
|
||||
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED | (1 << 4));
|
||||
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED | bit(4));
|
||||
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
|
||||
}
|
||||
END_TEST
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
#include "libinput-git-version.h"
|
||||
#include "shared.h"
|
||||
#include "builddir.h"
|
||||
#include "util-bits.h"
|
||||
#include "util-list.h"
|
||||
#include "util-time.h"
|
||||
#include "util-input-event.h"
|
||||
|
|
@ -391,9 +392,9 @@ handle_evdev_frame(struct record_device *d)
|
|||
assert(slot < sizeof(d->touch.slot_state) * 8);
|
||||
|
||||
if (e.value != -1)
|
||||
d->touch.slot_state |= 1 << slot;
|
||||
d->touch.slot_state |= bit(slot);
|
||||
else
|
||||
d->touch.slot_state &= ~(1 << slot);
|
||||
d->touch.slot_state &= ~bit(slot);
|
||||
}
|
||||
|
||||
if (e.type == EV_SYN && e.code == SYN_REPORT)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue