User Tools

Site Tools


en:tutorials:input:mouse_grab

Mouse Grab

You might notice on emulators and some games that use mouse movement, that the mouse is locked into the window or play area. The movement while contrained within the game window but the movement is able to continue infinitely in any direction.

You can then usually press a predefined key combo to free it from the application window so that items on the desktop can be accessed again.

Your player will get annoyed after a while and give the game away.

Orx lets you perform mouse grabbing and mouse releasing.

Let's try this out on a standard project. First, make your project.

Setting up a new project

To help you work through this tutorial, first create a new blank project using the init script.

Windowify the project

To demo this feature, we will change it from full screen to a smaller window, and make key presses that both grab and release the mouse.

First, change the config to make the full screen into a window, change the Decorations property under the [Display] section:

[Display]
...
Decoration      = false

Then specify a screen size. The entire [Display] section should look like this:

[Display]
Title           = mousegrab
FullScreen      = false
Decoration      = true
Smoothing       = true
VSync           = true
ScreenWidth	= 800
ScreenHeight	= 600

Compile and run. You'll see a demo application with the spinning Orx logo in a window.

Setting up rotation based on the mouse

Let's set up rotation of the Orx Logo based on the movement of the mouse.

We can do this with a couple of commands in

en/tutorials/input/mouse_grab.txt · Last modified: 2025/09/30 17:26 (9 months ago) by 127.0.0.1