sdl event stuff
This commit is contained in:
@@ -19,9 +19,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
ResizeWindowEvent() : width(0), height(0) {}
|
||||
ResizeWindowEvent() : Event(nullptr), width(0), height(0) {}
|
||||
|
||||
ResizeWindowEvent(int w, int h) : width(w), height(h) {}
|
||||
ResizeWindowEvent(int w, int h, void* userData = nullptr) : Event(userData), width(w), height(h) {}
|
||||
|
||||
~ResizeWindowEvent() {
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
CloseWindowEvent() : window(nullptr) {}
|
||||
CloseWindowEvent() : Event(nullptr), window(nullptr) {}
|
||||
|
||||
CloseWindowEvent(const Window* w) : window(w) {}
|
||||
CloseWindowEvent(const Window* w, void* userData = nullptr) : Event(userData), window(w) {}
|
||||
|
||||
~CloseWindowEvent() {
|
||||
|
||||
@@ -54,9 +54,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
KeyPressedWindowEvent() : key(0), repeat(0) {}
|
||||
KeyPressedWindowEvent() : Event(nullptr), key(0), repeat(0) {}
|
||||
|
||||
KeyPressedWindowEvent(unsigned int k, unsigned int r) : key(k), repeat(r) {}
|
||||
KeyPressedWindowEvent(unsigned int k, unsigned int r, void* userData = nullptr) : Event(userData), key(k), repeat(r) {}
|
||||
|
||||
~KeyPressedWindowEvent() {
|
||||
|
||||
@@ -72,9 +72,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
KeyReleasedWindowEvent() : key(0) {}
|
||||
KeyReleasedWindowEvent() : Event(nullptr), key(0) {}
|
||||
|
||||
KeyReleasedWindowEvent(unsigned int k) : key(k) {}
|
||||
KeyReleasedWindowEvent(unsigned int k, void* userData = nullptr) : Event(userData), key(k) {}
|
||||
|
||||
~KeyReleasedWindowEvent() {
|
||||
|
||||
@@ -89,9 +89,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
MouseButtonPressedWindowEvent() : button(0) {}
|
||||
MouseButtonPressedWindowEvent() : Event(nullptr), button(0) {}
|
||||
|
||||
MouseButtonPressedWindowEvent(unsigned int b) : button(b) {}
|
||||
MouseButtonPressedWindowEvent(unsigned int b, void* userData = nullptr) : Event(userData), button(b) {}
|
||||
|
||||
~MouseButtonPressedWindowEvent() {
|
||||
|
||||
@@ -106,9 +106,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
MouseButtonReleasedWindowEvent() : button(0) {}
|
||||
MouseButtonReleasedWindowEvent() : Event(nullptr), button(0) {}
|
||||
|
||||
MouseButtonReleasedWindowEvent(unsigned int b) : button(b) {}
|
||||
MouseButtonReleasedWindowEvent(unsigned int b, void* userData = nullptr) : Event(userData), button(b) {}
|
||||
|
||||
~MouseButtonReleasedWindowEvent() {
|
||||
|
||||
@@ -123,9 +123,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
ScrollWindowEvent() : dx(0), dy(0) {}
|
||||
ScrollWindowEvent() : Event(nullptr), dx(0), dy(0) {}
|
||||
|
||||
ScrollWindowEvent(double x, double y) : dx(x), dy(y) {}
|
||||
ScrollWindowEvent(double x, double y, void* userData = nullptr) : Event(userData), dx(x), dy(y) {}
|
||||
|
||||
~ScrollWindowEvent() {
|
||||
|
||||
@@ -140,9 +140,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
MouseMovedWindowEvent() : x(0), y(0) {}
|
||||
MouseMovedWindowEvent() : Event(nullptr), x(0), y(0) {}
|
||||
|
||||
MouseMovedWindowEvent(double x, double y) : x(x), y(y) {}
|
||||
MouseMovedWindowEvent(double x, double y, void* userData = nullptr) : Event(userData), x(x), y(y) {}
|
||||
|
||||
~MouseMovedWindowEvent() {
|
||||
|
||||
@@ -157,9 +157,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
FocusedWindowEvent() : window(nullptr) {}
|
||||
FocusedWindowEvent() : Event(nullptr), window(nullptr) {}
|
||||
|
||||
FocusedWindowEvent(const Window* w) : window(w) {}
|
||||
FocusedWindowEvent(const Window* w, void* userData = nullptr) : Event(userData), window(w) {}
|
||||
|
||||
~FocusedWindowEvent() {
|
||||
|
||||
@@ -174,9 +174,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
FocusLostWindowEvent() : window(nullptr) {}
|
||||
FocusLostWindowEvent() : Event(nullptr), window(nullptr) {}
|
||||
|
||||
FocusLostWindowEvent(const Window* w) : window(w) {}
|
||||
FocusLostWindowEvent(const Window* w, void* userData = nullptr) : Event(userData), window(w) {}
|
||||
|
||||
~FocusLostWindowEvent() {
|
||||
|
||||
@@ -191,9 +191,9 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
MovedWindowEvent() : x(0), y(0) {}
|
||||
MovedWindowEvent() : Event(nullptr), x(0), y(0) {}
|
||||
|
||||
MovedWindowEvent(int x, int y) : x(x), y(y) {}
|
||||
MovedWindowEvent(int x, int y, void* userData = nullptr) : Event(userData), x(x), y(y) {}
|
||||
|
||||
~MovedWindowEvent() {
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "pch.hpp"
|
||||
#if WINDOW == 1
|
||||
|
||||
#ifdef WINDOW_GLFW
|
||||
#undef WINDOW_GLFW
|
||||
#ifndef WINDOW_GLFW
|
||||
#define WINDOW_GLFW
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
#include "utils/Window/WindowEvents.h"
|
||||
|
||||
@@ -127,3 +129,5 @@ namespace Archimedes {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "pch.hpp"
|
||||
#if WINDOW == 2
|
||||
|
||||
#ifdef WINDOW_SDL3
|
||||
#undef WINDOW_SDL3
|
||||
#ifndef WINDOW_SDL3
|
||||
#define WINDOW_SDL3
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
#include "utils/Window/WindowEvents.h"
|
||||
|
||||
@@ -69,52 +71,52 @@ namespace Archimedes {
|
||||
|
||||
void doFrame() { restoreContext(); SDL_GL_SwapWindow(w); }
|
||||
|
||||
void pollEvents() {
|
||||
SDL_PollEvent(&e);
|
||||
void pollEvents() {
|
||||
while(SDL_PollEvent(&e)) {
|
||||
switch(e.type) {
|
||||
|
||||
switch(e.type) {
|
||||
|
||||
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
||||
case SDL_EVENT_QUIT:
|
||||
data.sendEvent(new CloseWindowEvent(data.window));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
width = e.window.data1;
|
||||
height = e.window.data2;
|
||||
data.sendEvent(new ResizeWindowEvent(e.window.data1, e.window.data2));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||
data.sendEvent(new FocusedWindowEvent(data.window));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
||||
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||
data.sendEvent(new FocusLostWindowEvent(data.window));
|
||||
break;
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
data.sendEvent(new KeyPressedWindowEvent(e.key.key, e.key.repeat ? 1 : 0));
|
||||
break;
|
||||
case SDL_EVENT_KEY_UP:
|
||||
data.sendEvent(new KeyReleasedWindowEvent(e.key.key));
|
||||
break;
|
||||
case SDL_EVENT_TEXT_EDITING:
|
||||
break;
|
||||
case SDL_EVENT_TEXT_INPUT:
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
data.sendEvent(new MouseMovedWindowEvent(e.motion.x, e.motion.y));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
data.sendEvent(new MouseButtonPressedWindowEvent(e.button.button));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
data.sendEvent(new MouseButtonReleasedWindowEvent(e.button.button));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
data.sendEvent(new ScrollWindowEvent(e.wheel.x, e.wheel.y));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
||||
case SDL_EVENT_QUIT:
|
||||
data.sendEvent(new CloseWindowEvent(data.window, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
width = e.window.data1;
|
||||
height = e.window.data2;
|
||||
data.sendEvent(new ResizeWindowEvent(e.window.data1, e.window.data2, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||
data.sendEvent(new FocusedWindowEvent(data.window, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
||||
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||
data.sendEvent(new FocusLostWindowEvent(data.window, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
data.sendEvent(new KeyPressedWindowEvent(e.key.key, e.key.repeat ? 1 : 0, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_KEY_UP:
|
||||
data.sendEvent(new KeyReleasedWindowEvent(e.key.key, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_TEXT_EDITING:
|
||||
break;
|
||||
case SDL_EVENT_TEXT_INPUT:
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
data.sendEvent(new MouseMovedWindowEvent(e.motion.x, e.motion.y, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
data.sendEvent(new MouseButtonPressedWindowEvent(e.button.button, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
data.sendEvent(new MouseButtonReleasedWindowEvent(e.button.button, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
data.sendEvent(new ScrollWindowEvent(e.wheel.x, e.wheel.y, (void*) &e));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,3 +145,5 @@ namespace Archimedes {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user