Modified files for SDL2.

This commit is contained in:
LuisAntonRebollo 2015-01-18 22:52:29 +01:00
parent d08db6cc54
commit 21d58bb191
33 changed files with 436 additions and 136 deletions

View file

@ -136,7 +136,7 @@ HWND getWin32WindowHandle()
return NULL;
}
return ( ( Win32Window* ) window )->getHWND();
return (HWND)window->getSystemWindow( PlatformWindow::WindowSystem_Windows );
}
#endif

View file

@ -124,10 +124,21 @@ public:
/// Get the WindowController associated with this window
virtual void setInputController( IProcessInput *controller ) { if( mWindowInputGenerator ) mWindowInputGenerator->setInputController( controller ); };
WindowInputGenerator* getInputGenerator() const { return mWindowInputGenerator; }
/// Get the ID that uniquely identifies this window in the context of its
/// window manager.
virtual WindowId getWindowId() { return 0; };
enum WindowSystem
{
WindowSystem_Unknown = 0,
WindowSystem_Windows,
WindowSystem_X11,
};
virtual void* getSystemWindow(const WindowSystem system) { return NULL; }
/// Set the flag that determines whether to suppress a GFXDevice reset
inline void setSuppressReset(bool suppress) { mSuppressReset = suppress; };

View file

@ -121,6 +121,8 @@ void CloseSplashWindow(HINSTANCE hinst)
}
#ifndef TORQUE_SDL
bool Platform::closeSplashWindow()
{
CloseSplashWindow(GetModuleHandle(NULL));
@ -155,4 +157,4 @@ bool Platform::displaySplashWindow( String path )
return true;
}
#endif

View file

@ -20,6 +20,8 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#if !defined(TORQUE_SDL)
#include <windows.h>
#include <tchar.h>
#include <winuser.h>
@ -121,6 +123,14 @@ Win32Window::~Win32Window()
_unregisterWindowClass();
}
void* Win32Window::getSystemWindow(const WindowSystem system)
{
if( system == WindowSystem_Windows)
return getHWND();
return NULL;
}
GFXDevice * Win32Window::getGFXDevice()
{
return mDevice;
@ -1209,3 +1219,5 @@ const UTF16 *Win32Window::getCurtainWindowClassName()
{
return _CurtainWindowClassName;
}
#endif

View file

@ -139,6 +139,8 @@ public:
return mWindowHandle;
}
virtual void* getSystemWindow(const WindowSystem system);
HMENU &getMenuHandle()
{
return mMenuHandle;

View file

@ -27,6 +27,8 @@
#include "core/util/journal/process.h"
#include "core/strings/unicode.h"
#if !defined( TORQUE_SDL )
// ------------------------------------------------------------------------
void CloseSplashWindow(HINSTANCE hinst);
@ -522,4 +524,6 @@ void Win32WindowManager::raiseCurtain()
DestroyWindow(mCurtainWindow);
mCurtainWindow = NULL;
}
}
#endif

View file

@ -39,6 +39,8 @@
#include "core/util/journal/process.h"
#include "core/util/journal/journaledSignal.h"
#if !defined( TORQUE_SDL )
static U32 _ModifierKeys=0;
static BYTE keyboardState[256];
static bool initKBState = false;
@ -591,3 +593,6 @@ void DispatchRemove(HWND hWnd)
{
_MessageQueue.remove(hWnd);
}
#endif

View file

@ -85,6 +85,19 @@ void WindowInputGenerator::generateInputEvent( InputEventInfo &inputEvent )
if( !mInputController || !mFocused )
return;
if (inputEvent.action == SI_MAKE && inputEvent.deviceType == KeyboardDeviceType)
{
for( int i = 0; i < mAcceleratorMap.size(); ++i )
{
const AccKeyMap &acc = mAcceleratorMap[i];
if( acc.modifier & inputEvent.modifier && acc.keyCode == inputEvent.objInst )
{
Con::evaluatef(acc.cmd);
return;
}
}
}
// Give the ActionMap first shot.
if (ActionMap::handleEventGlobal(&inputEvent))
return;

View file

@ -61,6 +61,16 @@ class WindowInputGenerator
void handleInputEvent (U32 deviceInst, F32 fValue, F32 fValue2, F32 fValue3, F32 fValue4, S32 iValue, U16 deviceType, U16 objType, U16 ascii, U16 objInst, U8 action, U8 modifier);
void generateInputEvent( InputEventInfo &inputEvent );
/// Accelerator key map
struct AccKeyMap
{
void *hnd;
String cmd;
U32 keyCode;
U32 modifier;
};
Vector <AccKeyMap> mAcceleratorMap;
public:
@ -72,6 +82,42 @@ class WindowInputGenerator
/// Returns true if the given keypress event should be send as a raw keyboard
/// event even if it maps to a character input event.
bool wantAsKeyboardEvent( U32 modifiers, U32 key );
void addAcceleratorKey( void *hnd, const String &cmd, U32 keycode, U32 modifier)
{
AccKeyMap acc;
acc.hnd = hnd;
acc.cmd = cmd;
acc.keyCode = keycode;
acc.modifier = modifier;
mAcceleratorMap.push_back(acc);
}
void removeAcceleratorKeys( void *hnd )
{
for( int i = 0; i < mAcceleratorMap.size(); )
{
if( mAcceleratorMap[i].hnd == hnd )
{
mAcceleratorMap.erase( i, 1 );
continue;
}
++i;
}
}
void removeAcceleratorKey( void *hnd, U32 keycode, U32 modifier )
{
for( int i = 0; i < mAcceleratorMap.size(); ++i )
{
if( mAcceleratorMap[i].hnd == hnd && mAcceleratorMap[i].keyCode == keycode && mAcceleratorMap[i].modifier == modifier )
{
mAcceleratorMap.erase( i, 1 );
return;
}
}
}
};
#endif // _WINDOW_INPUTGENERATOR_H_