Skip to content

Commit

Permalink
Added timestamp to platform events.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomspilman committed Aug 24, 2024
1 parent 3af0aae commit ccd6e48
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
13 changes: 8 additions & 5 deletions MonoGame.Framework/Platform/Native/Platform.Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,24 @@ internal struct MGP_Event
public EventType Type;

[FieldOffset(4)]
public ulong Timestamp;

[FieldOffset(12)]
public MGP_KeyEvent Key;

[FieldOffset(4)]
[FieldOffset(12)]
public MGP_MouseMoveEvent MouseMove;

[FieldOffset(4)]
[FieldOffset(12)]
public MGP_MouseButtonEvent MouseButton;

[FieldOffset(4)]
[FieldOffset(12)]
public MGP_MouseWheelEvent MouseWheel;

[FieldOffset(4)]
[FieldOffset(12)]
public MGP_DropEvent Drop;

[FieldOffset(4)]
[FieldOffset(12)]
public MGP_WindowEvent Window;

}
Expand Down
13 changes: 7 additions & 6 deletions src/monogame/include/csharp_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,13 @@ struct MGP_Event
{
union {
MGEventType Type;
MG_FIELD_OFFSET(4, MGP_KeyEvent, Key);
MG_FIELD_OFFSET(4, MGP_MouseMoveEvent, MouseMove);
MG_FIELD_OFFSET(4, MGP_MouseButtonEvent, MouseButton);
MG_FIELD_OFFSET(4, MGP_MouseWheelEvent, MouseWheel);
MG_FIELD_OFFSET(4, MGP_DropEvent, Drop);
MG_FIELD_OFFSET(4, MGP_WindowEvent, Window);
MG_FIELD_OFFSET(4, mgulong, Timestamp);
MG_FIELD_OFFSET(12, MGP_KeyEvent, Key);
MG_FIELD_OFFSET(12, MGP_MouseMoveEvent, MouseMove);
MG_FIELD_OFFSET(12, MGP_MouseButtonEvent, MouseButton);
MG_FIELD_OFFSET(12, MGP_MouseWheelEvent, MouseWheel);
MG_FIELD_OFFSET(12, MGP_DropEvent, Drop);
MG_FIELD_OFFSET(12, MGP_WindowEvent, Window);
};
};
#pragma pack(pop)
Expand Down
2 changes: 2 additions & 0 deletions src/monogame/sdl/MGP_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ mgbool MGP_Platform_PollEvent(MGP_Platform* platform, MGP_Event& event_)

while (SDL_PollEvent(&ev) == 1)
{
event_.Timestamp = SDL_GetTicks64();

switch (ev.type)
{
case SDL_QUIT:
Expand Down

0 comments on commit ccd6e48

Please sign in to comment.