Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
8f5f5c1e
Commit
8f5f5c1e
authored
Nov 23, 2022
by
Eden (Ashi)
Browse files
Options
Downloads
Patches
Plain Diff
hack and a half but joystick works now
parent
741b1f41
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1883
Fix Download Consent/Snake minigame not having controller support
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/d_clisrv.c
+66
-6
66 additions, 6 deletions
src/d_clisrv.c
with
66 additions
and
6 deletions
src/d_clisrv.c
+
66
−
6
View file @
8f5f5c1e
...
...
@@ -48,6 +48,9 @@
#include
"md5.h"
#include
"m_perfstats.h"
// aaaaaa
#include
"i_joy.h"
#ifndef NONET
// cl loading screen
#include
"v_video.h"
...
...
@@ -650,6 +653,22 @@ static UINT8 Snake_GetOppositeDir(UINT8 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
)
{
UINT8
x
,
y
;
...
...
@@ -676,6 +695,9 @@ static void Snake_Handle(void)
UINT8
x
,
y
;
UINT8
oldx
,
oldy
;
UINT16
i
;
UINT16
j
;
UINT16
joystate
=
0
;
static
INT32
pjoyx
=
0
,
pjoyy
=
0
;
// Handle retry
if
(
snake
->
gameover
&&
(
PLAYER1INPUTDOWN
(
GC_JUMP
)
||
gamekeydown
[
KEY_ENTER
]))
...
...
@@ -704,23 +726,57 @@ static void Snake_Handle(void)
oldx
=
snake
->
snakex
[
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
;
}
}
// Update direction
if
(
PLAYER1INPUTDOWN
(
GC_STRAFELEFT
)
||
gamekeydown
[
KEY_LEFTARROW
]
||
J
oy
Axis
(
JA_STRAFE
)
>
0
)
if
(
PLAYER1INPUTDOWN
(
GC_STRAFELEFT
)
||
gamekeydown
[
KEY_LEFTARROW
]
||
j
oy
state
==
3
)
{
if
(
snake
->
snakelength
<
2
||
x
<=
oldx
)
snake
->
snakedir
[
0
]
=
1
;
}
else
if
(
PLAYER1INPUTDOWN
(
GC_STRAFERIGHT
)
||
gamekeydown
[
KEY_RIGHTARROW
]
||
J
oy
Axis
(
JA_STRAFE
)
<
0
)
else
if
(
PLAYER1INPUTDOWN
(
GC_STRAFERIGHT
)
||
gamekeydown
[
KEY_RIGHTARROW
]
||
j
oy
state
==
4
)
{
if
(
snake
->
snakelength
<
2
||
x
>=
oldx
)
snake
->
snakedir
[
0
]
=
2
;
}
else
if
(
PLAYER1INPUTDOWN
(
GC_FORWARD
)
||
gamekeydown
[
KEY_UPARROW
]
||
J
oy
Axis
(
JA_MOVE
)
>
0
)
else
if
(
PLAYER1INPUTDOWN
(
GC_FORWARD
)
||
gamekeydown
[
KEY_UPARROW
]
||
j
oy
state
==
1
)
{
if
(
snake
->
snakelength
<
2
||
y
<=
oldy
)
snake
->
snakedir
[
0
]
=
3
;
}
else
if
(
PLAYER1INPUTDOWN
(
GC_BACKWARD
)
||
gamekeydown
[
KEY_DOWNARROW
]
||
J
oy
Axis
(
JA_MOVE
)
<
0
)
else
if
(
PLAYER1INPUTDOWN
(
GC_BACKWARD
)
||
gamekeydown
[
KEY_DOWNARROW
]
||
j
oy
state
==
2
)
{
if
(
snake
->
snakelength
<
2
||
y
>=
oldy
)
snake
->
snakedir
[
0
]
=
4
;
...
...
@@ -2073,7 +2129,7 @@ static boolean CL_FinishedFileList(void)
"Download of %s additional content
\n
is required to join.
\n
"
"
\n
"
"Press ENTER to continue
\n
or ESC to cancel.
\n
"
),
"1111"
),
M_ConfirmConnect
,
MM_EVENTHANDLER
);
),
downloadsize
),
M_ConfirmConnect
,
MM_EVENTHANDLER
);
Z_Free
(
downloadsize
);
cl_mode
=
CL_CONFIRMCONNECT
;
...
...
@@ -2380,9 +2436,13 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
D_ProcessEvents
();
//needed for menu system to receive inputs
else
{
// my hand has been forced and I am dearly sorry for this awful hack :vomit:
for
(;
eventtail
!=
eventhead
;
eventtail
=
(
eventtail
+
1
)
&
(
MAXEVENTS
-
1
))
{
if
(
!
Snake_Joy_Grabber
(
&
events
[
eventtail
]))
G_MapEventsToControls
(
&
events
[
eventtail
]);
}
}
if
(
gamekeydown
[
KEY_ESCAPE
]
||
gamekeydown
[
KEY_JOY1
+
1
]
||
cl_mode
==
CL_ABORTED
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment