mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 23:31:50 +00:00
Merge branch 'master' into next
This commit is contained in:
commit
1781ccf4ca
2 changed files with 79 additions and 77 deletions
|
@ -590,70 +590,78 @@ static BOOL I_ReadyConsole(HANDLE ci)
|
||||||
|
|
||||||
static boolean entering_con_command = false;
|
static boolean entering_con_command = false;
|
||||||
|
|
||||||
|
static void Impl_HandleKeyboardConsoleEvent(KEY_EVENT_RECORD evt, HANDLE co)
|
||||||
|
{
|
||||||
|
event_t event;
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO CSBI;
|
||||||
|
DWORD t;
|
||||||
|
|
||||||
|
memset(&event,0x00,sizeof (event));
|
||||||
|
|
||||||
|
if (evt.bKeyDown)
|
||||||
|
{
|
||||||
|
event.type = ev_console;
|
||||||
|
entering_con_command = true;
|
||||||
|
switch (evt.wVirtualKeyCode)
|
||||||
|
{
|
||||||
|
case VK_ESCAPE:
|
||||||
|
case VK_TAB:
|
||||||
|
event.data1 = KEY_NULL;
|
||||||
|
break;
|
||||||
|
case VK_SHIFT:
|
||||||
|
event.data1 = KEY_LSHIFT;
|
||||||
|
break;
|
||||||
|
case VK_RETURN:
|
||||||
|
entering_con_command = false;
|
||||||
|
// Fall through.
|
||||||
|
default:
|
||||||
|
event.data1 = MapVirtualKey(evt.wVirtualKeyCode,2); // convert in to char
|
||||||
|
}
|
||||||
|
if (co != INVALID_HANDLE_VALUE && GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &t))
|
||||||
|
{
|
||||||
|
if (event.data1 && event.data1 != KEY_LSHIFT && event.data1 != KEY_RSHIFT)
|
||||||
|
{
|
||||||
|
#ifdef _UNICODE
|
||||||
|
WriteConsole(co, &evt.uChar.UnicodeChar, 1, &t, NULL);
|
||||||
|
#else
|
||||||
|
WriteConsole(co, &evt.uChar.AsciiChar, 1 , &t, NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (evt.wVirtualKeyCode == VK_BACK
|
||||||
|
&& GetConsoleScreenBufferInfo(co,&CSBI))
|
||||||
|
{
|
||||||
|
WriteConsoleOutputCharacterA(co, " ",1, CSBI.dwCursorPosition, &t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
event.type = ev_keyup;
|
||||||
|
switch (evt.wVirtualKeyCode)
|
||||||
|
{
|
||||||
|
case VK_SHIFT:
|
||||||
|
event.data1 = KEY_LSHIFT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (event.data1) D_PostEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
void I_GetConsoleEvents(void)
|
void I_GetConsoleEvents(void)
|
||||||
{
|
{
|
||||||
event_t ev = {0,0,0,0};
|
|
||||||
HANDLE ci = GetStdHandle(STD_INPUT_HANDLE);
|
HANDLE ci = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
CONSOLE_SCREEN_BUFFER_INFO CSBI;
|
|
||||||
INPUT_RECORD input;
|
INPUT_RECORD input;
|
||||||
DWORD t;
|
DWORD t;
|
||||||
|
|
||||||
while (I_ReadyConsole(ci) && ReadConsoleInput(ci, &input, 1, &t) && t)
|
while (I_ReadyConsole(ci) && ReadConsoleInput(ci, &input, 1, &t) && t)
|
||||||
{
|
{
|
||||||
memset(&ev,0x00,sizeof (ev));
|
|
||||||
switch (input.EventType)
|
switch (input.EventType)
|
||||||
{
|
{
|
||||||
case KEY_EVENT:
|
case KEY_EVENT:
|
||||||
if (input.Event.KeyEvent.bKeyDown)
|
Impl_HandleKeyboardConsoleEvent(input.Event.KeyEvent, co);
|
||||||
{
|
|
||||||
ev.type = ev_console;
|
|
||||||
entering_con_command = true;
|
|
||||||
switch (input.Event.KeyEvent.wVirtualKeyCode)
|
|
||||||
{
|
|
||||||
case VK_ESCAPE:
|
|
||||||
case VK_TAB:
|
|
||||||
ev.data1 = KEY_NULL;
|
|
||||||
break;
|
|
||||||
case VK_SHIFT:
|
|
||||||
ev.data1 = KEY_LSHIFT;
|
|
||||||
break;
|
|
||||||
case VK_RETURN:
|
|
||||||
entering_con_command = false;
|
|
||||||
// Fall through.
|
|
||||||
default:
|
|
||||||
ev.data1 = MapVirtualKey(input.Event.KeyEvent.wVirtualKeyCode,2); // convert in to char
|
|
||||||
}
|
|
||||||
if (co != INVALID_HANDLE_VALUE && GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &t))
|
|
||||||
{
|
|
||||||
if (ev.data1 && ev.data1 != KEY_LSHIFT && ev.data1 != KEY_RSHIFT)
|
|
||||||
{
|
|
||||||
#ifdef _UNICODE
|
|
||||||
WriteConsole(co, &input.Event.KeyEvent.uChar.UnicodeChar, 1, &t, NULL);
|
|
||||||
#else
|
|
||||||
WriteConsole(co, &input.Event.KeyEvent.uChar.AsciiChar, 1 , &t, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (input.Event.KeyEvent.wVirtualKeyCode == VK_BACK
|
|
||||||
&& GetConsoleScreenBufferInfo(co,&CSBI))
|
|
||||||
{
|
|
||||||
WriteConsoleOutputCharacterA(co, " ",1, CSBI.dwCursorPosition, &t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ev.type = ev_keyup;
|
|
||||||
switch (input.Event.KeyEvent.wVirtualKeyCode)
|
|
||||||
{
|
|
||||||
case VK_SHIFT:
|
|
||||||
ev.data1 = KEY_LSHIFT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ev.data1) D_PostEvent(&ev);
|
|
||||||
break;
|
break;
|
||||||
case MOUSE_EVENT:
|
case MOUSE_EVENT:
|
||||||
case WINDOW_BUFFER_SIZE_EVENT:
|
case WINDOW_BUFFER_SIZE_EVENT:
|
||||||
|
|
|
@ -181,15 +181,13 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||||
wasfullscreen = SDL_TRUE;
|
wasfullscreen = SDL_TRUE;
|
||||||
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
}
|
}
|
||||||
else if (wasfullscreen)
|
else // windowed mode
|
||||||
{
|
|
||||||
wasfullscreen = SDL_FALSE;
|
|
||||||
SDL_SetWindowFullscreen(window, 0);
|
|
||||||
SDL_SetWindowSize(window, width, height);
|
|
||||||
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
if (wasfullscreen)
|
||||||
|
{
|
||||||
|
wasfullscreen = SDL_FALSE;
|
||||||
|
SDL_SetWindowFullscreen(window, 0);
|
||||||
|
}
|
||||||
// Reposition window only in windowed mode
|
// Reposition window only in windowed mode
|
||||||
SDL_SetWindowSize(window, width, height);
|
SDL_SetWindowSize(window, width, height);
|
||||||
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1));
|
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1));
|
||||||
|
@ -899,7 +897,7 @@ static inline boolean I_SkipFrame(void)
|
||||||
{
|
{
|
||||||
static boolean skip = false;
|
static boolean skip = false;
|
||||||
|
|
||||||
if (render_soft != rendermode)
|
if (rendermode != render_soft)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
skip = !skip;
|
skip = !skip;
|
||||||
|
@ -931,7 +929,7 @@ void I_FinishUpdate(void)
|
||||||
if (cv_ticrate.value)
|
if (cv_ticrate.value)
|
||||||
SCR_DisplayTicRate();
|
SCR_DisplayTicRate();
|
||||||
|
|
||||||
if (render_soft == rendermode && screens[0])
|
if (rendermode == render_soft && screens[0])
|
||||||
{
|
{
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
|
|
||||||
|
@ -958,7 +956,7 @@ void I_FinishUpdate(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
else
|
else if (rendermode == render_opengl)
|
||||||
{
|
{
|
||||||
OglSdlFinishUpdate(cv_vidwait.value);
|
OglSdlFinishUpdate(cv_vidwait.value);
|
||||||
}
|
}
|
||||||
|
@ -1188,9 +1186,9 @@ INT32 VID_SetMode(INT32 modeNum)
|
||||||
}
|
}
|
||||||
Impl_SetWindowName("SRB2 "VERSIONSTRING);
|
Impl_SetWindowName("SRB2 "VERSIONSTRING);
|
||||||
|
|
||||||
SDLSetMode(windowedModes[modeNum][0], windowedModes[modeNum][1], USE_FULLSCREEN);
|
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
|
||||||
|
|
||||||
if (render_soft == rendermode)
|
if (rendermode == render_soft)
|
||||||
{
|
{
|
||||||
if (bufSurface)
|
if (bufSurface)
|
||||||
{
|
{
|
||||||
|
@ -1209,30 +1207,20 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
if (rendermode == render_none) // dedicated
|
if (rendermode == render_none) // dedicated
|
||||||
{
|
|
||||||
return SDL_TRUE; // Monster Iestyn -- not sure if it really matters what we return here tbh
|
return SDL_TRUE; // Monster Iestyn -- not sure if it really matters what we return here tbh
|
||||||
}
|
|
||||||
|
|
||||||
if (window != NULL)
|
if (window != NULL)
|
||||||
{
|
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
|
||||||
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||||
}
|
|
||||||
|
|
||||||
if (borderlesswindow)
|
if (borderlesswindow)
|
||||||
{
|
|
||||||
flags |= SDL_WINDOW_BORDERLESS;
|
flags |= SDL_WINDOW_BORDERLESS;
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
{
|
|
||||||
flags |= SDL_WINDOW_OPENGL;
|
flags |= SDL_WINDOW_OPENGL;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create a window
|
// Create a window
|
||||||
|
@ -1261,7 +1249,13 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
||||||
#endif
|
#endif
|
||||||
if (rendermode == render_soft)
|
if (rendermode == render_soft)
|
||||||
{
|
{
|
||||||
renderer = SDL_CreateRenderer(window, -1, (usesdl2soft ? SDL_RENDERER_SOFTWARE : 0) | (cv_vidwait.value && !usesdl2soft ? SDL_RENDERER_PRESENTVSYNC : 0));
|
flags = 0; // Use this to set SDL_RENDERER_* flags now
|
||||||
|
if (usesdl2soft)
|
||||||
|
flags |= SDL_RENDERER_SOFTWARE;
|
||||||
|
else if (cv_vidwait.value)
|
||||||
|
flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||||
|
|
||||||
|
renderer = SDL_CreateRenderer(window, -1, flags);
|
||||||
if (renderer == NULL)
|
if (renderer == NULL)
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError());
|
CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError());
|
||||||
|
@ -1483,7 +1477,7 @@ void I_ShutdownGraphics(void)
|
||||||
rendermode = render_none;
|
rendermode = render_none;
|
||||||
if (icoSurface) SDL_FreeSurface(icoSurface);
|
if (icoSurface) SDL_FreeSurface(icoSurface);
|
||||||
icoSurface = NULL;
|
icoSurface = NULL;
|
||||||
if (render_soft == oldrendermode)
|
if (oldrendermode == render_soft)
|
||||||
{
|
{
|
||||||
if (vidSurface) SDL_FreeSurface(vidSurface);
|
if (vidSurface) SDL_FreeSurface(vidSurface);
|
||||||
vidSurface = NULL;
|
vidSurface = NULL;
|
||||||
|
|
Loading…
Reference in a new issue