Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Alexander_Naumov:SLE12
xf86-input-wacom
n_01-Add-option-to-enable-logging.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File n_01-Add-option-to-enable-logging.patch of Package xf86-input-wacom
From: Egbert Eich <eich@suse.com> Date: Fri Feb 7 23:06:26 2014 +0100 Subject: [PATCH 1/4]Add option to enable logging Patch-Mainline: never Git-commit: 9717547311abfe18b7edad9e0b45f16b902e2f2d Git-repo: git://linuxwacom.git.sourceforge.net/gitroot/linuxwacom/xf86-input-wacom References: FATE# Signed-off-by: Egbert Eich <eich@suse.com> This patch adds an option to set a bitmask marking events to be logged to the Xserver log file. Currently the list contains the following bits: PROXIMITY low level event 1 PRESSURE low level event 2 BUTTON high level event 7 Signed-off-by: Egbert Eich <eich@suse.com> --- configure.ac | 11 +++++++++++ include/wacom-properties.h | 9 +++++++++ man/wacom.man | 19 +++++++++++++++++++ man/xsetwacom.man | 19 ++++++++++++++++++- src/wcmCommon.c | 35 +++++++++++++++++++++++++++++++++++ src/wcmConfig.c | 4 ++++ src/wcmUSB.c | 25 +++++++++++++++++++++++++ src/wcmXCommand.c | 22 +++++++++++++++++++++- src/xf86Wacom.h | 22 ++++++++++++++++++++++ src/xf86WacomDefs.h | 4 +++- tools/xsetwacom.c | 10 ++++++++++ 11 files changed, 177 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5eae74d..008a804 100644 --- a/configure.ac +++ b/configure.ac @@ -86,6 +86,17 @@ if test "x$DEBUGGING" = xyes; then AC_DEFINE(DEBUG, 1, [Enable debugging code]) fi +# Define a configure option for event logging +AC_ARG_ENABLE(logging, + AS_HELP_STRING([--enable-logging], + [Enable logging (default: disabled)]), + [LOGGING=$enableval], [LOGGING=yes]) + +# Define the C preprocessor macro LOGGING in config.h +if test "x$LOGGING" = xyes; then + AC_DEFINE(LOGGING, 1, [Enable logging code]) +fi + # Define a configure option for an alternate input module directory AC_ARG_WITH(xorg-module-dir, AS_HELP_STRING([--with-xorg-module-dir=DIR], diff --git a/include/wacom-properties.h b/include/wacom-properties.h index b845083..f566d14 100644 --- a/include/wacom-properties.h +++ b/include/wacom-properties.h @@ -111,6 +111,15 @@ */ #define WACOM_PROP_PRESSURE_RECAL "Wacom Pressure Recalibration" +/* 8 bit, values: + Type bit + PROXIMITY_LOW_LEVEL event 1 + PRESSURE_LOW_LEVEL event 2 + BUTTON_HIGH_LEVEL event 7 + Log event of the types specified in the type mask. +*/ +#define WACOM_PROP_LOGMASK "Wacom Log Mask" + /* The following are tool types used by the driver in WACOM_PROP_TOOL_TYPE * or in the 'type' field for XI1 clients. Clients may check for one of * these types to identify tool types. diff --git a/man/wacom.man b/man/wacom.man index ae042f6..f699842 100644 --- a/man/wacom.man +++ b/man/wacom.man @@ -267,6 +267,25 @@ initial pressure reading may be unequal to zero even for a perfectly good pen. If the consecutive pressure readings are not higher than the initial pressure by a threshold no button event will be generated. This option allows to disable the recalibration. +.TP 4 +.B Option \fI"LogMask" \fI"number"\fP +bitmask that enables logging of a group of events. +.RS +.PD 0 +.TP +Bit +Event +.TP +0 +proximity low level +.TP +1 +pressure low level +.TP +7 +button high level +.PD + .RE .SH "TOUCH GESTURES" .SS Single finger (1FG) diff --git a/man/xsetwacom.man b/man/xsetwacom.man index 35ee9fe..5e42e3f 100644 --- a/man/xsetwacom.man +++ b/man/xsetwacom.man @@ -242,7 +242,24 @@ initial pressure reading may be unequal to zero even for a perfectly good pen. If the consecutive pressure readings are not higher than the initial pressure by a threshold no button event will be generated. This option allows to disable the recalibration. Default: on - +.TP +\fBLogMask\fR mask +bitmask that enables logging of a group of events. +.RS +.PD 0 +.TP +Bit +Event +.TP +0 +proximity low level +.TP +1 +pressure low level +.TP +7 +button high level +.PD .SH "AUTHORS" Peter Hutterer <peter.hutterer@redhat.com> diff --git a/src/wcmCommon.c b/src/wcmCommon.c index 6abb23b..238cf78 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -27,6 +27,9 @@ #include "wcmTouchFilter.h" #include <xkbsrv.h> #include <xf86_OSproc.h> +#ifdef LOGGING +#include <time.h> +#endif /* X servers pre 1.9 didn't copy data passed into xf86Post*Event. * Data passed in would be modified, requiring the driver to copy the @@ -85,6 +88,35 @@ void set_absolute(InputInfoPtr pInfo, Bool absolute) priv->flags &= ~ABSOLUTE_FLAG; } +#ifdef LOGGING +void wcm_timestr(char *str, int str_n) +{ + struct timespec tp; + struct tm tm; + static char wday_name[7][3] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + static char mon_name[12][3] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + + str[0] = '\0'; + if (clock_gettime(CLOCK_REALTIME, &tp) < 0) + return; + localtime_r(&tp.tv_sec, &tm); + + snprintf(str, str_n, " %.3s %.3s%3d %.2d:%.2d:%.2d.%.6d - ", + wday_name[tm.tm_wday], + mon_name[tm.tm_mon], + tm.tm_mday, tm.tm_hour, + tm.tm_min, tm.tm_sec, (int)tp.tv_nsec); + + return; + +} +#endif + /***************************************************************************** * wcmMappingFactor -- * calculate the proper tablet to screen mapping factor according to the @@ -1523,6 +1555,9 @@ WacomCommonPtr wcmNewCommon(void) common->wcmRawSample = DEFAULT_SAMPLES; /* number of raw data to be used to for filtering */ common->wcmPressureRecalibration = 1; +#ifdef LOGGING + common->LogMask = 0; +#endif return common; } diff --git a/src/wcmConfig.c b/src/wcmConfig.c index a8077f9..7965e13 100644 --- a/src/wcmConfig.c +++ b/src/wcmConfig.c @@ -637,6 +637,10 @@ static int wcmPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) common->debugLevel = xf86SetIntOption(pInfo->options, "CommonDBG", common->debugLevel); +#ifdef LOGGING + common->LogMask = xf86SetIntOption(pInfo->options, + "LogMask", common->LogMask); +#endif oldname = strdup(pInfo->name); if (wcmIsHotpluggedDevice(pInfo)) diff --git a/src/wcmUSB.c b/src/wcmUSB.c index dca0751..e99960f 100644 --- a/src/wcmUSB.c +++ b/src/wcmUSB.c @@ -1103,6 +1103,31 @@ static int usbIdToType(int id) return type; } +#ifdef LOGGING +/** + * Return type name string. + * @param type + * @return string + */ +static const char *usbTypeName(unsigned long type) +{ + switch (type) { + case STYLUS_ID: + return "PEN"; + case ERASER_ID: + return "RUBBER"; + case CURSOR_ID: + return "MOUSE"; + case TOUCH_ID: + return "TOUCH"; + case PAD_ID: + return "PAD"; + default: + return "UNKNOWN"; + } +} +#endif + /** * Find the tool type (STYLUS_ID, etc.) based on the device_id. * diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c index 0ec8737..504a03a 100644 --- a/src/wcmXCommand.c +++ b/src/wcmXCommand.c @@ -100,6 +100,9 @@ Atom prop_tooltype; Atom prop_btnactions; Atom prop_product_id; Atom prop_pressure_recal; +#ifdef LOGGING +Atom prop_logmask; +#endif #ifdef DEBUG Atom prop_debuglevels; #endif @@ -317,7 +320,10 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo) values[0] = common->vendor_id; values[1] = common->tablet_id; prop_product_id = InitWcmAtom(pInfo->dev, XI_PROP_PRODUCT_ID, XA_INTEGER, 32, 2, values); - +#ifdef LOGGING + values[0] = common->LogMask; + prop_logmask = InitWcmAtom(pInfo->dev, WACOM_PROP_LOGMASK, XA_INTEGER, 8, 1, values); +#endif #ifdef DEBUG values[0] = priv->debugLevel; values[1] = common->debugLevel; @@ -921,6 +927,20 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, common->debugLevel = values[1]; } #endif +#ifdef LOGGING + } else if (property == prop_logmask) { + CARD8 *values; + + if (prop->size != 1 || prop->format != 8) + return BadMatch; + + values = (CARD8*)prop->data; + + if (!checkonly) + { + common->LogMask = values[0]; + } +#endif } else if (property == prop_btnactions) { int nbuttons = priv->nbuttons < 4 ? priv->nbuttons : priv->nbuttons + 4; diff --git a/src/xf86Wacom.h b/src/xf86Wacom.h index 6872108..9bbee03 100644 --- a/src/xf86Wacom.h +++ b/src/xf86Wacom.h @@ -68,6 +68,28 @@ #define DBG(lvl, priv, ...) #endif +#ifdef LOG +#undef LOG +#endif +#ifdef LOGGING +void wcm_timestr(char *str, int str_n); +#define DO_LOG(m, v) (m->LogMask & v) +#define LOG(m, v, f, ...) do { \ + if (DO_LOG(m, v)) { \ + char tstr[30]; \ + wcm_timestr(tstr, sizeof(tstr)); \ + LogMessageVerbSigSafe(X_NONE, -1, "[LOG]%s " f, tstr, __VA_ARGS__); \ + } \ +} while (0) +#define LOG_PROXIMITY_LOW 1 << 0 +#define LOG_PRESSURE_LOW 1 << 1 +#define LOG_BUTTON_HIGH 1 << 7 +#else +#define DO_LOG(m, v) (0) +#define LOG(m, v, f, ...) do { \ + } while (0) +#endif + /****************************************************************************** * WacomModule - all globals are packed in a single structure to keep the * global namespaces as clean as possible. diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h index 476d94d..0dc1d42 100644 --- a/src/xf86WacomDefs.h +++ b/src/xf86WacomDefs.h @@ -493,7 +493,9 @@ struct _WacomCommonRec int wcmRawSample; /* Number of raw data used to filter an event */ int wcmPressureRecalibration; /* Determine if pressure recalibration of worn pens should be performed */ - +#ifdef LOGGING + int LogMask; /* Mask to determine which event types to log. */ +#endif int bufpos; /* position with buffer */ unsigned char buffer[BUFFER_SIZE]; /* data read from device */ diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 508326e..aace755 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -152,6 +152,16 @@ static param_t parameters[] = .arg_count = 1, }, { + .name = "LogMask", + .desc = "Mask whose bits determine which events to log: " + "0 PROXIMITY event, 1 BUTTON event, 2 MOTION event, " + "3 PRESSURE event", + .prop_name = WACOM_PROP_LOGMASK, + .prop_format = 8, + .prop_offset = 0, + .arg_count = 1, + }, + { .name = "Suppress", .desc = "Number of points trimmed (default is 2). ", .prop_name = WACOM_PROP_SAMPLE,
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor