Shared change with SMA, Low Level Hooks to disable Window's system shortcuts, try to press Windows Key when SM has focus :D

This commit is contained in:
Aldo Fregoso
2011-07-18 22:41:13 -05:00
parent 7014edbe26
commit c14dfd767c
+45 -1
View File
@@ -69,7 +69,8 @@
#include "Profile.h"
#if defined(WIN32)
#include <windows.h>
#include <windows.h>
#include "archutils/Win32/AppInstance.h" // used by SetWindowsHookEx -Aldo
#endif
void ShutdownGame();
@@ -934,6 +935,32 @@ static void ApplyLogPreferences()
static LocalizedString COULDNT_OPEN_LOADING_WINDOW( "StepMania", "Couldn't open any loading windows." );
#if defined(WIN32)
// Low Level hooks go here, I only added Windows Key, but letting the player choose which system shortcuts
// wants to get disabled via PREFSMAN would be nice -Aldo
LRESULT CALLBACK SpecialKeysHook(int code,WPARAM wparam,LPARAM lparam)
{
if( HOOKS->AppHasFocus() ) // only disable system shortcuts when the game has focus
{
PKBDLLHOOKSTRUCT key = (PKBDLLHOOKSTRUCT)lparam;
switch(wparam)
{
case WM_KEYDOWN:
case WM_KEYUP:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
if(key->vkCode==VK_LWIN || key->vkCode==VK_RWIN)
{
return 1;
}
}
}
return CallNextHookEx(0,code,wparam,lparam);
}
#endif
int main(int argc, char* argv[])
{
RageThreadRegister thread( "Main thread" );
@@ -1124,6 +1151,23 @@ int main(int argc, char* argv[])
StoreActualGraphicOptions();
LOG->Info( "%s", GetActualGraphicOptionsString().c_str() );
#if defined(WIN32)
// Apply Low Level hooks just after creating the display, so we have a valid
// HINSTANCE, rather than a NULL one -Aldo
AppInstance inst;
HHOOK hook;
hook = SetWindowsHookEx(
WH_KEYBOARD_LL,
SpecialKeysHook,
inst.Get(),
0
);
if(!hook)
{
LOG->Warn("SetWindowsHookEx: Could not create hook (Error %d).", GetLastError());
}
#endif
SONGMAN->PreloadSongImages();
/* Input handlers can have dependences on the video system so