Skip to content

Commit e0ef7c0

Browse files
committed
ActionSet: Fill in basic driver layout, add Steam and SDL drivers
1 parent b879a86 commit e0ef7c0

File tree

14 files changed

+279
-0
lines changed

14 files changed

+279
-0
lines changed

Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ LOCAL_SRC_FILES := \
1818
$(subst $(LOCAL_PATH)/,, \
1919
$(wildcard $(LOCAL_PATH)/src/*.c) \
2020
$(wildcard $(LOCAL_PATH)/src/actionset/*.c) \
21+
$(wildcard $(LOCAL_PATH)/src/actionset/sdlinput/*.c) \
2122
$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
2223
$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
2324
$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ endif()
484484
file(GLOB SOURCE_FILES
485485
${SDL3_SOURCE_DIR}/src/*.c
486486
${SDL3_SOURCE_DIR}/src/actionset/*.c
487+
${SDL3_SOURCE_DIR}/src/actionset/sdlinput/*.c
488+
${SDL3_SOURCE_DIR}/src/actionset/steaminput/*.c # FIXME: Windows/macOS/Linux only
487489
${SDL3_SOURCE_DIR}/src/atomic/*.c
488490
${SDL3_SOURCE_DIR}/src/audio/*.c
489491
${SDL3_SOURCE_DIR}/src/core/*.c

VisualC-GDK/SDL/SDL.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@
366366
<ClInclude Include="..\..\include\SDL3\SDL_video.h" />
367367
<ClInclude Include="..\..\include\SDL3\SDL_vulkan.h" />
368368
<ClInclude Include="..\..\src\actionset\SDL_actionset_c.h" />
369+
<ClInclude Include="..\..\src\actionset\sdlinput\SDL_sdlinput.h" />
369370
<ClInclude Include="..\..\src\audio\directsound\SDL_directsound.h" />
370371
<ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
371372
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
@@ -541,6 +542,7 @@
541542
</ItemGroup>
542543
<ItemGroup>
543544
<ClCompile Include="..\..\src\actionset\SDL_actionset.c" />
545+
<ClCompile Include="..\..\src\actionset\sdlinput\SDL_sdlinput.c" />
544546
<ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
545547
<ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
546548
<ClCompile Include="..\..\src\audio\directsound\SDL_directsound.c" />

VisualC-GDK/SDL/SDL.vcxproj.filters

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@
409409
<Filter>API Headers</Filter>
410410
</ClInclude>
411411
<ClInclude Include="..\..\src\actionset\SDL_actionset_c.h" />
412+
<ClInclude Include="..\..\src\actionset\sdlinput\SDL_sdlinput.h" />
412413
<ClInclude Include="..\..\src\audio\SDL_audio_c.h">
413414
<Filter>audio</Filter>
414415
</ClInclude>
@@ -837,6 +838,7 @@
837838
<ClCompile Include="..\..\src\SDL_list.c" />
838839
<ClCompile Include="..\..\src\SDL_utils.c" />
839840
<ClCompile Include="..\..\src\actionset\SDL_actionset.c" />
841+
<ClCompile Include="..\..\src\actionset\sdlinput\SDL_sdlinput.c" />
840842
<ClCompile Include="..\..\src\audio\SDL_audio.c">
841843
<Filter>audio</Filter>
842844
</ClCompile>

VisualC-WinRT/SDL-UWP.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<ClInclude Include="..\include\SDL3\SDL_version.h" />
9292
<ClInclude Include="..\include\SDL3\SDL_video.h" />
9393
<ClInclude Include="..\src\actionset\SDL_actionset_c.h" />
94+
<ClInclude Include="..\src\actionset\sdlinput\SDL_sdlinput.h" />
9495
<ClInclude Include="..\src\audio\disk\SDL_diskaudio.h" />
9596
<ClInclude Include="..\src\audio\dummy\SDL_dummyaudio.h" />
9697
<ClInclude Include="..\src\audio\SDL_audiodev_c.h" />
@@ -188,6 +189,7 @@
188189
</ItemGroup>
189190
<ItemGroup>
190191
<ClCompile Include="..\src\actionset\SDL_actionset.c" />
192+
<ClCompile Include="..\src\actionset\sdlinput\SDL_sdlinput.c" />
191193
<ClCompile Include="..\src\atomic\SDL_atomic.c" />
192194
<ClCompile Include="..\src\atomic\SDL_spinlock.c" />
193195
<ClCompile Include="..\src\audio\disk\SDL_diskaudio.c" />

VisualC-WinRT/SDL-UWP.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@
174174
<ClInclude Include="..\src\actionset\SDL_actionset_c.h">
175175
<Filter>Source Files</Filter>
176176
</ClInclude>
177+
<ClInclude Include="..\src\actionset\sdlinput\SDL_sdlinput.h">
178+
<Filter>Source Files</Filter>
179+
</ClInclude>
177180
<ClInclude Include="..\src\audio\disk\SDL_diskaudio.h">
178181
<Filter>Source Files</Filter>
179182
</ClInclude>
@@ -456,6 +459,9 @@
456459
<ClCompile Include="..\src\actionset\SDL_actionset.c">
457460
<Filter>Source Files</Filter>
458461
</ClCompile>
462+
<ClCompile Include="..\src\actionset\sdlinput\SDL_sdlinput.c">
463+
<Filter>Source Files</Filter>
464+
</ClCompile>
459465
<ClCompile Include="..\src\atomic\SDL_atomic.c">
460466
<Filter>Source Files</Filter>
461467
</ClCompile>

VisualC/SDL/SDL.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@
311311
<ClInclude Include="..\..\include\SDL3\SDL_video.h" />
312312
<ClInclude Include="..\..\include\SDL3\SDL_vulkan.h" />
313313
<ClInclude Include="..\..\src\actionset\SDL_actionset_c.h" />
314+
<ClInclude Include="..\..\src\actionset\sdlinput\SDL_sdlinput.h" />
315+
<ClInclude Include="..\..\src\actionset\steaminput\SDL_steaminput.h" />
314316
<ClInclude Include="..\..\src\audio\directsound\SDL_directsound.h" />
315317
<ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
316318
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
@@ -464,6 +466,8 @@
464466
</ItemGroup>
465467
<ItemGroup>
466468
<ClCompile Include="..\..\src\actionset\SDL_actionset.c" />
469+
<ClCompile Include="..\..\src\actionset\sdlinput\SDL_sdlinput.c" />
470+
<ClCompile Include="..\..\src\actionset\steaminput\SDL_steaminput.c" />
467471
<ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
468472
<ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
469473
<ClCompile Include="..\..\src\audio\directsound\SDL_directsound.c" />

VisualC/SDL/SDL.vcxproj.filters

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@
403403
<Filter>API Headers</Filter>
404404
</ClInclude>
405405
<ClInclude Include="..\..\src\actionset\SDL_actionset_c.h" />
406+
<ClInclude Include="..\..\src\actionset\sdlinput\SDL_sdlinput.h" />
407+
<ClInclude Include="..\..\src\actionset\steaminput\SDL_steaminput.h" />
406408
<ClInclude Include="..\..\src\audio\SDL_audio_c.h">
407409
<Filter>audio</Filter>
408410
</ClInclude>
@@ -825,6 +827,8 @@
825827
<ClCompile Include="..\..\src\SDL_list.c" />
826828
<ClCompile Include="..\..\src\SDL_utils.c" />
827829
<ClCompile Include="..\..\src\actionset\SDL_actionset.c" />
830+
<ClCompile Include="..\..\src\actionset\sdlinput\SDL_sdlinput.c" />
831+
<ClCompile Include="..\..\src\actionset\steaminput\SDL_steaminput.c" />
828832
<ClCompile Include="..\..\src\audio\SDL_audio.c">
829833
<Filter>audio</Filter>
830834
</ClCompile>

src/actionset/SDL_actionset.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,36 @@
2020
*/
2121
#include "SDL_internal.h"
2222
#include "SDL_actionset_c.h"
23+
#include "SDL_sysactionset.h"
2324

2425
/* TODO: Copy over from Codename GigaBrain */
2526

27+
/* Providers should be prioritized as follows:
28+
* Private Launchers (i.e. EA) > Shared Stores (i.e. Steam, Itch) > OS > SDL
29+
*/
30+
static const SDL_ActionSetProvider *const providers[] = {
31+
#ifdef SDL_ACTIONSET_STEAMINPUT
32+
&STEAMINPUT_provider,
33+
#endif
34+
&SDLINPUT_provider /* Unlike other subsystems, SDL is always available, no dummy drivers needed */
35+
};
36+
2637
int SDL_InitActionSet(void)
2738
{
39+
int i;
40+
for (i = 0; i < SDL_arraysize(providers); i += 1) {
41+
providers[i]->Init();
42+
}
2843
return 0;
2944
}
3045

3146
void SDL_QuitActionSet(void)
3247
{
48+
int i;
49+
/* TODO: Close ActionSetDevice array here */
50+
for (i = 0; i < SDL_arraysize(providers); i += 1) {
51+
providers[i]->Quit();
52+
}
3353
}
3454

3555
SDL_bool SDL_ActionSetsOpened(void)
@@ -39,4 +59,8 @@ SDL_bool SDL_ActionSetsOpened(void)
3959

4060
void SDL_UpdateActionSet(void)
4161
{
62+
int i;
63+
for (i = 0; i < SDL_arraysize(providers); i += 1) {
64+
providers[i]->Update();
65+
}
4266
}

src/actionset/SDL_sysactionset.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Simple DirectMedia Layer
3+
Copyright (C) 1997-2023 Sam Lantinga <[email protected]>
4+
5+
This software is provided 'as-is', without any express or implied
6+
warranty. In no event will the authors be held liable for any damages
7+
arising from the use of this software.
8+
9+
Permission is granted to anyone to use this software for any purpose,
10+
including commercial applications, and to alter it and redistribute it
11+
freely, subject to the following restrictions:
12+
13+
1. The origin of this software must not be misrepresented; you must not
14+
claim that you wrote the original software. If you use this software
15+
in a product, an acknowledgment in the product documentation would be
16+
appreciated but is not required.
17+
2. Altered source versions must be plainly marked as such, and must not be
18+
misrepresented as being the original software.
19+
3. This notice may not be removed or altered from any source distribution.
20+
*/
21+
#include "SDL_internal.h"
22+
23+
#ifndef SDL_sysactionset_h_
24+
#define SDL_sysactionset_h_
25+
26+
#include "./SDL_actionset_c.h"
27+
28+
typedef struct SDL_ActionSetProvider
29+
{
30+
void (*Init)(void);
31+
void (*Quit)(void);
32+
void (*Update)(void);
33+
} SDL_ActionSetProvider;
34+
35+
/* Not all of these are available in a given build. Use #ifdefs, etc. */
36+
extern SDL_ActionSetProvider STEAMINPUT_provider;
37+
extern SDL_ActionSetProvider SDLINPUT_provider;
38+
39+
#if defined(__WINDOWS__) || defined(__MACOS__) || defined(__LINUX__)
40+
#define SDL_ACTIONSET_STEAMINPUT
41+
#endif
42+
43+
#endif /* SDL_sysactionset_h_ */

0 commit comments

Comments
 (0)