When writing the X11 (linux) implementation there was a problem with X11 defining a "Display" type and we also have a Display class in the engine. So to fix that problem and minimize the risk for running into other name conflicts. We move everything from global namespace.
100 lines
No EOL
1.6 KiB
C++
100 lines
No EOL
1.6 KiB
C++
|
|
#include <windows.h>
|
|
#include "Win32Keyboard.h"
|
|
#include "Win32Mouse.h"
|
|
#include "Win32Application.h"
|
|
|
|
namespace sp {
|
|
|
|
void Win32Application::init()
|
|
{
|
|
}
|
|
|
|
void Win32Application::shutdown()
|
|
{
|
|
}
|
|
|
|
/*
|
|
PlatformDisplay& Win32Application::getDisplay()
|
|
{
|
|
return m_display;
|
|
} */
|
|
|
|
PlatformInput& Win32Application::getInput()
|
|
{
|
|
return m_input;
|
|
}
|
|
|
|
MessageQueue& Win32Application::getMessageQueue()
|
|
{
|
|
return m_messageQueue;
|
|
}
|
|
|
|
void Win32Application::update()
|
|
{
|
|
MSG msg;
|
|
|
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
|
|
TranslateMessage(&msg);
|
|
processMessage(msg);
|
|
}
|
|
}
|
|
|
|
LRESULT Win32Application::processMessage(MSG msg)
|
|
{
|
|
switch(msg.message) {
|
|
case WM_QUIT :
|
|
m_messageQueue.postEvent(SysEvent(SysEvent::Quit));
|
|
return 0;
|
|
// Input, Forward to devices.
|
|
case WM_KEYDOWN :
|
|
case WM_KEYUP :
|
|
OutputDebugString("WM_KEYDOWN\n");
|
|
//SetCapture(msg.hwnd);
|
|
|
|
if (Win32Keyboard::handleMessage(msg)) {
|
|
// Keyboard did handle the message.
|
|
return 0;
|
|
}
|
|
break;
|
|
case WM_MOUSEMOVE :
|
|
case WM_MOUSELEAVE :
|
|
|
|
if (Win32Mouse::handleMessage(msg)) {
|
|
// Mouse did handle the message.
|
|
return 0;
|
|
}
|
|
break;
|
|
case WM_LBUTTONDOWN :
|
|
case WM_RBUTTONDOWN :
|
|
case WM_MBUTTONDOWN :
|
|
case WM_XBUTTONDOWN :
|
|
|
|
SetCapture(msg.hwnd);
|
|
|
|
if (Win32Mouse::handleMessage(msg)) {
|
|
// Mouse did handle the message.
|
|
return 0;
|
|
}
|
|
break;
|
|
case WM_LBUTTONUP :
|
|
case WM_RBUTTONUP :
|
|
case WM_MBUTTONUP :
|
|
case WM_XBUTTONUP :
|
|
|
|
ReleaseCapture();
|
|
|
|
if (Win32Mouse::handleMessage(msg)) {
|
|
// Mouse did handle the message.
|
|
return 0;
|
|
}
|
|
break;
|
|
default :
|
|
break;
|
|
}
|
|
|
|
// Message was not intercepted. Pass down to window.
|
|
return DispatchMessage(&msg);
|
|
}
|
|
|
|
} // namespace sp
|