Skip to content

Commit a70700e

Browse files
committed
Introduce ActionSet subsystem
1 parent a67d410 commit a70700e

16 files changed

+242
-4
lines changed

Android.mk

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
1717
LOCAL_SRC_FILES := \
1818
$(subst $(LOCAL_PATH)/,, \
1919
$(wildcard $(LOCAL_PATH)/src/*.c) \
20+
$(wildcard $(LOCAL_PATH)/src/actionset/*.c) \
2021
$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
2122
$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
2223
$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \

CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ endif()
353353
set(LONGESTOPTIONNAME 0) # set_option and friends will change this.
354354

355355
set(SDL_SUBSYSTEMS
356-
Atomic Audio Video Render Events Joystick Haptic Hidapi Power Threads Timers
357-
File Loadso CPUinfo Filesystem Sensor Locale Misc)
356+
ActionSet Atomic Audio Video Render Events Joystick Haptic Hidapi Power
357+
Threads Timers File Loadso CPUinfo Filesystem Sensor Locale Misc)
358358
foreach(_SUB ${SDL_SUBSYSTEMS})
359359
string(TOUPPER ${_SUB} _OPT)
360360
if (NOT DEFINED SDL_${_OPT}_ENABLED_BY_DEFAULT)
@@ -483,6 +483,7 @@ endif()
483483
# General source files
484484
file(GLOB SOURCE_FILES
485485
${SDL3_SOURCE_DIR}/src/*.c
486+
${SDL3_SOURCE_DIR}/src/actionset/*.c
486487
${SDL3_SOURCE_DIR}/src/atomic/*.c
487488
${SDL3_SOURCE_DIR}/src/audio/*.c
488489
${SDL3_SOURCE_DIR}/src/core/*.c

VisualC-GDK/SDL/SDL.vcxproj

+3
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@
291291
<ClInclude Include="..\..\include\SDL3\SDL_begin_code.h" />
292292
<ClInclude Include="..\..\include\SDL3\SDL_close_code.h" />
293293
<ClInclude Include="..\..\include\SDL3\SDL.h" />
294+
<ClInclude Include="..\..\include\SDL3\SDL_actionset.h" />
294295
<ClInclude Include="..\..\include\SDL3\SDL_assert.h" />
295296
<ClInclude Include="..\..\include\SDL3\SDL_atomic.h" />
296297
<ClInclude Include="..\..\include\SDL3\SDL_audio.h" />
@@ -364,6 +365,7 @@
364365
<ClInclude Include="..\..\include\SDL3\SDL_version.h" />
365366
<ClInclude Include="..\..\include\SDL3\SDL_video.h" />
366367
<ClInclude Include="..\..\include\SDL3\SDL_vulkan.h" />
368+
<ClInclude Include="..\..\src\actionset\SDL_actionset_c.h" />
367369
<ClInclude Include="..\..\src\audio\directsound\SDL_directsound.h" />
368370
<ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
369371
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
@@ -538,6 +540,7 @@
538540
<ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb_std_func.h" />
539541
</ItemGroup>
540542
<ItemGroup>
543+
<ClCompile Include="..\..\src\actionset\SDL_actionset.c" />
541544
<ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
542545
<ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
543546
<ClCompile Include="..\..\src\audio\directsound\SDL_directsound.c" />

VisualC-GDK/SDL/SDL.vcxproj.filters

+7
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@
183183
<ClInclude Include="..\..\include\SDL3\SDL.h">
184184
<Filter>API Headers</Filter>
185185
</ClInclude>
186+
<ClInclude Include="..\..\include\SDL3\SDL_actionset.h">
187+
<Filter>API Headers</Filter>
188+
</ClInclude>
186189
<ClInclude Include="..\..\include\SDL3\SDL_assert.h">
187190
<Filter>API Headers</Filter>
188191
</ClInclude>
@@ -405,6 +408,9 @@
405408
<ClInclude Include="..\..\include\SDL3\SDL_test_memory.h">
406409
<Filter>API Headers</Filter>
407410
</ClInclude>
411+
<ClInclude Include="..\..\src\actionset\SDL_actionset_c.h">
412+
<Filter>audio</Filter>
413+
</ClInclude>
408414
<ClInclude Include="..\..\src\audio\SDL_audio_c.h">
409415
<Filter>audio</Filter>
410416
</ClInclude>
@@ -832,6 +838,7 @@
832838
<ClCompile Include="..\..\src\SDL_hints.c" />
833839
<ClCompile Include="..\..\src\SDL_list.c" />
834840
<ClCompile Include="..\..\src\SDL_utils.c" />
841+
<ClCompile Include="..\..\src\actionset\SDL_actionset.c" />
835842
<ClCompile Include="..\..\src\audio\SDL_audio.c">
836843
<Filter>audio</Filter>
837844
</ClCompile>

VisualC-WinRT/SDL-UWP.vcxproj

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<ClInclude Include="..\include\SDL3\SDL_begin_code.h" />
3939
<ClInclude Include="..\include\SDL3\SDL_close_code.h" />
4040
<ClInclude Include="..\include\SDL3\SDL.h" />
41+
<ClInclude Include="..\include\SDL3\SDL_actionset.h" />
4142
<ClInclude Include="..\include\SDL3\SDL_assert.h" />
4243
<ClInclude Include="..\include\SDL3\SDL_atomic.h" />
4344
<ClInclude Include="..\include\SDL3\SDL_audio.h" />
@@ -89,6 +90,7 @@
8990
<ClInclude Include="..\include\SDL3\SDL_types.h" />
9091
<ClInclude Include="..\include\SDL3\SDL_version.h" />
9192
<ClInclude Include="..\include\SDL3\SDL_video.h" />
93+
<ClInclude Include="..\src\actionset\SDL_actionset_c.h" />
9294
<ClInclude Include="..\src\audio\disk\SDL_diskaudio.h" />
9395
<ClInclude Include="..\src\audio\dummy\SDL_dummyaudio.h" />
9496
<ClInclude Include="..\src\audio\SDL_audiodev_c.h" />
@@ -185,6 +187,7 @@
185187
<ClInclude Include="..\src\video\yuv2rgb\yuv_rgb.h" />
186188
</ItemGroup>
187189
<ItemGroup>
190+
<ClCompile Include="..\src\actionset\SDL_actionset.c" />
188191
<ClCompile Include="..\src\atomic\SDL_atomic.c" />
189192
<ClCompile Include="..\src\atomic\SDL_spinlock.c" />
190193
<ClCompile Include="..\src\audio\disk\SDL_diskaudio.c" />

VisualC-WinRT/SDL-UWP.vcxproj.filters

+9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<ClInclude Include="..\include\SDL3\SDL.h">
1919
<Filter>Header Files</Filter>
2020
</ClInclude>
21+
<ClInclude Include="..\include\SDL3\SDL_actionset.h">
22+
<Filter>Header Files</Filter>
23+
</ClInclude>
2124
<ClInclude Include="..\include\SDL3\SDL_assert.h">
2225
<Filter>Header Files</Filter>
2326
</ClInclude>
@@ -168,6 +171,9 @@
168171
<ClInclude Include="..\src\joystick\SDL_gamepad_db.h">
169172
<Filter>Header Files</Filter>
170173
</ClInclude>
174+
<ClInclude Include="..\src\actionset\SDL_actionset_c.h">
175+
<Filter>Source Files</Filter>
176+
</ClInclude>
171177
<ClInclude Include="..\src\audio\disk\SDL_diskaudio.h">
172178
<Filter>Source Files</Filter>
173179
</ClInclude>
@@ -447,6 +453,9 @@
447453
<ClInclude Include="..\include\SDL3\SDL_misc.h">
448454
<Filter>Header Files</Filter>
449455
</ClInclude>
456+
<ClCompile Include="..\src\actionset\SDL_actionset.c">
457+
<Filter>Source Files</Filter>
458+
</ClCompile>
450459
<ClCompile Include="..\src\atomic\SDL_atomic.c">
451460
<Filter>Source Files</Filter>
452461
</ClCompile>

VisualC/SDL/SDL.vcxproj

+3
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@
237237
<ClInclude Include="..\..\include\SDL3\SDL_begin_code.h" />
238238
<ClInclude Include="..\..\include\SDL3\SDL_close_code.h" />
239239
<ClInclude Include="..\..\include\SDL3\SDL.h" />
240+
<ClInclude Include="..\..\include\SDL3\SDL_actionset.h" />
240241
<ClInclude Include="..\..\include\SDL3\SDL_assert.h" />
241242
<ClInclude Include="..\..\include\SDL3\SDL_atomic.h" />
242243
<ClInclude Include="..\..\include\SDL3\SDL_audio.h" />
@@ -309,6 +310,7 @@
309310
<ClInclude Include="..\..\include\SDL3\SDL_version.h" />
310311
<ClInclude Include="..\..\include\SDL3\SDL_video.h" />
311312
<ClInclude Include="..\..\include\SDL3\SDL_vulkan.h" />
313+
<ClInclude Include="..\..\src\actionset\SDL_actionset_c.h" />
312314
<ClInclude Include="..\..\src\audio\directsound\SDL_directsound.h" />
313315
<ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
314316
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
@@ -461,6 +463,7 @@
461463
<ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb_std_func.h" />
462464
</ItemGroup>
463465
<ItemGroup>
466+
<ClCompile Include="..\..\src\actionset\SDL_actionset.c" />
464467
<ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
465468
<ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
466469
<ClCompile Include="..\..\src\audio\directsound\SDL_directsound.c" />

VisualC/SDL/SDL.vcxproj.filters

+7
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@
180180
<ClInclude Include="..\..\include\SDL3\SDL.h">
181181
<Filter>API Headers</Filter>
182182
</ClInclude>
183+
<ClInclude Include="..\..\include\SDL3\SDL_actionset.h">
184+
<Filter>API Headers</Filter>
185+
</ClInclude>
183186
<ClInclude Include="..\..\include\SDL3\SDL_assert.h">
184187
<Filter>API Headers</Filter>
185188
</ClInclude>
@@ -399,6 +402,9 @@
399402
<ClInclude Include="..\..\include\SDL3\SDL_test_memory.h">
400403
<Filter>API Headers</Filter>
401404
</ClInclude>
405+
<ClInclude Include="..\..\src\actionset\SDL_actionset_c.h">
406+
<Filter>audio</Filter>
407+
</ClInclude>
402408
<ClInclude Include="..\..\src\audio\SDL_audio_c.h">
403409
<Filter>audio</Filter>
404410
</ClInclude>
@@ -820,6 +826,7 @@
820826
<ClCompile Include="..\..\src\SDL_hints.c" />
821827
<ClCompile Include="..\..\src\SDL_list.c" />
822828
<ClCompile Include="..\..\src\SDL_utils.c" />
829+
<ClCompile Include="..\..\src\actionset\SDL_actionset.c" />
823830
<ClCompile Include="..\..\src\audio\SDL_audio.c">
824831
<Filter>audio</Filter>
825832
</ClCompile>

include/SDL3/SDL.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define SDL_h_
3131

3232
#include <SDL3/SDL_stdinc.h>
33+
#include <SDL3/SDL_actionset.h>
3334
#include <SDL3/SDL_assert.h>
3435
#include <SDL3/SDL_atomic.h>
3536
#include <SDL3/SDL_audio.h>

include/SDL3/SDL_actionset.h

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
22+
/**
23+
* \file SDL_actionset.h
24+
*
25+
* \brief Access to the "action set" interface for the SDL library.
26+
*/
27+
28+
#ifndef SDL_actionset_h_
29+
#define SDL_actionset_h_
30+
31+
#include <SDL3/SDL_begin_code.h>
32+
/* Set up for C function definitions, even when using C++ */
33+
#ifdef __cplusplus
34+
extern "C" {
35+
#endif
36+
37+
/* TODO: Copy over from Codename GigaBrain */
38+
39+
extern DECLSPEC void SDLCALL SDL_UpdateActionSet(void);
40+
41+
/* Ends C function definitions when using C++ */
42+
#ifdef __cplusplus
43+
}
44+
#endif
45+
#include <SDL3/SDL_close_code.h>
46+
47+
#endif /* SDL_actionset_h_ */

include/SDL3/SDL_hints.h

+12
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,18 @@ extern "C" {
315315
*/
316316
#define SDL_HINT_AUTO_UPDATE_SENSORS "SDL_AUTO_UPDATE_SENSORS"
317317

318+
/**
319+
* \brief A variable controlling whether SDL updates action set state when getting action events
320+
*
321+
* This variable can be set to the following values:
322+
*
323+
* "0" - You'll call SDL_UpdateActionSet() manually
324+
* "1" - SDL will automatically call SDL_UpdateActionSet() (default)
325+
*
326+
* This hint can be toggled on and off at runtime.
327+
*/
328+
#define SDL_HINT_AUTO_UPDATE_ACTIONSET "SDL_AUTO_UPDATE_ACTIONSET"
329+
318330
/**
319331
* \brief Prevent SDL from using version 4 of the bitmap header when saving BMPs.
320332
*

include/SDL3/SDL_init.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ typedef enum
5959
SDL_INIT_HAPTIC = 0x00001000,
6060
SDL_INIT_GAMEPAD = 0x00002000, /**< `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` */
6161
SDL_INIT_EVENTS = 0x00004000,
62-
SDL_INIT_SENSOR = 0x00008000
62+
SDL_INIT_SENSOR = 0x00008000,
63+
SDL_INIT_ACTIONSET = 0x00010000, /**< `SDL_INIT_ACTIONSET` implies `SDL_INIT_GAMEPAD | SDL_INIT_SENSOR | SDL_INIT_HAPTIC` */
6364
} SDL_InitFlags;
6465
#define SDL_INIT_EVERYTHING ( \
6566
SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
66-
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMEPAD | SDL_INIT_SENSOR \
67+
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMEPAD | SDL_INIT_SENSOR | \
68+
SDL_INIT_ACTIONSET \
6769
)
6870

6971
/**
@@ -94,6 +96,8 @@ typedef enum
9496
* - `SDL_INIT_GAMEPAD`: gamepad subsystem; automatically initializes the
9597
* joystick subsystem
9698
* - `SDL_INIT_EVENTS`: events subsystem
99+
* - `SDL_INIT_ACTIONSET`: actionset subsystem, automatically initializes the
100+
* gamepad, sensor, haptic, and events subsystems
97101
* - `SDL_INIT_EVERYTHING`: all of the above subsystems
98102
*
99103
* Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem()

src/SDL.c

+33
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "joystick/SDL_gamepad_c.h"
4646
#include "joystick/SDL_joystick_c.h"
4747
#include "sensor/SDL_sensor_c.h"
48+
#include "actionset/SDL_actionset_c.h"
4849

4950
/* Initialization/Cleanup routines */
5051
#ifndef SDL_TIMERS_DISABLED
@@ -175,6 +176,11 @@ int SDL_InitSubSystem(Uint32 flags)
175176
SDL_DBus_Init();
176177
#endif
177178

179+
if (flags & SDL_INIT_ACTIONSET) {
180+
/* action set implies gamepad, sensor, and haptic */
181+
flags |= SDL_INIT_GAMEPAD | SDL_INIT_SENSOR | SDL_INIT_HAPTIC;
182+
}
183+
178184
if (flags & SDL_INIT_GAMEPAD) {
179185
/* game controller implies joystick */
180186
flags |= SDL_INIT_JOYSTICK;
@@ -348,6 +354,24 @@ int SDL_InitSubSystem(Uint32 flags)
348354
#endif
349355
}
350356

357+
if (flags & SDL_INIT_ACTIONSET) {
358+
#ifndef SDL_ACTIONSET_DISABLED
359+
if (SDL_ShouldInitSubsystem(SDL_INIT_ACTIONSET)) {
360+
SDL_IncrementSubsystemRefCount(SDL_INIT_ACTIONSET);
361+
if (SDL_InitActionSet() < 0) {
362+
SDL_DecrementSubsystemRefCount(SDL_INIT_ACTIONSET);
363+
goto quit_and_error;
364+
}
365+
} else {
366+
SDL_IncrementSubsystemRefCount(SDL_INIT_ACTIONSET);
367+
}
368+
flags_initialized |= SDL_INIT_ACTIONSET;
369+
#else
370+
SDL_SetError("SDL not built with actionset support");
371+
goto quit_and_error;
372+
#endif
373+
}
374+
351375
(void)flags_initialized; /* make static analysis happy, since this only gets used in error cases. */
352376

353377
return 0;
@@ -365,6 +389,15 @@ int SDL_Init(Uint32 flags)
365389
void SDL_QuitSubSystem(Uint32 flags)
366390
{
367391
/* Shut down requested initialized subsystems */
392+
#ifndef SDL_ACTIONSET_DISABLED
393+
if (flags & SDL_INIT_ACTIONSET) {
394+
if (SDL_ShouldQuitSubsystem(SDL_INIT_ACTIONSET)) {
395+
SDL_QuitActionSet();
396+
}
397+
SDL_DecrementSubsystemRefCount(SDL_INIT_ACTIONSET);
398+
}
399+
#endif
400+
368401
#ifndef SDL_SENSOR_DISABLED
369402
if (flags & SDL_INIT_SENSOR) {
370403
if (SDL_ShouldQuitSubsystem(SDL_INIT_SENSOR)) {

src/actionset/SDL_actionset.c

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
#include "SDL_actionset_c.h"
23+
24+
/* TODO: Copy over from Codename GigaBrain */
25+
26+
int SDL_InitActionSet(void)
27+
{
28+
return 0;
29+
}
30+
31+
void SDL_QuitActionSet(void)
32+
{
33+
}
34+
35+
SDL_bool SDL_ActionSetsOpened(void)
36+
{
37+
return SDL_FALSE;
38+
}
39+
40+
void SDL_UpdateActionSet(void)
41+
{
42+
}

0 commit comments

Comments
 (0)