This commit refactors the signature of the sendAction function to take a
WacomDeviceState pointer. This change makes it easier to implement the
following pan/scroll patch.

Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
---
 src/wcmCommon.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index dc6ecbd..b816cdd 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -58,8 +58,8 @@ static int applyPressureCurve(WacomDevicePtr pDev, const 
WacomDeviceStatePtr pSt
 static void commonDispatchDevice(InputInfoPtr pInfo,
                                 const WacomChannelPtr pChannel,
                                 enum WacomSuppressMode suppress);
-static void sendAButton(InputInfoPtr pInfo, int button, int mask,
-                       int first_val, int num_vals, int *valuators);
+static void sendAButton(InputInfoPtr pInfo,  const WacomDeviceState* ds, int 
button,
+                       int mask, int first_val, int num_vals, int *valuators);
 
 /*****************************************************************************
  * Utility functions
@@ -95,7 +95,7 @@ void set_absolute(InputInfoPtr pInfo, Bool absolute)
  *   previous one.
  ****************************************************************************/
 
-static void wcmSendButtons(InputInfoPtr pInfo, int buttons,
+static void wcmSendButtons(InputInfoPtr pInfo, const WacomDeviceState* ds, int 
buttons,
                           int first_val, int num_vals, int *valuators)
 {
        unsigned int button, mask, first_button;
@@ -136,7 +136,7 @@ static void wcmSendButtons(InputInfoPtr pInfo, int buttons,
        {
                mask = 1u << button;
                if ((mask & priv->oldState.buttons) != (mask & buttons))
-                       sendAButton(pInfo, button, (mask & buttons),
+                       sendAButton(pInfo, ds, button, (mask & buttons),
                                        first_val, num_vals, valuators);
        }
 
@@ -166,8 +166,8 @@ static int countPresses(int keybtn, unsigned int* keys, int 
size)
        return count;
 }
 
-static void sendAction(InputInfoPtr pInfo, int press,
-                      unsigned int *keys, int nkeys,
+static void sendAction(InputInfoPtr pInfo,  const WacomDeviceState* ds,
+                      int press, unsigned int *keys, int nkeys,
                       int first_val, int num_val, int *valuators)
 {
        int i;
@@ -249,8 +249,8 @@ static void sendAction(InputInfoPtr pInfo, int press,
  * sendAButton --
  *   Send one button event, called by wcmSendButtons
  ****************************************************************************/
-static void sendAButton(InputInfoPtr pInfo, int button, int mask,
-                       int first_val, int num_val, int *valuators)
+static void sendAButton(InputInfoPtr pInfo, const WacomDeviceState* ds, int 
button,
+                       int mask, int first_val, int num_val, int *valuators)
 {
        WacomDevicePtr priv = (WacomDevicePtr) pInfo->private;
 #ifdef DEBUG
@@ -263,7 +263,7 @@ static void sendAButton(InputInfoPtr pInfo, int button, int 
mask,
        if (!priv->keys[button][0])
                return;
 
-       sendAction(pInfo, (mask != 0), priv->keys[button],
+       sendAction(pInfo, ds, (mask != 0), priv->keys[button],
                   ARRAY_SIZE(priv->keys[button]),
                   first_val, num_val, valuators);
 }
@@ -345,11 +345,11 @@ TEST_NON_STATIC int getWheelButton(int delta, int 
action_up, int action_dn)
  * @param num_vals
  * @param valuators
  */
-static void sendWheelStripEvent(unsigned int *action, int nactions, 
InputInfoPtr pInfo,
-                                int first_val, int num_vals, int *valuators)
+static void sendWheelStripEvent(unsigned int *action, const WacomDeviceState* 
ds, int nactions,
+                               InputInfoPtr pInfo, int first_val, int 
num_vals, int *valuators)
 {
-       sendAction(pInfo, 1, action, nactions, first_val, num_vals, valuators);
-       sendAction(pInfo, 0, action, nactions, first_val, num_vals, valuators);
+       sendAction(pInfo, ds, 1, action, nactions, first_val, num_vals, 
valuators);
+       sendAction(pInfo, ds, 0, action, nactions, first_val, num_vals, 
valuators);
 }
 
 /*****************************************************************************
@@ -372,7 +372,7 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if (idx >= 0 && IsPad(priv) && priv->oldState.proximity == 
ds->proximity)
        {
                DBG(10, priv, "Left touch strip scroll delta = %d\n", delta);
-               sendWheelStripEvent(priv->strip_keys[idx], 
ARRAY_SIZE(priv->strip_keys[idx]),
+               sendWheelStripEvent(priv->strip_keys[idx], ds, 
ARRAY_SIZE(priv->strip_keys[idx]),
                                    pInfo, first_val, num_vals, valuators);
        }
 
@@ -382,7 +382,7 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if (idx >= 0 && IsPad(priv) && priv->oldState.proximity == 
ds->proximity)
        {
                DBG(10, priv, "Right touch strip scroll delta = %d\n", delta);
-               sendWheelStripEvent(priv->strip_keys[idx], 
ARRAY_SIZE(priv->strip_keys[idx]),
+               sendWheelStripEvent(priv->strip_keys[idx], ds, 
ARRAY_SIZE(priv->strip_keys[idx]),
                                    pInfo, first_val, num_vals, valuators);
        }
 
@@ -392,7 +392,7 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if (idx >= 0 && (IsCursor(priv) || IsPad(priv)) && 
priv->oldState.proximity == ds->proximity)
        {
                DBG(10, priv, "Relative wheel scroll delta = %d\n", delta);
-               sendWheelStripEvent(priv->wheel_keys[idx], 
ARRAY_SIZE(priv->wheel_keys[idx]),
+               sendWheelStripEvent(priv->wheel_keys[idx], ds, 
ARRAY_SIZE(priv->wheel_keys[idx]),
                                    pInfo, first_val, num_vals, valuators);
        }
 
@@ -402,7 +402,7 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if (idx >= 0 && IsPad(priv) && priv->oldState.proximity == 
ds->proximity)
        {
                DBG(10, priv, "Left touch wheel scroll delta = %d\n", delta);
-               sendWheelStripEvent(priv->wheel_keys[idx], 
ARRAY_SIZE(priv->wheel_keys[idx]),
+               sendWheelStripEvent(priv->wheel_keys[idx], ds, 
ARRAY_SIZE(priv->wheel_keys[idx]),
                                    pInfo, first_val, num_vals, valuators);
        }
 
@@ -412,7 +412,7 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if (idx >= 0 && IsPad(priv) && priv->oldState.proximity == 
ds->proximity)
        {
                DBG(10, priv, "Right touch wheel scroll delta = %d\n", delta);
-               sendWheelStripEvent(priv->wheel_keys[idx], 
ARRAY_SIZE(priv->wheel_keys[idx]),
+               sendWheelStripEvent(priv->wheel_keys[idx], ds, 
ARRAY_SIZE(priv->wheel_keys[idx]),
                                    pInfo, first_val, num_vals, valuators);
        }
 }
@@ -430,7 +430,7 @@ static void sendCommonEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
 
        /* send button events when state changed or first time in prox and 
button unpresses */
        if (priv->oldState.buttons != buttons || (!priv->oldState.proximity && 
!buttons))
-               wcmSendButtons(pInfo,buttons, first_val, num_vals, valuators);
+               wcmSendButtons(pInfo, ds, buttons, first_val, num_vals, 
valuators);
 
        /* emulate wheel/strip events when defined */
        if ( ds->relwheel || (ds->abswheel != priv->oldState.abswheel) || 
(ds->abswheel2 != priv->oldState.abswheel2) ||
@@ -526,7 +526,7 @@ wcmSendPadEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        else
        {
                if (priv->oldState.buttons)
-                       wcmSendButtons(pInfo, ds->buttons, first_val, num_vals, 
valuators);
+                       wcmSendButtons(pInfo, ds, ds->buttons, first_val, 
num_vals, valuators);
        }
 
        if (priv->oldState.proximity && !ds->proximity)
@@ -594,7 +594,7 @@ wcmSendNonPadEvents(InputInfoPtr pInfo, const 
WacomDeviceState *ds,
                /* reports button up when the device has been
                 * down and becomes out of proximity */
                if (priv->oldState.buttons)
-                       wcmSendButtons(pInfo, buttons, first_val, num_vals, 
valuators);
+                       wcmSendButtons(pInfo, ds, buttons, first_val, num_vals, 
valuators);
 
                if (priv->oldState.proximity)
                        xf86PostProximityEventP(pInfo->dev, 0, first_val, 
num_vals,
-- 
2.15.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to