mouse events

This commit is contained in:
Attila Uygun 2023-08-10 12:50:38 +02:00
parent 2985fed3d4
commit b292f423ba
2 changed files with 27 additions and 6 deletions

View File

@ -26,7 +26,9 @@ AudioMixer::AudioMixer()
#elif defined(__linux__)
audio_sink_{std::make_unique<AudioSinkAlsa>(this)} {
#elif defined(_WIN32)
audio_sink_{std::make_unique<AudioSinkNull>()} {
// TODO: Implement AudioSinkWindows
audio_sink_{std::make_unique<AudioSinkNull>()},
audio_enabled_(false) {
#endif
bool res = audio_sink_->Initialize();
CHECK(res) << "Failed to initialize audio sink.";

View File

@ -6,8 +6,8 @@
// #include <memory>
//
#include "base/log.h"
// #include "base/vecmath.h"
// #include "engine/input_event.h"
#include "base/vecmath.h"
#include "engine/input_event.h"
#include "engine/platform/platform_observer.h"
using namespace base;
@ -69,12 +69,9 @@ void Platform::CreateMainWindow() {
Platform::~Platform() {
LOG(0) << "Shutting down platform.";
DestroyWindow(wnd_);
}
void Platform::Update() {
DCHECK(!should_exit_);
MSG msg;
while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT) {
@ -125,6 +122,28 @@ LRESULT CALLBACK Platform::WndProc(HWND wnd,
platform->observer_->OnWindowDestroyed();
PostQuitMessage(0);
break;
case WM_MOUSEMOVE: {
Vector2f v(MAKEPOINTS(lparam).x, MAKEPOINTS(lparam).y);
auto input_event =
std::make_unique<InputEvent>(InputEvent::kDrag, 0, v);
platform->observer_->AddInputEvent(std::move(input_event));
} break;
case WM_LBUTTONDOWN: {
Vector2f v(MAKEPOINTS(lparam).x, MAKEPOINTS(lparam).y);
auto input_event =
std::make_unique<InputEvent>(InputEvent::kDragStart, 0, v);
platform->observer_->AddInputEvent(std::move(input_event));
} break;
case WM_LBUTTONUP: {
Vector2f v(MAKEPOINTS(lparam).x, MAKEPOINTS(lparam).y);
auto input_event =
std::make_unique<InputEvent>(InputEvent::kDragEnd, 0, v);
platform->observer_->AddInputEvent(std::move(input_event));
} break;
default:
return DefWindowProc(wnd, message, wparam, lparam);
}