Misc cleanup for src/joystick/hidapi/SDL_report_descriptor.c and new test program#15959
Misc cleanup for src/joystick/hidapi/SDL_report_descriptor.c and new test program#15959ao2 wants to merge 7 commits into
src/joystick/hidapi/SDL_report_descriptor.c and new test program#15959Conversation
|
I took the And I have no idea how to solve it. |
037f2f5 to
a84e078
Compare
|
The new version fixes, or rather avoids, the problems with msbuild. This should be ready for review. |
a84e078 to
937b67b
Compare
| dep_option(SDL_TESTS_LINK_SHARED "link tests to shared SDL library" "${SDL_SHARED}" "SDL_SHARED;SDL_STATIC" "${SDL_SHARED}") | ||
| set(SDL_TESTS_TIMEOUT_MULTIPLIER "1" CACHE STRING "Timeout multiplier to account for really slow machines") | ||
|
|
||
| dep_option(SDL_REPORT_DESCRIPTOR_EXE "Build SDL_report_descriptor as an executable" OFF "SDL_TESTS" OFF) |
There was a problem hiding this comment.
I'm wondering if this should be "testdescriptor" and just be part of the normally built tests?
There was a problem hiding this comment.
That would be fine by me, and I addressed this in the latest version.
Just noticing that the test is meant to accept a command line argument and will exit with a non-zero value if no arguments are passed.
But I guess we are good if this is not added by default to the automated test suite?
There was a problem hiding this comment.
Just noticing that the test is meant to accept a command line argument and will exit with a non-zero value if no arguments are passed.
But I guess we are good if this is not added by default to the automated test suite?
Yeah, that's fine.
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>
Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
937b67b to
6c99c26
Compare
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>
Add support for testing the SDL_report_descriptor code by adding a new executable to make it easier to experiment with HID report descriptor parsing. The main() function which originally was in src/joystick/hidapi/SDL_report_descriptor.c is moved to a separate file named test/testdescriptor.c in order to simplify dealing with multiple build systems. For instance if the main() was in src/joystick/hidapi/SDL_report_descriptor.c the code would have to account for the cases when the file is built as part of the library or when it's built as part of a standalone executable, in which case the dynamic API mechanism needs to be disabled. This would pose a problem especially with MSVC which uses pre-compiled headers (PCH) which do not sit well with the preprocessor logic that would be needed, like the hacks added in test/testevdev.c Using a completely separate source file for the standalone executable avoids the issue, especially considering that the new file is not built with MSVC at all. The new test program can be built with: cmake -DCMAKE_BUILD_TYPE=Debug -DSDL_TESTS=ON -S . -B build make -C testdescriptor Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
Fix compiler warning:
-----------------------------------------------------------------------
.../test/testdescriptor.c: In function ‘main’:
.../test/testdescriptor.c:56:17: warning: unused variable ‘file’ [-Wunused-variable]
56 | const char *file = argv[1];
| ^~~~
-----------------------------------------------------------------------
Use the `file` variable when appropriate since it is already declared
and assigned.
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>
This gives some more coverage when running the SDL_report_descriptor test program. Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
6c99c26 to
3befd1d
Compare
src/joystick/hidapi/SDL_report_descriptor.csrc/joystick/hidapi/SDL_report_descriptor.c and new test program
|
Building See https://github.com/ao2/SDL/actions/runs/29090880925/job/86399106802#step:33:741 This is because the code uses Maybe |
It's not a public API, feel free to change it. |
Hi,
here are some cleanups and improvements for
src/joystick/hidapi/SDL_report_descriptor.cin preparation for future changes.cc @smcv