Recording start time of screen touches in PsychoPy on Windows

I am helping to implement an experiment using PsychoPy on a Windows 8 tablet. It seems that it is not possible to directly access touch events through the PsychoPy or pyglet or PyGame interfaces.

Most of the other sources I found have referenced using mouse move events instead of touch events. This works great for position recording, but for recording time it doesn't work for us. We'd like to collect the start time of the touch while the mouse event comes at the end of the touch.

Does anyone know of a way to do this, either in PsychoPy or by importing another library into the experiment?

Update : Writing mouse events to the ioHub, it looks like mouse click and cancel events are dispatched at the end of the touch. This makes sense since this is the point where the OS is certain that the touch is not a napkin. (Also, it will decide whether the tap is left or right click based on the duration of the tap.)

+3


source to share


1 answer


I managed to do this using a hook in WndProc, it's not pretty, but it works. Solution for posterity:

https://github.com/alisdt/pywmtouchhook



Short review:

I used a combination of ctypes and pywin32 (unfortunately neither was able to get the job done) to register the target HWND to receive touch messages and replace it with WndProc, passing all non-touch messages to the original WndProc.

+1


source







All Articles