2023-04-01 15:20:53 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
|
|
|
Copyright (C) 2018-23 divingkatae and maximum
|
|
|
|
(theweirdo) spatium
|
|
|
|
|
|
|
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <core/hostevents.h>
|
|
|
|
#include <cpu/ppc/ppcemu.h>
|
|
|
|
#include <loguru.hpp>
|
|
|
|
#include <SDL.h>
|
|
|
|
|
|
|
|
EventManager* EventManager::event_manager;
|
|
|
|
|
|
|
|
void EventManager::poll_events()
|
|
|
|
{
|
|
|
|
SDL_Event event;
|
|
|
|
|
|
|
|
while (SDL_PollEvent(&event)) {
|
|
|
|
events_captured++;
|
|
|
|
|
|
|
|
switch (event.type) {
|
|
|
|
case SDL_QUIT:
|
|
|
|
power_on = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_WINDOWEVENT: {
|
|
|
|
WindowEvent we;
|
|
|
|
we.sub_type = event.window.event;
|
|
|
|
we.window_id = event.window.windowID;
|
2023-07-27 00:40:32 +00:00
|
|
|
this->_window_signal.emit(we);
|
2023-04-01 15:20:53 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_KEYDOWN:
|
|
|
|
key_downs++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_KEYUP:
|
|
|
|
key_ups++;
|
|
|
|
break;
|
|
|
|
|
2023-07-27 00:40:32 +00:00
|
|
|
case SDL_MOUSEMOTION: {
|
|
|
|
MouseEvent me;
|
|
|
|
me.xrel = event.motion.xrel;
|
|
|
|
me.yrel = event.motion.yrel;
|
|
|
|
me.flags = MOUSE_EVENT_MOTION;
|
|
|
|
this->_mouse_signal.emit(me);
|
|
|
|
}
|
2023-04-01 15:20:53 +00:00
|
|
|
break;
|
|
|
|
|
2023-08-01 21:57:16 +00:00
|
|
|
case SDL_MOUSEBUTTONDOWN: {
|
|
|
|
MouseEvent me;
|
|
|
|
me.buttons_state = 1;
|
|
|
|
me.flags = MOUSE_EVENT_BUTTON;
|
|
|
|
this->_mouse_signal.emit(me);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_MOUSEBUTTONUP: {
|
|
|
|
MouseEvent me;
|
|
|
|
me.buttons_state = 0;
|
|
|
|
me.flags = MOUSE_EVENT_BUTTON;
|
|
|
|
this->_mouse_signal.emit(me);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2023-04-01 15:20:53 +00:00
|
|
|
default:
|
|
|
|
unhandled_events++;
|
|
|
|
}
|
|
|
|
}
|
2023-08-01 15:21:17 +00:00
|
|
|
|
|
|
|
// perform post-processing
|
|
|
|
this->_post_signal.emit();
|
2023-04-01 15:20:53 +00:00
|
|
|
}
|