Announcement

Collapse
No announcement yet.

Touchscreen from Python (without X)?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Touchscreen from Python (without X)?

    I've got the 4DPI-24-HAT working just fine playing videos on a Pi Zero W using https://github.com/AndrewFromMelbourne/raspi2fb and omxplayer, and my client loves it!

    While I could use the buttons as per the supplied Python code, they are hard to get to in the case I'm using, and I'd much rather use the touchscreen. Is there a way to read the touchscreen with Python code if X is not running? Even just registering "Something touched me!" that would let me use the entire screen as a button would be better than nothing...

    Thanks!


  • #2
    Hi,

    Welcome to the forum,

    If this is the case, one way is using xdotool which can be found here: Simulate keyboard mouse events using xdotool raspberry pi


    Then, set the cursor location at (0,0) and when the current cursor location was changed, you could start a pop-up message.

    And also, subprocess will help you to execute a xdotool command within a python script.



    Hope it helps,

    Best regards,
    Kayven
    Last edited by kayven@4d; 9th February 2019, 04:42 PM.

    Comment


    • #3
      That's a lot of complexity, and I'm not sure how much of it'll work without X running (which it isn't in this case).

      Is there any way to interface to the touchscreen using Python on a device that isn't running X?

      THanks!

      Comment


      • #4
        So I've gotten to the point where I can either:

        A) Read the buttons from Python, send a simple text UI to /dev/tty1, and play a video using omxplayer and https://github.com/AndrewFromMelbourne/raspi2fb.git

        OR

        B) Start X and set/read the cursor position using xdotool and https://github.com/rshk/python-libxdo (but I'm unable to play the video)

        But not both. I'd love to be able to add some kind of touch-screen interface to A) above, any chance of a Python (or C or command line) interface to the touchscreen without running X?

        Thanks!

        Comment

        Working...
        X