Skip to content

Commit 95eba6d

Browse files
committed
Merge remote-tracking branch 'origin/pr/228'
* origin/pr/228: Add error checking on input device init Correctly label pointing device as absolute, not relative
2 parents 8f8c0a1 + 6898bf9 commit 95eba6d

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

xf86-input-mfndev/src/qubes.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ static void QubesUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
263263

264264
static int _qubes_init_kbd(DeviceIntPtr device)
265265
{
266-
InitKeyboardDeviceStruct(device, NULL, NULL, NULL);
266+
if (!InitKeyboardDeviceStruct(device, NULL, NULL, NULL))
267+
return BadAlloc;
267268
return Success;
268269
}
269270

@@ -328,8 +329,8 @@ static void QubesInitAxesLabels(QubesDevicePtr pQubes, int natoms,
328329
const char **labels;
329330
int labels_len = 0;
330331

331-
labels = rel_labels;
332-
labels_len = ArrayLength(rel_labels);
332+
labels = abs_labels;
333+
labels_len = ArrayLength(abs_labels);
333334

334335
memset(atoms, 0, natoms * sizeof(Atom));
335336

@@ -360,22 +361,23 @@ static int _qubes_init_axes(DeviceIntPtr device)
360361
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
361362
atoms,
362363
#endif
363-
GetMotionHistorySize(), 0))
364+
GetMotionHistorySize(),
365+
Absolute))
364366
return BadAlloc;
365367

366368
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
367-
pInfo->dev->valuator->mode = Relative;
369+
pInfo->dev->valuator->mode = Absolute;
368370
#endif
369371
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 13
370372
if (!InitAbsoluteClassDeviceStruct(device))
371373
return BadAlloc;
372374
#endif
373375

374376
for (i = 0; i < pQubes->axes; i++) {
375-
xf86InitValuatorAxisStruct(device, i, *pQubes->labels, -1,
376-
-1, 1, 1, 1
377+
xf86InitValuatorAxisStruct(device, i, atoms[i], 0,
378+
32767, 1, 1, 1
377379
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
378-
, Relative
380+
, Absolute
379381
#endif
380382
);
381383
xf86InitValuatorDefaults(device, i);
@@ -484,14 +486,22 @@ static int QubesControl(DeviceIntPtr device, int what)
484486
InputInfoPtr pInfo = device->public.devicePrivate;
485487
QubesDevicePtr pQubes = pInfo->private;
486488
DeviceIntPtr master_kbd = NULL;
489+
int ret;
487490

488491
switch (what) {
489492
case DEVICE_INIT:
490493
device->public.on = FALSE;
491-
_qubes_init_buttons(device);
492-
_qubes_init_axes(device);
493-
_qubes_init_kbd(device);
494-
InitPtrFeedbackClassDeviceStruct(device, QubesPtrCtrlProc);
494+
ret = _qubes_init_buttons(device);
495+
if (ret != Success)
496+
return ret;
497+
ret = _qubes_init_axes(device);
498+
if (ret != Success)
499+
return ret;
500+
ret = _qubes_init_kbd(device);
501+
if (ret != Success)
502+
return ret;
503+
if (!InitPtrFeedbackClassDeviceStruct(device, QubesPtrCtrlProc))
504+
return BadAlloc;
495505
break;
496506

497507
/* Switch device on. Establish socket, start event delivery. */

0 commit comments

Comments
 (0)