print_screen button?

I know that the manual says it’s not available on some OS’es “because it is used by the system”, but that sounds weird as we are porting a game to the Panda3d engine and it has no problem with using that key (the old engine source is not available now btw).

The key creates a screenshot of the game window, btw. I checked, the screenshot is generated right after pressing it, not an equivalent of Panda’s “print_screen-up”.

What system is it not working on?

Windows (7). The manual mentioned that Panda doesn’t support print_screen too. You didn’t know?

I wasn’t specifically aware of this, but a quick Google search does confirm that Windows eats the WM_KEYDOWN message for the print screen button, without sending it to the application. So it seems it’s not possible to catch the print screen button on a Windows application without going to something like DirectInput, which is no doubt what your other game did.

I’m not opposed to rewriting Panda’s keyboard handling to use DirectInput (or whatever the modern equivalent is) on Windows, as long as it also remained compatible with high-level inputs such as the IME. Someone would have to volunteer to do this work, of course–would you like to do it?

David

Why rewrite everything to DirectInput? Why not just add an exception to use DirectInput for print_screen on Windows?
Either way it’s not my speciality.

I think the manual indirectly gives the wrong impression that it’s not possible for any application to use that key because of how the OS works, but seems it’s not true.

I understand that DirectInput is an all-or-nothing proposal. You’re completely replacing the normal keyboard handling messages with direct access to the raw keyboard data. That means you become responsible for properly handling all of the messages.

I could be wrong. As you say, it’s not my specialty either. So far, no one has professed enough interest in solving this problem to step up and make it their specialty.

David

I thought I’d just go with “print_screen-up”, but it seems an up event is generated every time you minimize or change the Panda window, so the function is also ran.

from pandac.PandaModules import *
import direct.directbase.DirectStart

def printScreen():
	print "Clicked"
	
base.accept("print_screen-up", printScreen)

run()

Yeah, it actually spams every single possible button up event when the window focus is lost. This behavior has been annoying for a very long time.

I just committed a fix. Now it will only send sensible button ups when the focus is lost.

David

Thanks.
I think I understand the point behind it now.
Maybe it would be better to allow to specify which buttons are “sensible” or not.

In my application I simply bind to the up-event of Ctrl+PrintScreen, and display a message in the status bar whenever the up event of just PrintScreen is heard.

By “sensible” buttons I mean that set of buttons for which we have recently seen a button-down event but not a button-up event. There’s obviously no point to synthesizing any other button-up events than those.

David

Oh, that’s even better than what I though.