The AC_CUSTOM event type is introduced to make better use of the
limited space available in each Action Code. The value within the
AC_CODE mask defines what action to take when AC_TYPE == AC_CUSTOM.
Actions which do not require an argument (like modetoggle and
displaytoggle) should use the AC_CUSTOM type.

AC_MODETOGGLE and AC_DISPLAYTOGGLE are deprecated in favor of their
new brethren. Programs should now use e.g. (AC_CUSTOM | CODE_MODETOGGLE)
to describe the modetoggle action.
---
 include/Xwacom.h  |   10 +++++++---
 src/wcmCommon.c   |   46 +++++++++++++++++++++++++++++++++++++++++-----
 src/wcmXCommand.c |   14 ++++++++++++--
 tools/xsetwacom.c |   17 +++++++++++++++--
 4 files changed, 75 insertions(+), 12 deletions(-)

diff --git a/include/Xwacom.h b/include/Xwacom.h
index 3ca8573..16ab578 100644
--- a/include/Xwacom.h
+++ b/include/Xwacom.h
@@ -52,18 +52,22 @@
  * AC_KEY | AC_KEYBTNPRESS | <keycode> is a key press for key <keycode>.
  * AC_BUTTON | AC_KEYBTNPRESS | 1 is a button press for 1
  * AC_BUTTON | 1 is a button release for 1
+ * AC_CUSTOM | CODE_MODETOGGLE is a signal to toggle relative/absolute mode
  *
  * if no action is set for a button, the button behaves normally.
  */
 #define AC_CODE             0x0000ffff /* Mask to isolate button number or key 
code */
 #define AC_KEY              0x00010000 /* Emit key events */
-#define AC_MODETOGGLE       0x00020000 /* Toggle absolute/relative mode */
-#define AC_DBLCLICK         0x00030000 /* DEPRECATED: use two button events 
instead */
-#define AC_DISPLAYTOGGLE    0x00040000 /* Toggle among screens */
+#define AC_MODETOGGLE       0x00020000 /* DEPRECATED: Toggle absolute/relative 
mode */
+#define AC_CUSTOM           0x00030000 /* Emit custom events */
+#define AC_DISPLAYTOGGLE    0x00040000 /* DEPRECATED: Toggle among screens */
 #define AC_BUTTON           0x00080000 /* Emit button events */
 #define AC_TYPE             0x000f0000 /* The mask to isolate event type bits 
*/
 #define AC_KEYBTNPRESS      0x00100000  /* bit set for key/button presses */
 #define AC_CORE             0x10000000 /* DEPRECATED: has no effect */
 #define AC_EVENT            0xf00f0000 /* Mask to isolate event flag */
 
+#define CODE_MODETOGGLE              1 /* AC_CUSTOM toggle absolute/relative 
mode */
+#define CODE_DISPLAYTOGGLE           2 /* AC_CUSTOM toggle among screens */
+
 #endif /* __XORG_XWACOM_H */
diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index e4ff7d9..4fb0610 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -213,6 +213,22 @@ static void sendAction(InputInfoPtr pInfo, int press,
                if (!action)
                        break;
 
+               /* Transform pre-AC_CUSTOM types into their modern
+                * counterparts. This switch may be removed at the
+                * same time as the deprecated AC_XXXXXX defines.
+                */
+               switch (action & AC_TYPE)
+               {
+                       case AC_MODETOGGLE:
+                               action ^= (action & AC_TYPE);
+                               action |= AC_CUSTOM | CODE_MODETOGGLE;
+                               break;
+                       case AC_DISPLAYTOGGLE:
+                               action ^= (action & AC_TYPE);
+                               action |= AC_CUSTOM | CODE_DISPLAYTOGGLE;
+                               break;
+               }
+
                switch ((action & AC_TYPE))
                {
                        case AC_BUTTON:
@@ -232,11 +248,15 @@ static void sendAction(InputInfoPtr pInfo, int press,
                                        wcmEmitKeycode(pInfo->dev, key_code, 
is_press);
                                }
                                break;
-                       case AC_MODETOGGLE:
-                               if (press)
-                                       wcmDevSwitchModeCall(pInfo,
-                                                       (is_absolute(pInfo)) ? 
Relative : Absolute); /* not a typo! */
-                               break;
+                       case AC_CUSTOM:
+                               switch (action & AC_CODE)
+                               {
+                                       case CODE_MODETOGGLE:
+                                               if (press)
+                                                       
wcmDevSwitchModeCall(pInfo,
+                                                                       
(is_absolute(pInfo)) ? Relative : Absolute); /* not a typo! */
+                                               break;
+                               }
                }
        }
 
@@ -245,6 +265,22 @@ static void sendAction(InputInfoPtr pInfo, int press,
        {
                unsigned int action = keys[i];
 
+               /* Transform pre-AC_CUSTOM types into their modern
+                * counterparts. This switch may be removed at the
+                * same time as the deprecated AC_XXXXXX defines.
+                */
+               switch (action & AC_TYPE)
+               {
+                       case AC_MODETOGGLE:
+                               action ^= (action & AC_TYPE);
+                               action |= AC_CUSTOM | CODE_MODETOGGLE;
+                               break;
+                       case AC_DISPLAYTOGGLE:
+                               action ^= (action & AC_TYPE);
+                               action |= AC_CUSTOM | CODE_DISPLAYTOGGLE;
+                               break;
+               }
+
                switch ((action & AC_TYPE))
                {
                        case AC_BUTTON:
diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
index 5666bac..55cf748 100644
--- a/src/wcmXCommand.c
+++ b/src/wcmXCommand.c
@@ -283,8 +283,18 @@ static int wcmSanityCheckProperty(XIPropertyValuePtr prop)
                                if (code > WCM_MAX_MOUSE_BUTTONS)
                                        return BadValue;
                                break;
-                       case AC_DISPLAYTOGGLE:
-                       case AC_MODETOGGLE:
+                       case AC_DISPLAYTOGGLE: /* deprecated */
+                       case AC_MODETOGGLE:    /* deprecated */
+                               break;
+                       case AC_CUSTOM:
+                               switch (code)
+                               {
+                                       case CODE_MODETOGGLE:
+                                       case CODE_DISPLAYTOGGLE:
+                                               break;
+                                       default:
+                                               return BadValue;
+                               }
                                break;
                        default:
                                return BadValue;
diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 9d47ea6..e8cc8db 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -891,7 +891,7 @@ static int special_map_core(Display *dpy, int argc, char 
**argv, unsigned long *
 
 static int special_map_modetoggle(Display *dpy, int argc, char **argv, 
unsigned long *ndata, unsigned long *data)
 {
-       data[*ndata] = AC_MODETOGGLE;
+       data[*ndata] = AC_CUSTOM | CODE_MODETOGGLE;
 
        *ndata += 1;
 
@@ -900,7 +900,7 @@ static int special_map_modetoggle(Display *dpy, int argc, 
char **argv, unsigned
 
 static int special_map_displaytoggle(Display *dpy, int argc, char **argv, 
unsigned long *ndata, unsigned long *data)
 {
-       data[*ndata] = AC_DISPLAYTOGGLE;
+       data[*ndata] = AC_CUSTOM | CODE_DISPLAYTOGGLE;
 
        *ndata += 1;
 
@@ -1798,6 +1798,19 @@ static int get_actions(Display *dpy, XDevice *dev,
                        case AC_DISPLAYTOGGLE:
                                strcat(buff, "displaytoggle ");
                                break;
+                       case AC_CUSTOM:
+                               switch (detail)
+                               {
+                                       case CODE_MODETOGGLE:
+                                               strcat(buff, "modetoggle ");
+                                               break;
+                                       case CODE_DISPLAYTOGGLE:
+                                               strcat(buff, "displaytoggle ");
+                                               break;
+                                       default:
+                                               sprintf(buff, "custom(%d) ", 
detail);
+                                               break;
+                               }
                        default:
                                TRACE("unknown type %d\n", current_type);
                                continue;
-- 
1.7.6


------------------------------------------------------------------------------
FREE DOWNLOAD - uberSVN with Social Coding for Subversion.
Subversion made easy with a complete admin console. Easy 
to use, easy to manage, easy to install, easy to extend. 
Get a Free download of the new open ALM Subversion platform now.
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to