Skip to content

Commit 433e7da

Browse files
Merge pull request #93 from suve/add-sdlhidapi.inc
Add sdlhidapi.inc
2 parents f933108 + 6f4c532 commit 433e7da

File tree

3 files changed

+464
-1
lines changed

3 files changed

+464
-1
lines changed

units/ctypes.inc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ type
4444
cuint16 = Word;
4545
{$EXTERNALSYM cuint16}
4646

47+
pcushort = ^cushort;
48+
cushort = Word;
49+
{$EXTERNALSYM cushort}
50+
4751
pcint32 = ^cint32;
4852
cint32 = LongInt;
4953
{$EXTERNALSYM cint32}
@@ -124,3 +128,31 @@ type
124128

125129
ppcuint8 = ^pcuint8;
126130

131+
{$IFDEF WANT_CWCHAR_T}
132+
(* wchar_t is the "wide character" type of the C language.
133+
* The size of this type is platform- and compiler-dependent.
134+
*
135+
* While FPC does have it's own "wide character" type, System.WideChar,
136+
* that one is defined as always being 16-bits, so we can't re-use it here.
137+
*
138+
* When using FPC on Unices, the UnixType unit provides a wchar_t definition.
139+
*
140+
* On other systems/compiler combos, let's just go
141+
* by what the CPP reference wiki claims, i.e:
142+
* - wchar_t is 16-bits on Windows
143+
* - wchar_t is 32-bits on Linux "and many other non-Windows systems"
144+
*
145+
* See: https://en.cppreference.com/w/cpp/language/types#Character_types
146+
*)
147+
{$IF DEFINED(FPC) AND DEFINED(UNIX)}
148+
cwchar_t = UnixType.wchar_t;
149+
{$ELSE}
150+
{$IF DEFINED(WIN32) OR DEFINED(WIN64)}
151+
cwchar_t = cuint16;
152+
{$ELSE}
153+
cwchar_t = cuint32;
154+
{$ENDIF}
155+
{$ENDIF}
156+
{$EXTERNALSYM cwchar_t}
157+
pcwchar_t = ^cwchar_t;
158+
{$ENDIF}

units/sdl2.pas

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ interface
107107
uses
108108
{$IFDEF FPC}
109109
ctypes,
110+
UnixType,
110111
{$ENDIF}
111112
{$IFDEF DARWIN}
112113
CocoaAll;
@@ -118,7 +119,8 @@ interface
118119

119120
{$IF DEFINED(UNIX) AND DEFINED(ANDROID) AND DEFINED(FPC)}
120121
uses
121-
ctypes;
122+
ctypes,
123+
UnixType;
122124
{$ENDIF}
123125

124126
const
@@ -151,6 +153,7 @@ interface
151153
{$ENDIF}
152154

153155

156+
{$DEFINE WANT_CWCHAR_T}
154157
{$I ctypes.inc} // C data types
155158

156159
{SDL2 version of the represented header file}
@@ -184,6 +187,7 @@ interface
184187
{$I sdlsensor.inc} // 2.26.0
185188
{$I sdlgamecontroller.inc} // 2.24.0
186189
{$I sdlhaptic.inc}
190+
{$I sdlhidapi.inc} // 2.0.18
187191
{$I sdltouch.inc} // 2.24.0
188192
{$I sdlgesture.inc}
189193
{$I sdlsyswm.inc}

0 commit comments

Comments
 (0)