Search code examples
pythonpython-3.xtouchkivycalibration

Cant calibrate touchscreen on kivy


For my pi touchscreen project I am working with an -you guessed it- pi and an egalax touchdriver. The thing receives input and the touchscreen actually works, after some minor tweaking like inverting y_axis and stuff. However, at this moment I'm stuck trying to touch a certain button on the edge of the screen which I can't reach. I actually use a pen with the cursor enabled to make sure I know where the screen registers my input.

So after searching a bit in the kivy documents I came across this postproc.calibration module which should do the trick.

But it doesn't. I tried putting the following 2 code snippets in the .kivy/config.ini file:

[input]
egalax = hidinput,/dev/input/event0,rotation=90,invert_y=1

[postproc:calibration]
egalax = xratio=1.2,yratio=1.2

The [input] bit works, no problems there. the [postproc:calibration] bit is what doesn't work. I've tried putting the line above the [postproc] module, beneath it, even beneath the [modules] module. Also I've tried putting the egalax = xratio=1.2,yratio=1.2 line IN the [postproc] module. Didn't seem to work. I've also tried to increase the floats to 2.0, but no changes.

So how would I 'expand' my area of touch input?


Solution

  • For this problem I found a solution from this source: Google group. Just for clarification: it involves changing a file in the kivy install directories.

    In /usr/local/lib/python3.5/dist-packages/kivy/input/providers/hdinput.py insert the last line:

    class HIDInputMotionEventProvider(MotionEventProvider):
        options = ('min_position_x', 'max_position_x',
                   'min_position_y', 'max_position_y',
                   'min_pressure', 'max_pressure',
                   'invert_x', 'invert_y', 'rotation',
                -> 'min_abs_x', 'max_abs_x', 'min_abs_y', 'max_abs_y') # <- this one
    

    Then in your .kivy/config.ini file you add this:

    [input]
    eGalax = hidinput,/dev/input/event1,rotation=90,min_abs_x=60,min_abs_y=90,max_abs_x=1985,max_abs_y=1970
    

    With that atleast my touchscreen (an eGalax thing) is calibrated.