How to block the keyboard and mouse?

Need help with C, C++, perl, python, etc?

How to block the keyboard and mouse?

Postby Teixeira » 2007-04-05 07:21

I wrote an application with C++/Qt and now if the application receives certain events I need to block/unblock the mouse and keyboard input for the whole system. Under Windows I can call the function “BlockInput()” but I do not found the equivalent function under Linux.
How can I do that with Linux?
Posts: 1
Joined: 2007-04-05 07:04

Postby rowan » 2007-04-06 10:40

Is this something malicious?
User avatar
Posts: 8
Joined: 2007-02-14 14:05

Postby Lavene » 2007-04-06 13:14

All input for the entire system? Holy sh**, remind me never to use your apps! ;)

Seriously though, I doubt there is such a function (But I admit I don't know anything about C++) because I can't imagine under what circumstances you would want that. And a Qt app even? What if it bombs? Qt is good but it's not bullet proof. It will lock up your system completely and force a hard reset... Not a good thing at all.

I'm pretty sure there are ways to do it but I would really really advice against it.

Site admin
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby thamarok » 2007-04-06 14:38

For the mouse: modprobe -r psmouse
And to bring it back to function, just modprobe psmouse

Didn't find anything working to disable the keyboard yet.. but I think it would be impossible.

Postby Guest » 2007-04-06 16:31

Yes, I need to “freeze” the keyboard and mouse input for the complete system! The reasons to do that are not exceptional as it looks. A short explanation: the application runs in factories and is responsible to control some robots, to monitor several quality parameters, to send a couple of telegrams and so on. We need a keyboard and a mouse only to parameterize the system. During the normal operation neither a mouse nor a keyboard are necessary. In few installations we have sporadically the problem that when the machine operator is bored during his pause he think that our computer can be used to play some games. Well!
Now we plan to lock the system using a digital input: if it is on the keyboard and the mouse are locked, if it is off they are unlocked.
I will be grateful if you can send good ideas. Thanks in advance!

Postby sinical » 2007-04-07 08:17

Sounds well.. suss to me, blocking input is a real pita when thigs go wrong but,

QApplication::setOverrideCursor and QApplication::restoreOverrideCursor might be what you want for mouse movements... at least give the poor admin keyboard ways out of this system with out yanking power

Seeing as you did ask for ideas, here is one. Couldnt you do an (albiet) ugly ncurses interface with direct to a terminal console and when the rpgoram is doing its thing just have a please wait / progress meter going?
Every cloud has a silver lining, except for the mushroom shaped ones, which have a lining of Strontium 90.
umop apisdn
User avatar
Posts: 1022
Joined: 2007-03-25 11:52

Return to Programming

Who is online

Users browsing this forum: No registered users and 4 guests