Merge pull request #148 from ren2r/feat-libinput-scroll_button

feat: add libinput scroll_button
This commit is contained in:
DreamMaoMao 2025-07-04 08:50:02 +08:00 committed by GitHub
commit 64b83d907e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 0 deletions

View file

@ -205,6 +205,7 @@ typedef struct {
unsigned int accel_profile;
double accel_speed;
unsigned int scroll_method;
unsigned int scroll_button;
unsigned int click_method;
unsigned int send_events_mode;
unsigned int button_map;
@ -1170,6 +1171,8 @@ void parse_config_line(Config *config, const char *line) {
config->accel_speed = atof(value);
} else if (strcmp(key, "scroll_method") == 0) {
config->scroll_method = atoi(value);
} else if (strcmp(key, "scroll_button") == 0) {
config->scroll_button = atoi(value);
} else if (strcmp(key, "click_method") == 0) {
config->click_method = atoi(value);
} else if (strcmp(key, "send_events_mode") == 0) {
@ -2174,6 +2177,7 @@ void override_config(void) {
accel_profile = CLAMP_INT(config.accel_profile, 0, 2);
accel_speed = CLAMP_FLOAT(config.accel_speed, -1.0f, 1.0f);
scroll_method = CLAMP_INT(config.scroll_method, 0, 4);
scroll_button = CLAMP_INT(config.scroll_button, 272, 276);
click_method = CLAMP_INT(config.click_method, 0, 2);
send_events_mode = CLAMP_INT(config.send_events_mode, 0, 2);
button_map = CLAMP_INT(config.button_map, 0, 1);
@ -2318,6 +2322,7 @@ void set_value_default() {
config.accel_profile = accel_profile;
config.accel_speed = accel_speed;
config.scroll_method = scroll_method;
config.scroll_button = scroll_button;
config.click_method = click_method;
config.send_events_mode = send_events_mode;
config.button_map = button_map;

View file

@ -134,6 +134,7 @@ LIBINPUT_CONFIG_SCROLL_EDGE
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN
*/
enum libinput_config_scroll_method scroll_method = LIBINPUT_CONFIG_SCROLL_2FG;
unsigned int scroll_button = 274;
/* You can choose between:
LIBINPUT_CONFIG_CLICK_METHOD_NONE

View file

@ -3940,6 +3940,9 @@ void createpointer(struct wlr_pointer *pointer) {
if (libinput_device_config_scroll_get_methods(device) !=
LIBINPUT_CONFIG_SCROLL_NO_SCROLL)
libinput_device_config_scroll_set_method(device, scroll_method);
if (libinput_device_config_scroll_get_methods(device) ==
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)
libinput_device_config_scroll_set_button(device, scroll_button);
if (libinput_device_config_click_get_methods(device) !=
LIBINPUT_CONFIG_CLICK_METHOD_NONE)