Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
13 changes: 12 additions & 1 deletion units/SDL3.pas
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,16 @@ function SDL_CreateThreadWithProperties(props: TSDL_PropertiesID): PSDL_Thread;
SDL_CreateThreadWithProperties:=SDL_CreateThreadWithPropertiesRuntime(props,TSDL_FunctionPointer(SDL_BeginThreadFunction),TSDL_FunctionPointer(SDL_EndThreadFunction));
end;

end.
{ Macros from SDL_mouse.h }
function SDL_BUTTON_MASK(X: TSDL_MouseButtonFlags): TSDL_MouseButtonFlags;
begin
Result := TSDL_MouseButtonFlags(1) shl (X-1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add semicolon please.

end;

{ Macros from SDL_stdinc.h}
function SDL_FOURCC(A, B, C, D: AnsiChar): cuint32;
begin
Result := (cuint32(Ord(A)) shl 0) or (cuint32(Ord(B)) shl 8) or (cuint32(Ord(C)) shl 16) or (cuint32(Ord(D)) shl 24)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add semicolon please.

end;

end.
7 changes: 4 additions & 3 deletions units/SDL_mouse.inc
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,17 @@ type
PSDL_MouseButtonFlags = ^TSDL_MouseButtonFlags;
TSDL_MouseButtonFlags = type cuint32;

function SDL_BUTTON_MASK(X: TSDL_MouseButtonFlags): TSDL_MouseButtonFlags;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with the original code, this function should be right above SDL_BUTTON_LMASK. I would suggest to move it down and have the following structure:


function SDL_BUTTON_MASK(X: TSDL_MouseButtonFlags): TSDL_MouseButtonFlags;
{SDL3-for-Pascal: FPC does not allow assigning function results to consts,
                    so these values are calculated manually. }
const
  SDL_BUTTON_LMASK  = TSDL_MouseButtonFlags(1 shl SDL_BUTTON_LEFT-1);    { SDL_BUTTON_MASK(SDL_BUTTON_LEFT)  }


const
SDL_BUTTON_LEFT = TSDL_MouseButtonFlags(1);
SDL_BUTTON_MIDDLE = TSDL_MouseButtonFlags(2);
SDL_BUTTON_RIGHT = TSDL_MouseButtonFlags(3);
SDL_BUTTON_X1 = TSDL_MouseButtonFlags(4);
SDL_BUTTON_X2 = TSDL_MouseButtonFlags(5);

{SDL3-for-Pascal: The C macro SDL_BUTTON_MASK is not implemented but the mask
defines are directly translated. }
{#define SDL_BUTTON_MASK(X) (1u << ((X)-1)) }
{SDL3-for-Pascal: FPC does not allow assigning function results to consts,
so these values are calculated manually. }
SDL_BUTTON_LMASK = TSDL_MouseButtonFlags(1 shl SDL_BUTTON_LEFT-1); { SDL_BUTTON_MASK(SDL_BUTTON_LEFT) }
SDL_BUTTON_MMASK = TSDL_MouseButtonFlags(1 shl SDL_BUTTON_MIDDLE-1); { SDL_BUTTON_MASK(SDL_BUTTON_MIDDLE) }
SDL_BUTTON_RMASK = TSDL_MouseButtonFlags(1 shl SDL_BUTTON_RIGHT-1); { SDL_BUTTON_MASK(SDL_BUTTON_RIGHT) }
Expand Down
16 changes: 16 additions & 0 deletions units/SDL_stdinc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
SPDX-License-Identifier: Zlib
}

{*
* Define a four character code as a Uint32.
*
* \param A the first ASCII character.
* \param B the second ASCII character.
* \param C the third ASCII character.
* \param D the fourth ASCII character.
* \returns the four characters converted into a Uint32, one character
* per-byte.
*
* \threadsafety It is safe to call this macro from any thread.
*
* \since This macro is available since SDL 3.2.0.
*}
function SDL_FOURCC(A, B, C, D: AnsiChar): cuint32;

{*
* A signed 8-bit integer type.
*
Expand Down