mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-24 20:18:29 +00:00
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594
This commit is contained in:
@@ -28,12 +28,9 @@
|
||||
#include "../SDL_sysjoystick.h"
|
||||
#include "../SDL_joystick_c.h"
|
||||
|
||||
static joystick_hwdata *g_VJoys = NULL;
|
||||
|
||||
static joystick_hwdata * g_VJoys = NULL;
|
||||
|
||||
|
||||
static joystick_hwdata *
|
||||
VIRTUAL_HWDataForIndex(int device_index)
|
||||
static joystick_hwdata *VIRTUAL_HWDataForIndex(int device_index)
|
||||
{
|
||||
joystick_hwdata *vjoy = g_VJoys;
|
||||
while (vjoy) {
|
||||
@@ -46,13 +43,11 @@ VIRTUAL_HWDataForIndex(int device_index)
|
||||
return vjoy;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
VIRTUAL_FreeHWData(joystick_hwdata *hwdata)
|
||||
static void VIRTUAL_FreeHWData(joystick_hwdata *hwdata)
|
||||
{
|
||||
joystick_hwdata * cur = g_VJoys;
|
||||
joystick_hwdata * prev = NULL;
|
||||
|
||||
joystick_hwdata *cur = g_VJoys;
|
||||
joystick_hwdata *prev = NULL;
|
||||
|
||||
if (hwdata == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -94,9 +89,7 @@ VIRTUAL_FreeHWData(joystick_hwdata *hwdata)
|
||||
SDL_free(hwdata);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc)
|
||||
int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc)
|
||||
{
|
||||
joystick_hwdata *hwdata = NULL;
|
||||
int device_index = -1;
|
||||
@@ -161,7 +154,7 @@ SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc)
|
||||
int i, axis;
|
||||
|
||||
if (hwdata->desc.button_mask == 0) {
|
||||
for (i = 0; i < hwdata->desc.nbuttons && i < sizeof(hwdata->desc.button_mask)*8; ++i) {
|
||||
for (i = 0; i < hwdata->desc.nbuttons && i < sizeof(hwdata->desc.button_mask) * 8; ++i) {
|
||||
hwdata->desc.button_mask |= (1 << i);
|
||||
}
|
||||
}
|
||||
@@ -247,9 +240,7 @@ SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc)
|
||||
return device_index;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_JoystickDetachVirtualInner(int device_index)
|
||||
int SDL_JoystickDetachVirtualInner(int device_index)
|
||||
{
|
||||
SDL_JoystickID instance_id;
|
||||
joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
|
||||
@@ -262,9 +253,7 @@ SDL_JoystickDetachVirtualInner(int device_index)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value)
|
||||
int SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value)
|
||||
{
|
||||
joystick_hwdata *hwdata;
|
||||
|
||||
@@ -287,9 +276,7 @@ SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 value)
|
||||
int SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 value)
|
||||
{
|
||||
joystick_hwdata *hwdata;
|
||||
|
||||
@@ -312,9 +299,7 @@ SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 valu
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value)
|
||||
int SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value)
|
||||
{
|
||||
joystick_hwdata *hwdata;
|
||||
|
||||
@@ -337,16 +322,12 @@ SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
VIRTUAL_JoystickInit(void)
|
||||
static int VIRTUAL_JoystickInit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
VIRTUAL_JoystickGetCount(void)
|
||||
static int VIRTUAL_JoystickGetCount(void)
|
||||
{
|
||||
int count = 0;
|
||||
joystick_hwdata *cur = g_VJoys;
|
||||
@@ -357,15 +338,11 @@ VIRTUAL_JoystickGetCount(void)
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
VIRTUAL_JoystickDetect(void)
|
||||
static void VIRTUAL_JoystickDetect(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
VIRTUAL_JoystickGetDeviceName(int device_index)
|
||||
static const char *VIRTUAL_JoystickGetDeviceName(int device_index)
|
||||
{
|
||||
joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
|
||||
if (hwdata == NULL) {
|
||||
@@ -374,23 +351,17 @@ VIRTUAL_JoystickGetDeviceName(int device_index)
|
||||
return hwdata->name;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
VIRTUAL_JoystickGetDevicePath(int device_index)
|
||||
static const char *VIRTUAL_JoystickGetDevicePath(int device_index)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
VIRTUAL_JoystickGetDevicePlayerIndex(int device_index)
|
||||
static int VIRTUAL_JoystickGetDevicePlayerIndex(int device_index)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_index)
|
||||
static void VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_index)
|
||||
{
|
||||
joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
|
||||
|
||||
@@ -399,9 +370,7 @@ VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_index)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static SDL_JoystickGUID
|
||||
VIRTUAL_JoystickGetDeviceGUID(int device_index)
|
||||
static SDL_JoystickGUID VIRTUAL_JoystickGetDeviceGUID(int device_index)
|
||||
{
|
||||
joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
|
||||
if (hwdata == NULL) {
|
||||
@@ -412,9 +381,7 @@ VIRTUAL_JoystickGetDeviceGUID(int device_index)
|
||||
return hwdata->guid;
|
||||
}
|
||||
|
||||
|
||||
static SDL_JoystickID
|
||||
VIRTUAL_JoystickGetDeviceInstanceID(int device_index)
|
||||
static SDL_JoystickID VIRTUAL_JoystickGetDeviceInstanceID(int device_index)
|
||||
{
|
||||
joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
|
||||
if (hwdata == NULL) {
|
||||
@@ -423,9 +390,7 @@ VIRTUAL_JoystickGetDeviceInstanceID(int device_index)
|
||||
return hwdata->instance_id;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
static int VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
{
|
||||
joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
|
||||
if (hwdata == NULL) {
|
||||
@@ -440,9 +405,7 @@ VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
VIRTUAL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
|
||||
static int VIRTUAL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
|
||||
{
|
||||
int result;
|
||||
|
||||
@@ -460,8 +423,7 @@ VIRTUAL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
VIRTUAL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
|
||||
static int VIRTUAL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
|
||||
{
|
||||
int result;
|
||||
|
||||
@@ -479,9 +441,7 @@ VIRTUAL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static Uint32
|
||||
VIRTUAL_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
static Uint32 VIRTUAL_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
joystick_hwdata *hwdata = joystick->hwdata;
|
||||
Uint32 caps = 0;
|
||||
@@ -500,9 +460,7 @@ VIRTUAL_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
return caps;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
VIRTUAL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
static int VIRTUAL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
{
|
||||
int result;
|
||||
|
||||
@@ -520,8 +478,7 @@ VIRTUAL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blu
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
VIRTUAL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size)
|
||||
static int VIRTUAL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size)
|
||||
{
|
||||
int result;
|
||||
|
||||
@@ -539,15 +496,12 @@ VIRTUAL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size)
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
VIRTUAL_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
|
||||
static int VIRTUAL_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
VIRTUAL_JoystickUpdate(SDL_Joystick *joystick)
|
||||
static void VIRTUAL_JoystickUpdate(SDL_Joystick *joystick)
|
||||
{
|
||||
joystick_hwdata *hwdata;
|
||||
int i;
|
||||
@@ -576,9 +530,7 @@ VIRTUAL_JoystickUpdate(SDL_Joystick *joystick)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
VIRTUAL_JoystickClose(SDL_Joystick *joystick)
|
||||
static void VIRTUAL_JoystickClose(SDL_Joystick *joystick)
|
||||
{
|
||||
if (joystick->hwdata) {
|
||||
joystick_hwdata *hwdata = joystick->hwdata;
|
||||
@@ -587,17 +539,14 @@ VIRTUAL_JoystickClose(SDL_Joystick *joystick)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
VIRTUAL_JoystickQuit(void)
|
||||
static void VIRTUAL_JoystickQuit(void)
|
||||
{
|
||||
while (g_VJoys) {
|
||||
VIRTUAL_FreeHWData(g_VJoys);
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
||||
static SDL_bool VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
||||
{
|
||||
joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
|
||||
int current_button = 0;
|
||||
@@ -740,8 +689,7 @@ VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver =
|
||||
{
|
||||
SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver = {
|
||||
VIRTUAL_JoystickInit,
|
||||
VIRTUAL_JoystickGetCount,
|
||||
VIRTUAL_JoystickDetect,
|
||||
|
Reference in New Issue
Block a user