1
0
Fork 0
spectre/source/Platform/Win32/Win32Application.cpp
2016-01-10 09:26:43 +01:00

96 lines
1.6 KiB
C++

#include <windows.h>
#include "Win32Keyboard.h"
#include "Win32Mouse.h"
#include "Win32Application.h"
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);
}