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
Package Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vlad Doc
SRB2
Commits
f5f22413
Commit
f5f22413
authored
2 years ago
by
Eidolon
Browse files
Options
Downloads
Patches
Plain Diff
sdl: Version-guard rumble and extended buttons
parent
ec58b150
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sdl/i_gamepad.c
+14
-1
14 additions, 1 deletion
src/sdl/i_gamepad.c
with
14 additions
and
1 deletion
src/sdl/i_gamepad.c
+
14
−
1
View file @
f5f22413
...
...
@@ -231,6 +231,7 @@ static boolean Controller_OpenDevice(UINT8 which, INT32 devindex)
controller
->
info
->
type
=
GAMEPAD_TYPE_UNKNOWN
;
#endif // SDL_VERSION_ATLEAST(2,0,12)
#if SDL_VERSION_ATLEAST(2,0,6)
// Check the device vendor and product to find out what controller this actually is
Uint16
vendor
=
SDL_JoystickGetDeviceVendor
(
devindex
);
Uint16
product
=
SDL_JoystickGetDeviceProduct
(
devindex
);
...
...
@@ -239,13 +240,17 @@ static boolean Controller_OpenDevice(UINT8 which, INT32 devindex)
controller
->
info
->
type
=
GAMEPAD_TYPE_XBOX_SERIES_XS
;
else
if
(
IsJoystickXboxOneElite
(
vendor
,
product
))
controller
->
info
->
type
=
GAMEPAD_TYPE_XBOX_ELITE
;
#endif
CONS_Debug
(
DBG_GAMELOGIC
,
M_GetText
(
" Type: %s
\n
"
),
G_GamepadTypeToString
(
controller
->
info
->
type
));
#if SDL_VERSION_ATLEAST(2,0,12)
// Change the ring LEDs on Xbox 360 controllers
// FIXME: Doesn't seem to work?
SDL_GameControllerSetPlayerIndex
(
controller
->
dev
,
which
);
#endif
#if SDL_VERSION_ATLEAST(2,0,18)
// Check if rumble is supported
if
(
SDL_GameControllerHasRumble
(
controller
->
dev
)
==
SDL_TRUE
)
{
...
...
@@ -255,8 +260,12 @@ static boolean Controller_OpenDevice(UINT8 which, INT32 devindex)
else
{
controller
->
info
->
rumble
.
supported
=
false
;
CONS_Debug
(
DBG_GAMELOGIC
,
M_GetText
(
" Rumble supported: No
\n
"
));
;
CONS_Debug
(
DBG_GAMELOGIC
,
M_GetText
(
" Rumble supported: No
\n
"
));
}
#else
controller
->
info
->
rumble
.
supported
=
true
;
CONS_Debug
(
DBG_GAMELOGIC
,
M_GetText
(
" Rumble supported: Maybe
\n
"
));
#endif // SDL_VERSION_ATLEAST(2,0,18)
if
(
!
controller
->
info
->
connected
)
{
...
...
@@ -600,12 +609,14 @@ void I_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint32 type)
GAMEPAD_BUTTON_CASE
(
DPAD_DOWN
);
GAMEPAD_BUTTON_CASE
(
DPAD_LEFT
);
GAMEPAD_BUTTON_CASE
(
DPAD_RIGHT
);
#if SDL_VERSION_ATLEAST(2,0,14)
GAMEPAD_BUTTON_CASE
(
MISC1
);
GAMEPAD_BUTTON_CASE
(
PADDLE1
);
GAMEPAD_BUTTON_CASE
(
PADDLE2
);
GAMEPAD_BUTTON_CASE
(
PADDLE3
);
GAMEPAD_BUTTON_CASE
(
PADDLE4
);
GAMEPAD_BUTTON_CASE
(
TOUCHPAD
);
#endif
default:
return
;
}
...
...
@@ -663,8 +674,10 @@ static void Controller_StopRumble(UINT8 num)
gamepad
->
rumble
.
data
.
small_magnitude
=
0
;
gamepad
->
rumble
.
data
.
duration
=
0
;
#if SDL_VERSION_ATLEAST(2,0,9)
if
(
gamepad
->
rumble
.
supported
)
SDL_GameControllerRumble
(
controller
->
dev
,
0
,
0
,
0
);
#endif
}
static
void
Controller_Close
(
UINT8
num
)
...
...
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