---
name: "SDL_AppEvent"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_AppEvent"
---

# SDL\_AppEvent(3)

App-implemented event entry point for SDL\_MAIN\_USE\_CALLBACKS apps.

## NAME

SDL\_AppEvent - App-implemented event entry point for  **SDL\_MAIN\_USE\_CALLBACKS**\
  apps.

## HEADER FILE

Defined in SDL3/SDL\_main.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**SDL\_AppResult SDL\_AppEvent(void \*appstate, SDL\_Event \*event);**

## DESCRIPTION

Apps implement this function when using

**SDL\_MAIN\_USE\_CALLBACKS** . If using a standard "main" function, you should not supply this.

This function is called as needed by SDL after  **SDL\_AppInit**

returns  **SDL\_APP\_CONTINUE** . It is called once for each new event.

There is (currently) no guarantee about what thread this will be called from; whatever thread pushes an event onto SDL's queue will trigger this function. SDL is responsible for pumping the event queue between each call to  **SDL\_AppIterate** , so in normal operation one should only get events in a serial fashion, but be careful if you have a thread that explicitly calls  **SDL\_PushEvent** . SDL itself will push events to the queue on the main thread.

Events sent to this function are not owned by the app; if you need to save the data, you should copy it.

This function should not go into an infinite mainloop; it should handle the provided event appropriately and return.

The **appstate** parameter is an optional pointer provided by the app during

**SDL\_AppInit** (). If the app never provided a pointer, this will be NULL.

If this function returns  **SDL\_APP\_CONTINUE** , the app will continue normal operation, receiving repeated calls to

**SDL\_AppIterate**\
  and  **SDL\_AppEvent**\
  for the life of the program. If this function returns

**SDL\_APP\_FAILURE** , SDL will call

**SDL\_AppQuit**\
  and terminate the process with an exit code that reports an error to the platform. If it returns

**SDL\_APP\_SUCCESS** , SDL calls  **SDL\_AppQuit**

and terminates with an exit code that reports success to the platform.

## FUNCTION PARAMETERS

- *appstate*

  an optional pointer, provided by the app in  **SDL\_AppInit** .

- *event*

  the new event for the app to examine.

## RETURN VALUE

( **SDL\_AppResult** ) Returns  **SDL\_APP\_FAILURE**

to terminate with an error,  **SDL\_APP\_SUCCESS**\
  to terminate with success,  **SDL\_APP\_CONTINUE**\
  to continue.

## THREAD SAFETY

This function may get called concurrently with

**SDL\_AppIterate** () or  **SDL\_AppQuit** () for events not pushed from the main thread.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_AppInit**(3)](/SDL_AppInit/3.md), **•**(3), [**SDL\_AppIterate**(3)](/SDL_AppIterate/3.md)
