From e8a7b5a5ac359d6a53148f61a05f7996459fa5d4 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 26 Nov 2021 14:39:37 +1000 Subject: Move a function to the core driver layer Signed-off-by: Peter Hutterer --- src/wcmCommon.c | 26 ++++++++++++++++++++++++++ src/wcmXCommand.c | 25 ------------------------- 2 files changed, 26 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/wcmCommon.c b/src/wcmCommon.c index d87405d..209e8c8 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -76,6 +76,32 @@ void set_absolute(WacomDevicePtr priv, Bool absolute) priv->flags &= ~ABSOLUTE_FLAG; } +/***************************************************************************** +* wcmDevSwitchModeCall -- +*****************************************************************************/ + +int wcmDevSwitchModeCall(WacomDevicePtr priv, int mode) +{ + DBG(3, priv, "to mode=%d\n", mode); + + /* Pad is always in absolute mode.*/ + if (IsPad(priv)) + return (mode == Absolute) ? Success : XI_BadMode; + + if ((mode == Absolute) && !is_absolute(priv)) + set_absolute(priv, TRUE); + else if ((mode == Relative) && is_absolute(priv)) + set_absolute(priv, FALSE); + else if ( (mode != Absolute) && (mode != Relative)) + { + DBG(10, priv, "invalid mode=%d\n", mode); + return XI_BadMode; + } + + return Success; +} + + static int wcmButtonPerNotch(WacomDevicePtr priv, int value, int threshold, int btn_positive, int btn_negative) { int mode = is_absolute(priv); diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c index a58b2ec..d7a42e6 100644 --- a/src/wcmXCommand.c +++ b/src/wcmXCommand.c @@ -37,31 +37,6 @@ static int wcmSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr pr static int wcmGetProperty(DeviceIntPtr dev, Atom property); static int wcmDeleteProperty(DeviceIntPtr dev, Atom property); -/***************************************************************************** -* wcmDevSwitchModeCall -- -*****************************************************************************/ - -int wcmDevSwitchModeCall(WacomDevicePtr priv, int mode) -{ - DBG(3, priv, "to mode=%d\n", mode); - - /* Pad is always in absolute mode.*/ - if (IsPad(priv)) - return (mode == Absolute) ? Success : XI_BadMode; - - if ((mode == Absolute) && !is_absolute(priv)) - set_absolute(priv, TRUE); - else if ((mode == Relative) && is_absolute(priv)) - set_absolute(priv, FALSE); - else if ( (mode != Absolute) && (mode != Relative)) - { - DBG(10, priv, "invalid mode=%d\n", mode); - return XI_BadMode; - } - - return Success; -} - /***************************************************************************** * wcmDevSwitchMode -- *****************************************************************************/ -- cgit v1.2.1