1
0
forked from 0ad/0ad

Allow the standard Windows PrtSc action (i.e. copy to clipboard) if HOTKEY_SCREENSHOT has been redefined

This was SVN commit r951.
This commit is contained in:
Ykkrosh 2004-08-09 20:58:32 +00:00
parent 0b3361b6f5
commit 230731c69d
3 changed files with 27 additions and 7 deletions

View File

@ -35,6 +35,7 @@
#include "win_internal.h"
#include "SDL_vkeys.h"
#include "ps/Hotkey.h"
#include <assert.h>
#include <stdio.h>
@ -446,14 +447,19 @@ LRESULT CALLBACK keyboard_ll_hook(int nCode, WPARAM wParam, LPARAM lParam)
// replace Windows PrintScreen handler
if(vk == VK_SNAPSHOT)
{
// send to wndproc
UINT msg = (UINT)wParam;
PostMessage(hWnd, msg, vk, 0);
// specify hWnd to be safe.
// if window not yet created, it's INVALID_HANDLE_VALUE.
// check whether PrintScreen should be taking screenshots -- if
// not, allow the standard Windows clipboard to work
if(keyRespondsTo(HOTKEY_SCREENSHOT, SDLK_PRINT))
{
// send to wndproc
UINT msg = (UINT)wParam;
PostMessage(hWnd, msg, vk, 0);
// specify hWnd to be safe.
// if window not yet created, it's INVALID_HANDLE_VALUE.
// don't pass it on to other handlers
return 1;
// don't pass it on to other handlers
return 1;
}
}
}

View File

@ -478,3 +478,15 @@ int hotkeyInputHandler( const SDL_Event* ev )
}
return( EV_PASS );
}
// Returns true if the specified HOTKEY_* responds to the specified SDLK_*
// (mainly for the screenshot system to know whether it needs to override
// the printscreen screen). Ignores modifier keys.
bool keyRespondsTo( int hotkey, int sdlkey )
{
for (KeyMapping::iterator it = hotkeyMap[sdlkey].begin(); it != hotkeyMap[sdlkey].end(); ++it)
if (it->mapsTo == hotkey)
return true;
return false;
}

View File

@ -102,4 +102,6 @@ void initKeyNameMap();
CStr getKeyName( int keycode );
int getKeyCode( CStr keyname );
bool keyRespondsTo( int hotkey, int sdlkey );
extern bool hotkeys[HOTKEY_LAST];