|
|
|
Return to General Discussion
by preusser » Sat Jan 14, 2012 3:07 am
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".
-
preusser
-
- Posts: 516
- Joined: Sun Mar 27, 2011 10:07 am
by drwr » Sat Jan 14, 2012 10:31 am
What system is it not working on?
-
drwr
-
- Posts: 11253
- Joined: Fri Feb 13, 2004 12:42 pm
- Location: Glendale, CA
by preusser » Sat Jan 14, 2012 10:59 am
Windows (7). The manual mentioned that Panda doesn't support print_screen too. You didn't know?
-
preusser
-
- Posts: 516
- Joined: Sun Mar 27, 2011 10:07 am
by drwr » Sat Jan 14, 2012 11:30 am
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
-
drwr
-
- Posts: 11253
- Joined: Fri Feb 13, 2004 12:42 pm
- Location: Glendale, CA
by preusser » Sat Jan 14, 2012 11:45 am
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.
-
preusser
-
- Posts: 516
- Joined: Sun Mar 27, 2011 10:07 am
by drwr » Sat Jan 14, 2012 1:45 pm
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
-
drwr
-
- Posts: 11253
- Joined: Fri Feb 13, 2004 12:42 pm
- Location: Glendale, CA
by preusser » Sun Jan 15, 2012 4:29 am
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.
- Code: Select all
from pandac.PandaModules import * import direct.directbase.DirectStart
def printScreen(): print "Clicked" base.accept("print_screen-up", printScreen)
run()
-
preusser
-
- Posts: 516
- Joined: Sun Mar 27, 2011 10:07 am
by drwr » Sun Jan 15, 2012 12:02 pm
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
-
drwr
-
- Posts: 11253
- Joined: Fri Feb 13, 2004 12:42 pm
- Location: Glendale, CA
by preusser » Mon Jan 16, 2012 3:35 am
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.
-
preusser
-
- Posts: 516
- Joined: Sun Mar 27, 2011 10:07 am
by bluskies » Mon Jan 16, 2012 9:41 am
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.
>>> print capitalOfCanada == 'Toronto'
False
>>> print capitalOfCanada
'Ottawa'
-
bluskies
-
- Posts: 109
- Joined: Thu Jun 17, 2010 9:28 am
- Location: 45.32, -75.67
-
by drwr » Mon Jan 16, 2012 10:05 am
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
-
drwr
-
- Posts: 11253
- Joined: Fri Feb 13, 2004 12:42 pm
- Location: Glendale, CA
by preusser » Mon Jan 16, 2012 12:38 pm
Oh, that's even better than what I though.
-
preusser
-
- Posts: 516
- Joined: Sun Mar 27, 2011 10:07 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 0 guests
| | |