Re: [Linuxwacom-devel] [PATCH 1/3] Introduce AC_CUSTOM; deprecate AC_MODETOGGLE and AC_DISPLAYTOGGLE
On Fri, Aug 12, 2011 at 04:01:06PM -0700, Jason Gerecke wrote: 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 s/is a signal// * * if no action is set for a button, the button behaves normally. */ #define AC_CODE 0x /* Mask to isolate button number or key code */ #define AC_KEY 0x0001 /* Emit key events */ -#define AC_MODETOGGLE 0x0002 /* Toggle absolute/relative mode */ -#define AC_DBLCLICK 0x0003 /* DEPRECATED: use two button events instead */ -#define AC_DISPLAYTOGGLE0x0004 /* Toggle among screens */ +#define AC_MODETOGGLE 0x0002 /* DEPRECATED: Toggle absolute/relative mode */ +#define AC_CUSTOM 0x0003 /* Emit custom events */ +#define AC_DISPLAYTOGGLE0x0004 /* DEPRECATED: Toggle among screens */ #define AC_BUTTON 0x0008 /* Emit button events */ #define AC_TYPE 0x000f /* The mask to isolate event type bits */ #define AC_KEYBTNPRESS 0x0010 /* bit set for key/button presses */ #define AC_CORE 0x1000 /* DEPRECATED: has no effect */ #define AC_EVENT0xf00f /* 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_XX defines. + */ + switch (action AC_TYPE) + { + case AC_MODETOGGLE: + action ^= (action AC_TYPE); action = ~AC_TYPE; is the more common approach to unset flags. + 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
[Linuxwacom-devel] [PATCH 1/3] Introduce AC_CUSTOM; deprecate AC_MODETOGGLE and AC_DISPLAYTOGGLE
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 0x /* Mask to isolate button number or key code */ #define AC_KEY 0x0001 /* Emit key events */ -#define AC_MODETOGGLE 0x0002 /* Toggle absolute/relative mode */ -#define AC_DBLCLICK 0x0003 /* DEPRECATED: use two button events instead */ -#define AC_DISPLAYTOGGLE0x0004 /* Toggle among screens */ +#define AC_MODETOGGLE 0x0002 /* DEPRECATED: Toggle absolute/relative mode */ +#define AC_CUSTOM 0x0003 /* Emit custom events */ +#define AC_DISPLAYTOGGLE0x0004 /* DEPRECATED: Toggle among screens */ #define AC_BUTTON 0x0008 /* Emit button events */ #define AC_TYPE 0x000f /* The mask to isolate event type bits */ #define AC_KEYBTNPRESS 0x0010 /* bit set for key/button presses */ #define AC_CORE 0x1000 /* DEPRECATED: has no effect */ #define AC_EVENT0xf00f /* 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_XX 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_XX defines. +*/ +