2

I am trying to write touch events. I am using a camera to track hands so I need two pointers and I need to display them.

This is what I have tried but it does nothing:

import uinput
import time

device = uinput.Device([
        uinput.BTN_TOUCH,
        uinput.BTN_TOOL_PEN,
        # uinput.INPUT_PROP_POINTER,  # This property doesn't exist... what is the alternative?
        uinput.ABS_X,
        uinput.ABS_Y,
        ])
time.sleep(1)

device.emit(uinput.ABS_X, 5)
device.emit(uinput.ABS_Y, 5)

device.emit(uinput.BTN_TOUCH, 1)

for i in range(20):
    time.sleep(0.01)
    device.emit(uinput.ABS_Y, 5 * i)

device.emit(uinput.BTN_TOUCH, 0)

However, using a mouse works:

import uinput
import time

device = uinput.Device([
        uinput.BTN_LEFT,
        uinput.BTN_RIGHT,
        uinput.REL_X,
        uinput.REL_Y,
        ])
time.sleep(1)

for i in range(20):
    time.sleep(0.01)
    device.emit(uinput.REL_Y, 5)

But I need absolute rather than relative positioning.

Is it possible for me to see events from the terminal for debugging?

I want to be able to have 2 pointers, absolute positioning, touch/click, hover(BTN_TOOL_PEN) and my intention is to allow drag/scrolling. Any guidance as to what events I should be using and a simple working example would be great!

I could not get evdev working but answers for that are welcome too.

ovg
  • 1,486
  • 1
  • 18
  • 30

1 Answers1

1

I assume that you're consuming those device events in a server somewhere? X11? Remove uinput.BTN_TOOL_PEN and define the range for each valuator:

    uinput.BTN_TOUCH,
    uinput.ABS_X + (0, 2**24-1, 0, 0),
    uinput.ABS_Y + (0, 2**24-1, 0, 0),
    uinput.ABS_PRESSURE + (0, 255, 0, 0),

If you still have problems, keep an eye on your Xorg log file.

totaam
  • 1,306
  • 14
  • 25