Disable gamepad input on background apps

Does there currently exist a way to disable gamepad input on apps that are not in focus?

At times I like to have two types of games open, but when they both use gamepads, they’ll both respond to inputs at the same time. Even for a more normal use case, having one game open, putting it in the background to do other things and then bumping your controller accidentally will have the game respond while not in focus.

What your DE?

KDE Plasma, I think. I’m still new and figuring out some terms, so let me know if that’s not what you meant.