[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] How to prevent mouse initialization in Pygame



On Fri, Jun 30, 2017 at 12:28 PM, Роман Мещеряков <roman.mescheryakov@xxxxxxxxx> wrote:

In my Python application running on Raspberry Pi under Raspbian I use Pygame to display some software-generated images via framebuffer. I don’t need any input from mouse, keyboard or any other devices, all I need is a convenient way of using framebuffer.

 

I initialize Pygame in the following way:

 

Problem #1: I have mouse pointer at the top left corner of Pygame-drawn images. I want mouse pointer to be hidden.

I know that I can disable mouse pointer using pygame.mouse.set_visible, but here comes

Problem #2: I have to run my application with sudo in order for pygame to not raise “

​​
unable to open a console terminal” exception. But I want to run my application without root rights, because this increases my application’s security.

There are some posts on forums that recommend setting SDL_NOMOUSE=1 environment variable before initializing pygame which should skip mouse initialization and maybe make it possible to get rid of sudo, but this doesn’t work for me: I still need to use sudo and mouse pointer is still there.

If this makes any difference, I have no mouse or keyboard attached to the Raspberry Pi, I connect to it using SSH.

I use

Pygame version 1.9.2~pre~r3348-2~bpo8+rpi1

libsdl-image1.2 version 1.2.12-5+b1

libsdl1.2debian version 1.2.15-10+rpi1

 

Does SDL_NOMOUSE work for anyone using recent Pygame versions?

Is it possible to skip mouse initialization in Pygame?

P.S. This question was originally posted on StackExchange, but it seems I chose the wrong section. For this reason or another, I haven’t got any straight answer yet, so I write here and hope for the best :)

​Hi,

It's not exactly clear to me what you're trying to do. It sounds like:

I want to SSH into a RPI, open a fullscreen window on it, and disable user input on that window entirely. However, the mouse cursor still shows on that window, and I can't disable it with `mouse.set_visible(...)` because that makes my program require root privileges.

If this is so, your code and attempts are more-or-less what I would have tried. I don't know enough about Debian to know if that permission error is insurmountable (I can think of a fairly good reason it should be; you don't want random users to be able to hijack already running graphical sessions, although I'd expect opening a fullscreen window would also require root privileges for the same reason).

If it does turns out to be unworkable, is SSHing into the RPI and uploading images to an already-running daemon an answer? What exactly are you trying to do?

Ian​