Skip to content

Commit 699cee3

Browse files
committed
tslib.c: define TOUCH_NUM_AXES 2 and avoid magic numbers
1 parent 59a0fd0 commit 699cee3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/tslib.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767

6868
#define TOUCH_MAX_SLOTS 10 /* fallback if not found */
6969
#define TOUCH_SAMPLES_READ 3 /* up to, if available */
70-
#define MAXBUTTONS 11 /* > 10 */
70+
#define MAXBUTTONS 11 /* > 10 */
71+
#define TOUCH_NUM_AXES 2 /* x, y */
7172

7273
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 23
7374
#define HAVE_THREADED_INPUT 1
@@ -218,7 +219,7 @@ static void init_button_labels(Atom *labels, size_t size)
218219

219220
static void init_axis_labels(Atom *labels, size_t size)
220221
{
221-
assert(size >= 2);
222+
assert(size >= TOUCH_NUM_AXES);
222223

223224
memset(labels, 0, size * sizeof(Atom));
224225
labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_X);
@@ -230,7 +231,7 @@ static int xf86TslibControlProc(DeviceIntPtr device, int what)
230231
InputInfoPtr pInfo;
231232
unsigned char map[MAXBUTTONS + 1];
232233
Atom labels[MAXBUTTONS];
233-
Atom axis_labels[2];
234+
Atom axis_labels[TOUCH_NUM_AXES];
234235
int i;
235236
struct ts_priv *priv;
236237

@@ -261,7 +262,7 @@ static int xf86TslibControlProc(DeviceIntPtr device, int what)
261262
}
262263

263264
if (InitValuatorClassDeviceStruct(device,
264-
2,
265+
TOUCH_NUM_AXES,
265266
axis_labels,
266267
0, Absolute) == FALSE) {
267268
xf86IDrvMsg(pInfo, X_ERROR,
@@ -310,7 +311,7 @@ static int xf86TslibControlProc(DeviceIntPtr device, int what)
310311
if (InitTouchClassDeviceStruct(device,
311312
priv->slots,
312313
XIDirectTouch,
313-
2 /* axes */) == FALSE) {
314+
TOUCH_NUM_AXES) == FALSE) {
314315
xf86IDrvMsg(pInfo, X_ERROR,
315316
"Unable to allocate TouchClassDeviceStruct\n");
316317
return !Success;
@@ -439,7 +440,7 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
439440
xf86CollectInputOptions(pInfo, NULL);
440441
xf86ProcessCommonOptions(pInfo, pInfo->options);
441442

442-
priv->valuators = valuator_mask_new(6);
443+
priv->valuators = valuator_mask_new(TOUCH_NUM_AXES);
443444
if (!priv->valuators)
444445
return BadValue;
445446

0 commit comments

Comments
 (0)