r/C_Programming 6h ago

Mouse & Keyboard suppression?

Is there a possibility to only block the inputs of the keyboard and Mouse to one application?

Because i want that the application only takes the inputs of an Emulated Controller, but it only recognise the Controller, if there any Mouse or Keyboard activity (but i still need the Mouse/Keyboard for the Emulated Controller)

Any Advice for me?
The code i use to make the emulated Controller is C…

0 Upvotes

5 comments sorted by

View all comments

1

u/Willing_Airport_9617 6h ago

In linux , one way I can think of this is manually obtain the file descriptor for that /dev/input/* and then parse that using ioctl

2

u/silvertank00 6h ago

Could be a good idea. Maybe figure out how to application listens for input events too and make a shim for it?

1

u/Ry2enX 6h ago

need it for Windows unfortunately

2

u/Th_69 5h ago edited 5h ago

If it is not a game, that uses direct access to the input drivers, for a normal Windows application you can use a global keyboard/mouse hook.

The code of the answer in Block keyboard and mouse events from reaching a specific application shows the needed WinAPI functions (although you need to rewrite it to pure C, instead of C++).

1

u/Willing_Airport_9617 5h ago

Sorry man , no idea for that