Skip to content

Misc cleanup and improvements for src/joystick/hidapi/SDL_report_descriptor.c#15959

Open
ao2 wants to merge 8 commits into
libsdl-org:mainfrom
ao2:wip/ao2/task957-prepare
Open

Misc cleanup and improvements for src/joystick/hidapi/SDL_report_descriptor.c#15959
ao2 wants to merge 8 commits into
libsdl-org:mainfrom
ao2:wip/ao2/task957-prepare

Conversation

@ao2

@ao2 ao2 commented Jul 8, 2026

Copy link
Copy Markdown

Hi,

here are some cleanups and improvements for src/joystick/hidapi/SDL_report_descriptor.c in preparation for future changes.

cc @smcv

The size of the HID report descriptors in the SDL_COMPILE_TIME_ASSERT
checks is specified sometimes in decimal and sometimes in octal.

Always used decimal for consistency.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
@ao2

ao2 commented Jul 8, 2026

Copy link
Copy Markdown
Author

I took the SDL_DYNAMIC_API hack in 992d47d from test/testevdev.c, but apparently this breaks build with msbuild (https://github.com/ao2/SDL/actions/runs/28957779597/job/85921577553#step:44:401) with the following error:

 (ClCompile target) -> 
         D:\a\SDL\SDL\src\joystick\hidapi\SDL_report_descriptor.c(31,9): error C2220: the following warning is treated as an error [D:\a\SDL\SDL\VisualC\SDL\SDL.vcxproj]
         D:\a\SDL\SDL\src\joystick\hidapi\SDL_report_descriptor.c(47,1): error C1020: unexpected #endif [D:\a\SDL\SDL\VisualC\SDL\SDL.vcxproj]

And I have no idea how to solve it.

@slouken slouken added this to the 3.x milestone Jul 8, 2026
ao2 added 7 commits July 9, 2026 11:20
Unconditionally include "SDL_internal.h" for robustness, since it's
needed in any case for embedding SDL's internal API aftre disabling
SDL_DYNAMIC_API, as per the Hacks libsdl-org#1-libsdl-org#3 at the top of the file.

Also include "SDL_internal.h" without prepending src/ because
add_sdl_test_executable(... BUILD_DEPENDENT ...) already adds src/ to
the include path.

Do the same for "dynapi/SDL_dynapi.h".

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
Add support for building SDL_report_descriptor as an executable to make
it easier to experiment with HID report descriptor parsing.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
Fix compiler warning:

-----------------------------------------------------------------------
.../src/joystick/hidapi/SDL_report_descriptor.c:621:17: warning: unused variable ‘file’ [-Wunused-variable]
  621 |     const char *file = argv[1];
      |                 ^~~~
-----------------------------------------------------------------------

Use the declared variable.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
For correctness clean up the descriptor parsing context before exiting,
even though this is not a problem in practice for a standalone
executable.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
Fix some ignored return values resulting in incomplete error checking.

For instance:

  - ParseMainItem() was always returning true because the return value of
    AddInputFields() was not handled.

  - ParseLocalItem() was always returning true because the return value of
    AddUsage() was not handled.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
This gives some more coverage when launching the executable.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
@ao2 ao2 force-pushed the wip/ao2/task957-prepare branch from bebc7b1 to 037f2f5 Compare July 9, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants