Bladeren bron

Split SDL gamepad internal functions into SDL_gamepad_c.h

Sam Lantinga 2 jaren geleden
bovenliggende
commit
ad8a6d2b05

+ 1 - 0
VisualC-GDK/SDL/SDL.vcxproj

@@ -403,6 +403,7 @@
     <ClInclude Include="..\..\src\joystick\controller_type.h" />
     <ClInclude Include="..\..\src\joystick\hidapi\SDL_hidapijoystick_c.h" />
     <ClInclude Include="..\..\src\joystick\hidapi\SDL_hidapi_rumble.h" />
+    <ClInclude Include="..\..\src\joystick\SDL_gamepad_c.h" />
     <ClInclude Include="..\..\src\joystick\SDL_gamepad_db.h" />
     <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
     <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />

+ 3 - 0
VisualC-GDK/SDL/SDL.vcxproj.filters

@@ -483,6 +483,9 @@
     <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h">
       <Filter>haptic</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\joystick\SDL_gamepad_c.h">
+      <Filter>joystick</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\src\joystick\SDL_gamepad_db.h">
       <Filter>joystick</Filter>
     </ClInclude>

+ 2 - 1
VisualC-WinRT/SDL-UWP.vcxproj

@@ -121,6 +121,7 @@
     <ClInclude Include="..\src\haptic\windows\SDL_windowshaptic_c.h" />
     <ClInclude Include="..\src\haptic\windows\SDL_xinputhaptic_c.h" />
     <ClInclude Include="..\src\joystick\controller_type.h" />
+    <ClInclude Include="..\src\joystick\SDL_gamepad_c.h" />
     <ClInclude Include="..\src\joystick\SDL_gamepad_db.h" />
     <ClInclude Include="..\src\joystick\SDL_joystick_c.h" />
     <ClInclude Include="..\src\joystick\SDL_sysjoystick.h" />
@@ -837,4 +838,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 4 - 1
VisualC-WinRT/SDL-UWP.vcxproj.filters

@@ -162,6 +162,9 @@
     <ClInclude Include="..\include\SDL3\SDL_video.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\joystick\SDL_gamepad_c.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
     <ClInclude Include="..\src\joystick\SDL_gamepad_db.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -843,4 +846,4 @@
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
-</Project>
+</Project>

+ 1 - 0
VisualC/SDL/SDL.vcxproj

@@ -347,6 +347,7 @@
     <ClInclude Include="..\..\src\joystick\controller_type.h" />
     <ClInclude Include="..\..\src\joystick\hidapi\SDL_hidapijoystick_c.h" />
     <ClInclude Include="..\..\src\joystick\hidapi\SDL_hidapi_rumble.h" />
+    <ClInclude Include="..\..\src\joystick\SDL_gamepad_c.h" />
     <ClInclude Include="..\..\src\joystick\SDL_gamepad_db.h" />
     <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
     <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />

+ 3 - 0
VisualC/SDL/SDL.vcxproj.filters

@@ -477,6 +477,9 @@
     <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h">
       <Filter>haptic</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\joystick\SDL_gamepad_c.h">
+      <Filter>joystick</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\src\joystick\SDL_gamepad_db.h">
       <Filter>joystick</Filter>
     </ClInclude>

+ 1 - 0
src/SDL.c

@@ -41,6 +41,7 @@
 #include "video/SDL_video_c.h"
 #include "events/SDL_events_c.h"
 #include "haptic/SDL_haptic_c.h"
+#include "joystick/SDL_gamepad_c.h"
 #include "joystick/SDL_joystick_c.h"
 #include "sensor/SDL_sensor_c.h"
 

+ 1 - 0
src/joystick/SDL_gamepad.c

@@ -24,6 +24,7 @@
 
 #include "SDL_sysjoystick.h"
 #include "SDL_joystick_c.h"
+#include "SDL_gamepad_c.h"
 #include "SDL_gamepad_db.h"
 #include "controller_type.h"
 #include "usb_ids.h"

+ 45 - 0
src/joystick/SDL_gamepad_c.h

@@ -0,0 +1,45 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SDL_gamepad_c_h_
+#define SDL_gamepad_c_h_
+
+#include "SDL_internal.h"
+
+/* Useful functions and variables from SDL_gamepad.c */
+
+/* Initialization and shutdown functions */
+extern int SDL_GamepadInitMappings(void);
+extern void SDL_GamepadQuitMappings(void);
+extern int SDL_GamepadInit(void);
+extern void SDL_GamepadQuit(void);
+
+
+/* Function to return whether a joystick name and GUID is a gamepad  */
+extern SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_JoystickGUID guid);
+
+/* Function to return whether a gamepad should be ignored */
+extern SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_JoystickGUID guid);
+
+/* Handle delayed guide button on a gamepad */
+extern void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick);
+
+#endif /* SDL_gamepad_c_h_ */

+ 2 - 0
src/joystick/SDL_joystick.c

@@ -24,6 +24,8 @@
 
 #include "SDL_sysjoystick.h"
 #include "../SDL_hints_c.h"
+#include "SDL_gamepad_c.h"
+#include "SDL_joystick_c.h"
 
 #if !SDL_EVENTS_DISABLED
 #include "../events/SDL_events_c.h"

+ 0 - 15
src/joystick/SDL_joystick_c.h

@@ -52,12 +52,6 @@ extern void SDL_AssertJoysticksLocked(void) SDL_ASSERT_CAPABILITY(SDL_joystick_l
 /* Function to get the next available joystick instance ID */
 extern SDL_JoystickID SDL_GetNextJoystickInstanceID(void);
 
-/* Initialization and shutdown functions */
-extern int SDL_GamepadInitMappings(void);
-extern void SDL_GamepadQuitMappings(void);
-extern int SDL_GamepadInit(void);
-extern void SDL_GamepadQuit(void);
-
 /* Function to return the device index for a joystick ID, or -1 if not found */
 extern int SDL_JoystickGetDeviceIndexFromInstanceID(SDL_JoystickID instance_id);
 
@@ -137,15 +131,6 @@ extern SDL_bool SDL_IsJoystickVIRTUAL(SDL_JoystickGUID guid);
 /* Function to return whether a joystick should be ignored */
 extern SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid);
 
-/* Function to return whether a joystick name and GUID is a gamepad  */
-extern SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_JoystickGUID guid);
-
-/* Function to return whether a gamepad should be ignored */
-extern SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_JoystickGUID guid);
-
-/* Handle delayed guide button on a gamepad */
-extern void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick);
-
 /* Internal event queueing functions */
 extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers);
 extern void SDL_PrivateJoystickAddSensor(SDL_Joystick *joystick, SDL_SensorType type, float rate);