Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude HIDAPI support on iOS to avoid CoreBluetooth references #188

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ jobs:
with:
submodules: true

- name: Disable CoreBluetooth
run: echo "#define SDL_HIDAPI_DISABLED 1" >> External/SDL/include/build_config/SDL_build_config_ios.h

- name: Build (iOS)
run: xcodebuild -project External/SDL/Xcode/SDL/SDL.xcodeproj -target SDL3.xcframework -configuration Release

Expand Down
26 changes: 26 additions & 0 deletions SDL3-CS/SDL3/ClangSharp/SDL_hidapi.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ 3. This notice may not be removed or altered from any source distribution.

using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

namespace SDL
{
[UnsupportedOSPlatform("iOS")]
public partial struct SDL_hid_device
{
}

[UnsupportedOSPlatform("iOS")]
public enum SDL_hid_bus_type
{
SDL_HID_API_BUS_UNKNOWN = 0x00,
Expand All @@ -41,6 +44,7 @@ public enum SDL_hid_bus_type
SDL_HID_API_BUS_SPI = 0x04,
}

[UnsupportedOSPlatform("iOS")]
public unsafe partial struct SDL_hid_device_info
{
[NativeTypeName("char *")]
Expand Down Expand Up @@ -87,70 +91,92 @@ public unsafe partial struct SDL_hid_device_info
public static unsafe partial class SDL3
{
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_init();

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_exit();

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("Uint32")]
[UnsupportedOSPlatform("iOS")]
public static extern uint SDL_hid_device_change_count();

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern SDL_hid_device_info* SDL_hid_enumerate([NativeTypeName("unsigned short")] ushort vendor_id, [NativeTypeName("unsigned short")] ushort product_id);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern void SDL_hid_free_enumeration(SDL_hid_device_info* devs);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern SDL_hid_device* SDL_hid_open([NativeTypeName("unsigned short")] ushort vendor_id, [NativeTypeName("unsigned short")] ushort product_id, [NativeTypeName("const wchar_t *")] IntPtr serial_number);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern SDL_hid_device* SDL_hid_open_path([NativeTypeName("const char *")] byte* path);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_write(SDL_hid_device* dev, [NativeTypeName("const unsigned char *")] byte* data, [NativeTypeName("size_t")] nuint length);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_read_timeout(SDL_hid_device* dev, [NativeTypeName("unsigned char *")] byte* data, [NativeTypeName("size_t")] nuint length, int milliseconds);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_read(SDL_hid_device* dev, [NativeTypeName("unsigned char *")] byte* data, [NativeTypeName("size_t")] nuint length);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_set_nonblocking(SDL_hid_device* dev, int nonblock);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_send_feature_report(SDL_hid_device* dev, [NativeTypeName("const unsigned char *")] byte* data, [NativeTypeName("size_t")] nuint length);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_get_feature_report(SDL_hid_device* dev, [NativeTypeName("unsigned char *")] byte* data, [NativeTypeName("size_t")] nuint length);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_get_input_report(SDL_hid_device* dev, [NativeTypeName("unsigned char *")] byte* data, [NativeTypeName("size_t")] nuint length);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_close(SDL_hid_device* dev);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_get_manufacturer_string(SDL_hid_device* dev, [NativeTypeName("wchar_t *")] IntPtr @string, [NativeTypeName("size_t")] nuint maxlen);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_get_product_string(SDL_hid_device* dev, [NativeTypeName("wchar_t *")] IntPtr @string, [NativeTypeName("size_t")] nuint maxlen);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_get_serial_number_string(SDL_hid_device* dev, [NativeTypeName("wchar_t *")] IntPtr @string, [NativeTypeName("size_t")] nuint maxlen);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_get_indexed_string(SDL_hid_device* dev, int string_index, [NativeTypeName("wchar_t *")] IntPtr @string, [NativeTypeName("size_t")] nuint maxlen);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern SDL_hid_device_info* SDL_hid_get_device_info(SDL_hid_device* dev);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern int SDL_hid_get_report_descriptor(SDL_hid_device* dev, [NativeTypeName("unsigned char *")] byte* buf, [NativeTypeName("size_t")] nuint buf_size);

[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[UnsupportedOSPlatform("iOS")]
public static extern void SDL_hid_ble_scan([NativeTypeName("bool")] SDLBool active);
}
}
35 changes: 35 additions & 0 deletions SDL3-CS/SDL3/SDL_hidapi.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,38 @@
# ClangSharp recommended remapping
--remap
SDL_hid_device_=SDL_hid_device

# iOS builds opt out of HIDAPI
--with-using
# the SDL_CreateThread symbol name doesn't matter, it just needs to be any symbol defined in SDL_hidapi.h
SDL_hid_device=System.Runtime.Versioning
# The wildcard '*' is supposed to be used here but it's currently broken in the tool
# See: https://github.com/dotnet/ClangSharp/pull/567
# --with-attribute
# *=UnsupportedOSPlatform("iOS")
--with-attribute
SDL_hid_device=UnsupportedOSPlatform("iOS")
SDL_hid_bus_type=UnsupportedOSPlatform("iOS")
SDL_hid_device_info=UnsupportedOSPlatform("iOS")
SDL_hid_init=UnsupportedOSPlatform("iOS")
SDL_hid_exit=UnsupportedOSPlatform("iOS")
SDL_hid_device_change_count=UnsupportedOSPlatform("iOS")
SDL_hid_enumerate=UnsupportedOSPlatform("iOS")
SDL_hid_free_enumeration=UnsupportedOSPlatform("iOS")
SDL_hid_open=UnsupportedOSPlatform("iOS")
SDL_hid_open_path=UnsupportedOSPlatform("iOS")
SDL_hid_write=UnsupportedOSPlatform("iOS")
SDL_hid_read_timeout=UnsupportedOSPlatform("iOS")
SDL_hid_read=UnsupportedOSPlatform("iOS")
SDL_hid_set_nonblocking=UnsupportedOSPlatform("iOS")
SDL_hid_send_feature_report=UnsupportedOSPlatform("iOS")
SDL_hid_get_feature_report=UnsupportedOSPlatform("iOS")
SDL_hid_get_input_report=UnsupportedOSPlatform("iOS")
SDL_hid_close=UnsupportedOSPlatform("iOS")
SDL_hid_get_manufacturer_string=UnsupportedOSPlatform("iOS")
SDL_hid_get_product_string=UnsupportedOSPlatform("iOS")
SDL_hid_get_serial_number_string=UnsupportedOSPlatform("iOS")
SDL_hid_get_indexed_string=UnsupportedOSPlatform("iOS")
SDL_hid_get_device_info=UnsupportedOSPlatform("iOS")
SDL_hid_get_report_descriptor=UnsupportedOSPlatform("iOS")
SDL_hid_ble_scan=UnsupportedOSPlatform("iOS")