C+++++++++++++

This commit is contained in:
ZakatTeamI2P 2026-03-31 01:44:57 +04:00
parent 73e70ebdb4
commit f142b26df1
4 changed files with 56 additions and 68 deletions

View file

@ -108,7 +108,7 @@ RB_METHOD(fileIntGetByte)
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self); SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
unsigned char byte; unsigned char byte;
size_t result = SDL_RWread(ops, &byte, 1, 1); size_t result = SDL_ReadIO(ops, &byte, 1);
return (result == 1) ? rb_fix_new(byte) : Qnil; return (result == 1) ? rb_fix_new(byte) : Qnil;
} }

View file

@ -23,6 +23,7 @@
#define ALUTIL_H #define ALUTIL_H
#include <AL/al.h> #include <AL/al.h>
#include <AL/alc.h>
#include <SDL3/SDL_audio.h> #include <SDL3/SDL_audio.h>
#include <assert.h> #include <assert.h>

View file

@ -30,11 +30,6 @@
#include <SDL3/SDL_touch.h> #include <SDL3/SDL_touch.h>
#include <SDL3/SDL_rect.h> #include <SDL3/SDL_rect.h>
// #include <al.h>
#include <AL/al.h>
// #include <alc.h>
#include <AL/alc.h>
#include "sharedstate.h" #include "sharedstate.h"
#include "graphics.h" #include "graphics.h"
#include "settingsmenu.h" #include "settingsmenu.h"
@ -223,12 +218,9 @@ void EventThread::process(RGSSThreadData &rtData)
break; break;
} }
/* Now process the rest */ //Window events
switch (event.type)
{ switch (event.window.type){
case SDL_WINDOWEVENT :
switch (event.window.event)
{
//SDL_WINDOWEVENT_SIZE_CHANGED - handle the SDL_EVENT_WINDOW_RESIZED and SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED events instead //SDL_WINDOWEVENT_SIZE_CHANGED - handle the SDL_EVENT_WINDOW_RESIZED and SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED events instead
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED : case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED :
winW = event.window.data1; winW = event.window.data1;
@ -275,17 +267,18 @@ void EventThread::process(RGSSThreadData &rtData)
resetInputStates(); resetInputStates();
break; break;
} #ifdef __APPLE__
case SDL_EVENT_WINDOW_MOVED:
if (shState != NULL && event.window.data1 && event.window.data2)
shState->oneshot().setWindowPos(event.window.data1, event.window.data2);
break;
#endif
}
#ifdef __APPLE__
case SDL_EVENT_WINDOW_MOVED:
if (shState != NULL && event.window.data1 && event.window.data2)
shState->oneshot().setWindowPos(event.window.data1, event.window.data2);
break;
#endif
break;
/* Now process the rest */
switch (event.type)
{
case SDL_EVENT_QUIT : case SDL_EVENT_QUIT :
if (rtData.allowExit) { if (rtData.allowExit) {
terminate = true; terminate = true;
@ -301,7 +294,7 @@ void EventThread::process(RGSSThreadData &rtData)
break; break;
case SDL_EVENT_KEY_DOWN : case SDL_EVENT_KEY_DOWN :
if (event.key.keysym.scancode == SDL_SCANCODE_F1) if (event.key.scancode == SDL_SCANCODE_F1)
{ {
if (!sMenu) if (!sMenu)
{ {
@ -312,7 +305,7 @@ void EventThread::process(RGSSThreadData &rtData)
sMenu->raise(); sMenu->raise();
} }
if (event.key.keysym.scancode == SDL_SCANCODE_F2) if (event.key.scancode == SDL_SCANCODE_F2)
{ {
if (!displayingFPS) if (!displayingFPS)
{ {
@ -341,7 +334,7 @@ void EventThread::process(RGSSThreadData &rtData)
break; break;
} }
if (event.key.keysym.scancode == SDL_SCANCODE_F12) if (event.key.scancode == SDL_SCANCODE_F12)
{ {
if (!rtData.config.debugMode) if (!rtData.config.debugMode)
break; break;
@ -356,19 +349,19 @@ void EventThread::process(RGSSThreadData &rtData)
} }
if (rtData.acceptingTextInput) { if (rtData.acceptingTextInput) {
if (event.key.keysym.sym == SDLK_BACKSPACE && rtData.inputText.length() > 0) if (event.key.sym == SDLK_BACKSPACE && rtData.inputText.length() > 0)
rtData.inputText.pop_back(); rtData.inputText.pop_back();
else if (event.key.keysym.sym == SDLK_RETURN) else if (event.key.sym == SDLK_RETURN)
rtData.acceptingTextInput.clear(); rtData.acceptingTextInput.clear();
break; break;
} }
keyStates[event.key.keysym.scancode] = true; keyStates[event.key.scancode] = true;
break; break;
case SDL_EVENT_KEY_UP : case SDL_EVENT_KEY_UP :
if (event.key.keysym.scancode == SDL_SCANCODE_F12) if (event.key.scancode == SDL_SCANCODE_F12)
{ {
if (!rtData.config.debugMode) if (!rtData.config.debugMode)
break; break;
@ -378,7 +371,7 @@ void EventThread::process(RGSSThreadData &rtData)
break; break;
} }
keyStates[event.key.keysym.scancode] = false; keyStates[event.key.scancode] = false;
break; break;
case SDL_EVENT_GAMEPAD_BUTTON_DOWN: case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
@ -586,8 +579,8 @@ bool EventThread::eventFilter(void *data, SDL_Event *event)
return 0; return 0;
/* Workaround for Windows pausing on drag */ /* Workaround for Windows pausing on drag */
case SDL_WINDOWEVENT: default:
if (event->window.event == SDL_EVENT_WINDOW_MOVED) if (event->window.event->type == SDL_EVENT_WINDOW_MOVED)
{ {
if (shState != NULL && shState->rgssVersion > 0) if (shState != NULL && shState->rgssVersion > 0)
{ {

View file

@ -724,7 +724,7 @@ struct SettingsMenuPrivate
{ {
case SDL_EVENT_KEY_DOWN: case SDL_EVENT_KEY_DOWN:
desc.type = Key; desc.type = Key;
desc.d.scan = event.key.keysym.scancode; desc.d.scan = event.key.scancode;
/* Special case aliases */ /* Special case aliases */
if (desc.d.scan == SDL_SCANCODE_RSHIFT) if (desc.d.scan == SDL_SCANCODE_RSHIFT)
@ -1152,10 +1152,35 @@ SettingsMenu::~SettingsMenu()
bool SettingsMenu::onEvent(const SDL_Event &event, bool SettingsMenu::onEvent(const SDL_Event &event,
const std::map<int, SDL_Joystick*> &joysticks) const std::map<int, SDL_Joystick*> &joysticks)
{ {
/* First, check whether this event is for us */ switch (event.window.type)
{
case SDL_EVENT_WINDOW_SHOWN : // SDL is bugged and doesn't give us a first FOCUS_GAINED event
case SDL_EVENT_WINDOW_FOCUS_GAINED :
p->hasFocus = true;
break;
case SDL_EVENT_WINDOW_FOCUS_LOST :
p->hasFocus = false;
break;
case SDL_EVENT_WINDOW_EXPOSED :
SDL_UpdateWindowSurface(p->window);
break;
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
if (p->hovered)
{
p->hovered->leave();
p->hovered = 0;
}
break;
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
p->onCancel();
}
switch (event.type) switch (event.type)
{ {
case SDL_WINDOWEVENT :
case SDL_EVENT_MOUSE_BUTTON_DOWN : case SDL_EVENT_MOUSE_BUTTON_DOWN :
case SDL_EVENT_MOUSE_BUTTON_UP : case SDL_EVENT_MOUSE_BUTTON_UP :
case SDL_EVENT_MOUSE_MOTION : case SDL_EVENT_MOUSE_MOTION :
@ -1190,37 +1215,6 @@ bool SettingsMenu::onEvent(const SDL_Event &event,
case SDL_EVENT_MOUSE_BUTTON_UP : case SDL_EVENT_MOUSE_BUTTON_UP :
case SDL_EVENT_KEY_UP : case SDL_EVENT_KEY_UP :
return true; return true;
case SDL_WINDOWEVENT :
switch (event.window.event)
{
case SDL_EVENT_WINDOW_SHOWN : // SDL is bugged and doesn't give us a first FOCUS_GAINED event
case SDL_EVENT_WINDOW_FOCUS_GAINED :
p->hasFocus = true;
break;
case SDL_EVENT_WINDOW_FOCUS_LOST :
p->hasFocus = false;
break;
case SDL_EVENT_WINDOW_EXPOSED :
SDL_UpdateWindowSurface(p->window);
break;
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
if (p->hovered)
{
p->hovered->leave();
p->hovered = 0;
}
break;
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
p->onCancel();
}
return true;
case SDL_EVENT_MOUSE_MOTION: case SDL_EVENT_MOUSE_MOTION:
p->onMotion(event.motion); p->onMotion(event.motion);
return true; return true;
@ -1228,9 +1222,9 @@ bool SettingsMenu::onEvent(const SDL_Event &event,
case SDL_EVENT_KEY_DOWN: case SDL_EVENT_KEY_DOWN:
if (p->state != AwaitingInput) if (p->state != AwaitingInput)
{ {
if (event.key.keysym.sym == SDLK_RETURN) if (event.key.sym == SDLK_RETURN)
p->onAccept(); p->onAccept();
else if (event.key.keysym.sym == SDLK_ESCAPE) else if (event.key.sym == SDLK_ESCAPE)
p->onCancel(); p->onCancel();
return true; return true;
@ -1238,7 +1232,7 @@ bool SettingsMenu::onEvent(const SDL_Event &event,
/* Don't let the user bind keys that trigger /* Don't let the user bind keys that trigger
* mkxp functions */ * mkxp functions */
switch(event.key.keysym.scancode) switch(event.key.scancode)
{ {
case SDL_SCANCODE_F1: case SDL_SCANCODE_F1:
case SDL_SCANCODE_F2: case SDL_SCANCODE_F2: