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