Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
MouseManager.cpp
Go to the documentation of this file.
1#include "MouseManager.h"
2#include "EventQueue.h"
3#include <iostream>
4#include "system_utils.h"
5
11
13{
14 name = "MouseManager";
15 SYSTEM_LOG << "MouseManager Initialized\n";
16}
17
19{
20 SYSTEM_LOG << "MouseManager Shutdown\n";
21}
22
24{
25 // Reset per-frame mouse state if needed in future
26 // For now, no per-frame state to reset
27}
28
30{
31 // if (!ev) return; // useless because it is tested before function call
32 switch (ev->type)
33 {
36 PostButtonEvent(ev->button);
37 break;
39 PostMotionEvent(ev->motion);
40 break;
41 default:
42 break;
43 }
44}
45
47{
51 static_cast<int>(be.which),
52 static_cast<int>(be.button)
53 );
54 msg.state = be.down ? 1 : 0;
55 msg.param1 = be.x;
56 msg.param2 = be.y;
57
59}
60
62{
66 static_cast<int>(me.which),
67 0
68 );
69 msg.state = 0;
70 msg.param1 = me.x;
71 msg.param2 = me.y;
72
74}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
void Push(const Message &msg)
Definition EventQueue.h:37
static EventQueue & Get()
Definition EventQueue.h:34
void HandleEvent(const SDL_Event *ev)
void PostMotionEvent(const SDL_MouseMotionEvent &me)
std::string name
static MouseManager & GetInstance()
void PostButtonEvent(const SDL_MouseButtonEvent &be)
static Message Create(EventType _ev_t, EventDomain _domain, int _d_id=-1, int _c_id=-1, uint64_t _t_uid=0)
Definition message.h:28
int state
Definition message.h:24
@ Olympe_EventType_Mouse_ButtonDown
@ Olympe_EventType_Mouse_ButtonUp
@ Olympe_EventType_Mouse_Motion
#define SYSTEM_LOG