---
name: "SDL_MouseMotionEvent"
section: "3"
platform: "linux"
package: "libsdl1.2-dev"
version: "1.2.15+dfsg2-8"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_MouseMotionEvent"
---

# SDL\_MouseMotionEvent(3)

Mouse motion event structure

## NAME

SDL\_MouseMotionEvent - Mouse motion event structure

## STRUCTURE DEFINITION

```
typedef struct{
  Uint8 type;
  Uint8 state;
  Uint16 x, y;
  Sint16 xrel, yrel;
} SDL_MouseMotionEvent;
```

## STRUCTURE DATA

- **type**

  **SDL\_MOUSEMOTION**

- **state**

  The current button state

- **x**, **y**

  The X/Y coordinates of the mouse

- **xrel**, **yrel**

  Relative motion in the X/Y direction

## DESCRIPTION

**SDL\_MouseMotionEvent** is a member of the **SDL\_Event** union and is used when an event of type **SDL\_MOUSEMOTION** is reported.

Simply put, a **SDL\_MOUSEMOTION** type event occurs when a user moves the mouse within the application window or when **SDL\_WarpMouse** is called. Both the absolute (**x** and **y**) and relative (**xrel** and **yrel**) coordinates are reported along with the current button states (**state**). The button state can be interpreted using the **SDL\_BUTTON** macro (see **SDL\_GetMouseState**).

If the cursor is hidden (**SDL\_ShowCursor***(0)*) and the input is grabbed (**SDL\_WM\_GrabInput***(SDL\_GRAB\_ON)*), then the mouse will give relative motion events even when the cursor reaches the edge fo the screen. This is currently only implemented on Windows and Linux/Unix-a-likes.

## SEE ALSO

**SDL\_Event**, **SDL\_MouseButtonEvent**
