This is a function "cheat sheet" for the Raw Input extension by YellowAfterlife.
The extension can be acquired via itch.io or GM Marketplace.
A most up-to-date version of the manual is always available online.

Click on sections to expand/collapse them.
Quick display controls: Categories · Sections · Everything ·

raw_input_init(?flags)ok?

Initializes the extension. This must be called before doing anything else.

flags are bit flags (added together via |) that indicate types of devices that the extension will poll:

  • raw_input_watch_hid_mice: HID devices that claim to be able to function as mice[1].
  • raw_input_watch_system_mouse: Prepends a virtual device (taking index 0) that will take input from any other devices - like the default system cursor does.
  • raw_input_watch_rdp_mice: Remote Desktop Protocol mice.
  • raw_input_watch_hid_keyboards: HID devices that claim to be keyboards.

If not specified, default value is raw_input_watch_hid_mice|raw_input_watch_hid_keyboards.

[1]: By which I mean - having virtual devices (which the user cannot control) isn't uncommon, so you should ideally require input/confirmation before assuming that they are in use.

raw_input_update()ok?

Should be called once per frame, ideally before using other functions (for lower latency).

This populates a GML-side data structure with fresh data from DLL and is used for rest of the functions.

The only case where this can fail and return false is if the DLL failed to load (which, in turn, most likely means that the file is missing).

Mouse functions

raw_mouse_get_count()

Returns the number of available mice.

raw_mouse_is_absolute(index)

Returns whether the given mouse is currently moving in "absolute" mode.

Absolute mice are usually non-mouse pointer devices (for example, a stylus on a graphic tablet) and will update coordinates slightly differently - instead of using screen pixels, coordinates range from 0 (top/left side of desktop) to 65536 (bottom/right side of desktop).

Switching "mouse mode" on a graphic tablet can result in the mouse switching between absolute and relative modes, so you should not assume this to be entirely constant.

raw_mouse_is_virtual_desktop(index)

Returns whether the given mouse had last reported to have MOUSE_VIRTUAL_DESKTOP tag.

I can't actually think of a good reason you'd care about this in a game, but it's there.

raw_mouse_get_device_name(index)

Returns a raw WinAPI device name for the given mouse.

This has the device GUID, but otherwise don't expect it to make any sense.

raw_mouse_x(index)

Returns absolute X coordinate for the given mouse. These are measured in screen pixels.

This is a convenience function and the coordinates are not clamped by default - you can do that yourself via raw_mouse_set.

raw_mouse_y(index)

Returns absolute Y coordinate for the given mouse. These are measured in screen pixels.

This is a convenience function and the coordinates are not clamped by default - you can do that yourself via raw_mouse_set.

raw_mouse_set_speed(index, multiplier)

Changes speed/sensitivity for the given mouse (only applies to relative mode). Default is 1.

You may want to let user customize this in-game, as mice can have wildly variying speeds.

raw_mouse_get_speed(index)

Returns the current speed/sensitivity of a mouse (see above).

raw_mouse_set(index, x, y)

Changes internal coordinates that are reported by raw_mouse_x / raw_mouse_y.

Usually you'll want to clamp these to window coordinates.

raw_mouse_delta_x(index)

Returns changes to X position of the given mouse since the last update.

raw_mouse_delta_y(index)

Returns changes to Y position of the given mouse since the last update.

raw_mouse_delta_z(index)

Returns the number of wheel "ticks" that the mouse scrolled by since the last update.

This is a bit more flexible than _wheel_up/_wheel_down for that reason.

The following act exactly like their built-in counter-parts:

Keyboard functions

raw_keyboard_get_count()

Returns the number of available keyboards.

The following act like their built-in counter-parts, except they use Virtual Key Codes like keyboard_check_direct does (so you need to check for vk_lshift or vk_rshift rather than just vk_shift):