mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Merge branch 'fix-downloadsnakeconcent' into 'next'
Fix Download Consent/Snake minigame not having controller support Closes #836 and #835 See merge request STJr/SRB2!1883
This commit is contained in:
commit
5a38bbbbf5
1 changed files with 69 additions and 7 deletions
|
@ -48,6 +48,9 @@
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
#include "m_perfstats.h"
|
#include "m_perfstats.h"
|
||||||
|
|
||||||
|
// aaaaaa
|
||||||
|
#include "i_joy.h"
|
||||||
|
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
// cl loading screen
|
// cl loading screen
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
|
@ -650,6 +653,22 @@ static UINT8 Snake_GetOppositeDir(UINT8 dir)
|
||||||
return 12 + 5 - dir;
|
return 12 + 5 - dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event_t *snakejoyevents[MAXEVENTS];
|
||||||
|
UINT16 joyeventcount = 0;
|
||||||
|
|
||||||
|
// I'm screaming the hack is clean - ashi
|
||||||
|
static boolean Snake_Joy_Grabber(event_t *ev)
|
||||||
|
{
|
||||||
|
if (ev->type == ev_joystick && ev->key == 0)
|
||||||
|
{
|
||||||
|
snakejoyevents[joyeventcount] = ev;
|
||||||
|
joyeventcount++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void Snake_FindFreeSlot(UINT8 *freex, UINT8 *freey, UINT8 headx, UINT8 heady)
|
static void Snake_FindFreeSlot(UINT8 *freex, UINT8 *freey, UINT8 headx, UINT8 heady)
|
||||||
{
|
{
|
||||||
UINT8 x, y;
|
UINT8 x, y;
|
||||||
|
@ -676,6 +695,9 @@ static void Snake_Handle(void)
|
||||||
UINT8 x, y;
|
UINT8 x, y;
|
||||||
UINT8 oldx, oldy;
|
UINT8 oldx, oldy;
|
||||||
UINT16 i;
|
UINT16 i;
|
||||||
|
UINT16 j;
|
||||||
|
UINT16 joystate = 0;
|
||||||
|
static INT32 pjoyx = 0, pjoyy = 0;
|
||||||
|
|
||||||
// Handle retry
|
// Handle retry
|
||||||
if (snake->gameover && (PLAYER1INPUTDOWN(GC_JUMP) || gamekeydown[KEY_ENTER]))
|
if (snake->gameover && (PLAYER1INPUTDOWN(GC_JUMP) || gamekeydown[KEY_ENTER]))
|
||||||
|
@ -704,23 +726,58 @@ static void Snake_Handle(void)
|
||||||
oldx = snake->snakex[1];
|
oldx = snake->snakex[1];
|
||||||
oldy = snake->snakey[1];
|
oldy = snake->snakey[1];
|
||||||
|
|
||||||
|
// process the input events in here dear lord
|
||||||
|
for (j = 0; j < joyeventcount; j++)
|
||||||
|
{
|
||||||
|
event_t *ev = snakejoyevents[j];
|
||||||
|
const INT32 jdeadzone = (JOYAXISRANGE * cv_digitaldeadzone.value) / FRACUNIT;
|
||||||
|
if (ev->y != INT32_MAX)
|
||||||
|
{
|
||||||
|
if (Joystick.bGamepadStyle || abs(ev->y) > jdeadzone)
|
||||||
|
{
|
||||||
|
if (ev->y < 0 && pjoyy >= 0)
|
||||||
|
joystate = 1;
|
||||||
|
else if (ev->y > 0 && pjoyy <= 0)
|
||||||
|
joystate = 2;
|
||||||
|
pjoyy = ev->y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pjoyy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev->x != INT32_MAX)
|
||||||
|
{
|
||||||
|
if (Joystick.bGamepadStyle || abs(ev->x) > jdeadzone)
|
||||||
|
{
|
||||||
|
if (ev->x < 0 && pjoyx >= 0)
|
||||||
|
joystate = 3;
|
||||||
|
else if (ev->x > 0 && pjoyx <= 0)
|
||||||
|
joystate = 4;
|
||||||
|
pjoyx = ev->x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pjoyx = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
joyeventcount = 0;
|
||||||
|
|
||||||
// Update direction
|
// Update direction
|
||||||
if (gamekeydown[KEY_LEFTARROW])
|
if (PLAYER1INPUTDOWN(GC_STRAFELEFT) || gamekeydown[KEY_LEFTARROW] || joystate == 3)
|
||||||
{
|
{
|
||||||
if (snake->snakelength < 2 || x <= oldx)
|
if (snake->snakelength < 2 || x <= oldx)
|
||||||
snake->snakedir[0] = 1;
|
snake->snakedir[0] = 1;
|
||||||
}
|
}
|
||||||
else if (gamekeydown[KEY_RIGHTARROW])
|
else if (PLAYER1INPUTDOWN(GC_STRAFERIGHT) || gamekeydown[KEY_RIGHTARROW] || joystate == 4)
|
||||||
{
|
{
|
||||||
if (snake->snakelength < 2 || x >= oldx)
|
if (snake->snakelength < 2 || x >= oldx)
|
||||||
snake->snakedir[0] = 2;
|
snake->snakedir[0] = 2;
|
||||||
}
|
}
|
||||||
else if (gamekeydown[KEY_UPARROW])
|
else if (PLAYER1INPUTDOWN(GC_FORWARD) || gamekeydown[KEY_UPARROW] || joystate == 1)
|
||||||
{
|
{
|
||||||
if (snake->snakelength < 2 || y <= oldy)
|
if (snake->snakelength < 2 || y <= oldy)
|
||||||
snake->snakedir[0] = 3;
|
snake->snakedir[0] = 3;
|
||||||
}
|
}
|
||||||
else if (gamekeydown[KEY_DOWNARROW])
|
else if (PLAYER1INPUTDOWN(GC_BACKWARD) || gamekeydown[KEY_DOWNARROW] || joystate == 2)
|
||||||
{
|
{
|
||||||
if (snake->snakelength < 2 || y >= oldy)
|
if (snake->snakelength < 2 || y >= oldy)
|
||||||
snake->snakedir[0] = 4;
|
snake->snakedir[0] = 4;
|
||||||
|
@ -1934,7 +1991,7 @@ static void M_ConfirmConnect(event_t *ev)
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
if (ev->type == ev_keydown)
|
if (ev->type == ev_keydown)
|
||||||
{
|
{
|
||||||
if (ev->key == ' ' || ev->key == 'y' || ev->key == KEY_ENTER)
|
if (ev->key == ' ' || ev->key == 'y' || ev->key == KEY_ENTER || ev->key == KEY_JOY1)
|
||||||
{
|
{
|
||||||
if (totalfilesrequestednum > 0)
|
if (totalfilesrequestednum > 0)
|
||||||
{
|
{
|
||||||
|
@ -1949,7 +2006,7 @@ static void M_ConfirmConnect(event_t *ev)
|
||||||
|
|
||||||
M_ClearMenus(true);
|
M_ClearMenus(true);
|
||||||
}
|
}
|
||||||
else if (ev->key == 'n' || ev->key == KEY_ESCAPE)
|
else if (ev->key == 'n' || ev->key == KEY_ESCAPE || ev->key == KEY_JOY1 + 3)
|
||||||
{
|
{
|
||||||
cl_mode = CL_ABORTED;
|
cl_mode = CL_ABORTED;
|
||||||
M_ClearMenus(true);
|
M_ClearMenus(true);
|
||||||
|
@ -1964,6 +2021,7 @@ static boolean CL_FinishedFileList(void)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
char *downloadsize = NULL;
|
char *downloadsize = NULL;
|
||||||
|
|
||||||
//CONS_Printf(M_GetText("Checking files...\n"));
|
//CONS_Printf(M_GetText("Checking files...\n"));
|
||||||
i = CL_CheckFiles();
|
i = CL_CheckFiles();
|
||||||
if (i == 4) // still checking ...
|
if (i == 4) // still checking ...
|
||||||
|
@ -2379,9 +2437,13 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
|
||||||
D_ProcessEvents(); //needed for menu system to receive inputs
|
D_ProcessEvents(); //needed for menu system to receive inputs
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// my hand has been forced and I am dearly sorry for this awful hack :vomit:
|
||||||
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
|
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
|
||||||
|
{
|
||||||
|
if (!Snake_Joy_Grabber(&events[eventtail]))
|
||||||
G_MapEventsToControls(&events[eventtail]);
|
G_MapEventsToControls(&events[eventtail]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (gamekeydown[KEY_ESCAPE] || gamekeydown[KEY_JOY1+1] || cl_mode == CL_ABORTED)
|
if (gamekeydown[KEY_ESCAPE] || gamekeydown[KEY_JOY1+1] || cl_mode == CL_ABORTED)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue