Commit 73534814 authored by Peter Hutterer's avatar Peter Hutterer

Split LibinputDeviceApplyConfig into helper functions

No functional changes
parent 6d3bd454
...@@ -483,13 +483,12 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, ...@@ -483,13 +483,12 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
static void static void
LibinputInitProperty(DeviceIntPtr dev); LibinputInitProperty(DeviceIntPtr dev);
static inline void static void
LibinputApplyConfig(DeviceIntPtr dev) LibinputApplyConfigSendEvents(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{ {
InputInfoPtr pInfo = dev->public.devicePrivate; InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
struct libinput_device *device = driver_data->shared_device->device;
unsigned int scroll_button;
if (libinput_device_config_send_events_get_modes(device) != LIBINPUT_CONFIG_SEND_EVENTS_ENABLED && if (libinput_device_config_send_events_get_modes(device) != LIBINPUT_CONFIG_SEND_EVENTS_ENABLED &&
libinput_device_config_send_events_set_mode(device, libinput_device_config_send_events_set_mode(device,
...@@ -497,6 +496,14 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -497,6 +496,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR, xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set SendEventsMode %u\n", "Failed to set SendEventsMode %u\n",
driver_data->options.sendevents); driver_data->options.sendevents);
}
static void
LibinputApplyConfigNaturalScroll(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
if (libinput_device_config_scroll_has_natural_scroll(device) && if (libinput_device_config_scroll_has_natural_scroll(device) &&
libinput_device_config_scroll_set_natural_scroll_enabled(device, libinput_device_config_scroll_set_natural_scroll_enabled(device,
...@@ -504,6 +511,14 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -504,6 +511,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR, xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set NaturalScrolling to %d\n", "Failed to set NaturalScrolling to %d\n",
driver_data->options.natural_scrolling); driver_data->options.natural_scrolling);
}
static void
LibinputApplyConfigAccel(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
if (libinput_device_config_accel_is_available(device) && if (libinput_device_config_accel_is_available(device) &&
libinput_device_config_accel_set_speed(device, libinput_device_config_accel_set_speed(device,
...@@ -532,6 +547,14 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -532,6 +547,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
} }
xf86IDrvMsg(pInfo, X_ERROR, "Failed to set profile %s\n", profile); xf86IDrvMsg(pInfo, X_ERROR, "Failed to set profile %s\n", profile);
} }
}
static inline void
LibinputApplyConfigTap(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
if (libinput_device_config_tap_get_finger_count(device) > 0 && if (libinput_device_config_tap_get_finger_count(device) > 0 &&
libinput_device_config_tap_set_enabled(device, libinput_device_config_tap_set_enabled(device,
...@@ -568,6 +591,14 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -568,6 +591,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR, xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set Tapping Drag to %d\n", "Failed to set Tapping Drag to %d\n",
driver_data->options.tap_drag); driver_data->options.tap_drag);
}
static void
LibinputApplyConfigCalibration(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
if (libinput_device_config_calibration_has_matrix(device) && if (libinput_device_config_calibration_has_matrix(device) &&
libinput_device_config_calibration_set_matrix(device, libinput_device_config_calibration_set_matrix(device,
...@@ -580,6 +611,14 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -580,6 +611,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
driver_data->options.matrix[4], driver_data->options.matrix[5], driver_data->options.matrix[4], driver_data->options.matrix[5],
driver_data->options.matrix[6], driver_data->options.matrix[7], driver_data->options.matrix[6], driver_data->options.matrix[7],
driver_data->options.matrix[8]); driver_data->options.matrix[8]);
}
static void
LibinputApplyConfigLeftHanded(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
if (libinput_device_config_left_handed_is_available(device) && if (libinput_device_config_left_handed_is_available(device) &&
libinput_device_config_left_handed_set(device, libinput_device_config_left_handed_set(device,
...@@ -587,6 +626,14 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -587,6 +626,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR, xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set LeftHanded to %d\n", "Failed to set LeftHanded to %d\n",
driver_data->options.left_handed); driver_data->options.left_handed);
}
static void
LibinputApplyConfigScrollMethod(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
if (libinput_device_config_scroll_set_method(device, if (libinput_device_config_scroll_set_method(device,
driver_data->options.scroll_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) { driver_data->options.scroll_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) {
...@@ -607,12 +654,22 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -607,12 +654,22 @@ LibinputApplyConfig(DeviceIntPtr dev)
} }
if (libinput_device_config_scroll_get_methods(device) & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) { if (libinput_device_config_scroll_get_methods(device) & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) {
unsigned int scroll_button;
scroll_button = btn_xorg2linux(driver_data->options.scroll_button); scroll_button = btn_xorg2linux(driver_data->options.scroll_button);
if (libinput_device_config_scroll_set_button(device, scroll_button) != LIBINPUT_CONFIG_STATUS_SUCCESS) if (libinput_device_config_scroll_set_button(device, scroll_button) != LIBINPUT_CONFIG_STATUS_SUCCESS)
xf86IDrvMsg(pInfo, X_ERROR, xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set ScrollButton to %u\n", "Failed to set ScrollButton to %u\n",
driver_data->options.scroll_button); driver_data->options.scroll_button);
} }
}
static void
LibinputApplyConfigClickMethod(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
if (libinput_device_config_click_set_method(device, if (libinput_device_config_click_set_method(device,
driver_data->options.click_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) { driver_data->options.click_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) {
...@@ -630,6 +687,14 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -630,6 +687,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
"Failed to set click method to %s\n", "Failed to set click method to %s\n",
method); method);
} }
}
static void
LibinputApplyConfigMiddleEmulation(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
if (libinput_device_config_middle_emulation_is_available(device) && if (libinput_device_config_middle_emulation_is_available(device) &&
libinput_device_config_middle_emulation_set_enabled(device, libinput_device_config_middle_emulation_set_enabled(device,
...@@ -637,6 +702,14 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -637,6 +702,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR, xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set MiddleEmulation to %d\n", "Failed to set MiddleEmulation to %d\n",
driver_data->options.middle_emulation); driver_data->options.middle_emulation);
}
static void
LibinputApplyConfigDisableWhileTyping(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
if (libinput_device_config_dwt_is_available(device) && if (libinput_device_config_dwt_is_available(device) &&
libinput_device_config_dwt_set_enabled(device, libinput_device_config_dwt_set_enabled(device,
...@@ -644,13 +717,40 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -644,13 +717,40 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR, xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set DisableWhileTyping to %d\n", "Failed to set DisableWhileTyping to %d\n",
driver_data->options.disable_while_typing); driver_data->options.disable_while_typing);
}
static void
LibinputApplyConfigRotation(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
if (libinput_device_config_rotation_is_available(device) && if (libinput_device_config_rotation_is_available(device) &&
libinput_device_config_rotation_set_angle(device, driver_data->options.rotation_angle) != LIBINPUT_CONFIG_STATUS_SUCCESS) libinput_device_config_rotation_set_angle(device, driver_data->options.rotation_angle) != LIBINPUT_CONFIG_STATUS_SUCCESS)
xf86IDrvMsg(pInfo, X_ERROR, xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set RotationAngle to %.2f\n", "Failed to set RotationAngle to %.2f\n",
driver_data->options.rotation_angle); driver_data->options.rotation_angle);
}
static inline void
LibinputApplyConfig(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
struct libinput_device *device = driver_data->shared_device->device;
LibinputApplyConfigSendEvents(dev, driver_data, device);
LibinputApplyConfigNaturalScroll(dev, driver_data, device);
LibinputApplyConfigAccel(dev, driver_data, device);
LibinputApplyConfigTap(dev, driver_data, device);
LibinputApplyConfigCalibration(dev, driver_data, device);
LibinputApplyConfigLeftHanded(dev, driver_data, device);
LibinputApplyConfigScrollMethod(dev, driver_data, device);
LibinputApplyConfigClickMethod(dev, driver_data, device);
LibinputApplyConfigMiddleEmulation(dev, driver_data, device);
LibinputApplyConfigDisableWhileTyping(dev, driver_data, device);
LibinputApplyConfigRotation(dev, driver_data, device);
} }
static int static int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment