Raquet / Wiki / v1x / Input

Input

Table of Contents

Avaliable Keys

 Due to my lack of knowledge on automation through python, currently, there are no Raquet Equivilants to the SDL input names. That doesn't matter much though, since you can just use the SDL input names. Specifically, you need to use the SDL_Scancode values from this list. These scancode values should all work perfectly fine with all Raquet_KeyCheck functions, and if they dont, send an issue on our github.

Input Check Types

 There are a few different ways to check for input in Raquet. The way they return information are all different, and can be useful in various scenarios.

 The basic Raquet_KeyCheck() will return 1 if the specified key is being pressed down. In contrast, the Raquet_KeyCheck_Pressed() will only return 1 for the first frame of a key being pressed, and will return 0 until the key is released and then pressed again. The semi-opposite of this, would be Raquet_KeyCheck_Released()Which will reutrn 0 until a key has been pressed, and then will return 1 on the first frame of the key being released.

 For example, if you want to have the player fire a bullet when they press the Z key, you would impliment something like the following:

if (Raquet_KeyCheck(SDL_SCANCODE_Z))
{
Create_Bullet();
}

 But this would end up creating a rapid-fire, like a minigun. To make it more like a pistol, where you have to press the button again every time you want to fire, you would use Raquet_KeyCheck_Pressed()

if (Raquet_KeyCheck_Pressed(SDL_SCANCODE_Z))
{
Create_Bullet();
}

 Lets say you wanted to have your gun charge up, and once you release the button, it shoots out based on your charge, you could do so with a combination of Raquet_KeyCheck() and Raquet_KeyCheck_Released()

if (Raquet_KeyCheck(SDL_SCANCODE_Z))
{
player.chargeup++

} else if (Raquet_KeyCheck_Released(SDL_SCANCODE_Z))
{
Create_Bullet(player.chargeup)
}

 Whether this is practical or not is up to the higher programmers (intellectuals), as I am just a babbling baby moron (doesn't know C++, only C).

Mouse Input

 Is the keyboard not good enough for you? Are you more of a mouse person? Do the curves of the wheely spinny thing make you swoon? Well don't worry, Raquet has Mouse Input Functions too! They're all Raquet_KeyCheck equivilants, so everything from above will apply here. There are 3 different buttons you can use in regards to the mouse: RAQUET_MOUSE_LEFT for the left button, RAQUET_MOUSE_MIDDLE for the scroll wheel, and RAQUET_MOUSE_RIGHT for the right button.

 Lets reuse an example from the Keyboard Section. If I want to create a bullet whenever I press the Left Mouse Button, I could do it like so:

if (Raquet_MouseCheck_Pressed(RAQUET_MOUSE_LEFT))
{
Create_Bullet();
}

Read the keyboard section for more information.

Hey: If you need more mouse support in our mouse button options, send us an issue on github!