Skip to content

Commit

Permalink
Update Functions-(Config).md
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Oct 15, 2024
1 parent 5d2835b commit 7a3264f
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions docs/10.0/Functions-(Config).md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,21 @@ Input also ships with a small piece of logic that changes the default bindings w
|`defaultKbmBinding` |binding |Default binding to use when the player is using a keyboard and mouse|
|`defaultGamepadBinding`|binding |Default binding to use when the player is using a gamepad |
This function defines a verb within Input. You should provide two sets of bindings - one that is the default binding when the player is using a keyboard and mouse (`INPUT_DEVICE_KBM`) and another for when the player is using a gamepad. Bindings should be specified using the `gp_*` constants for gamepads and the `vk_*` and `mb_*` constants for keyboards. Additionally, you may specify keyboard letter bindings using single character strings e.g. `"A"`.
You can specify multiple bindings for a verb by using an array. In this case, bindings will fill up the "alternate" binding slots for a verb. If you give one binding for a verb then it will fill binding slot 0. Please see the Examples tab for a demonstration.
The `exportName` parameter sets the name of this verb when exporting bindings. Export names should be unique (no two verbs may share the same export name).
!> Once you have decided on an export name for a verb **you must never change it**. Doing so will invalidate any bindings that have been saved by your players.
#### **Example**
```gml
// The "jump" verb is triggered by the spacebar or the A button on an Xbox gamepad
InputDefineVerb(INPUT_VERB.JUMP, "jump", vk_space, gp_face1);
// The "up" verb is triggered by either the up arrow key or the W key, or the left thumbstick or dpad on a gamepad.
InputDefineVerb(INPUT_VERB.UP, "up", [vk_up, "W"], [-gp_axislv, gp_padu]);
```

Expand All @@ -93,6 +105,10 @@ InputDefineVerb(INPUT_VERB.UP, "up", [vk_up, "W"], [-gp_axislv, gp_padu]);
|`verbDown` |integer |Verb to indicate down (negative y) movement |
|`verbLeft` |integer |Verb to indicate left (negative x) movement |

This function defines verb clusters - there are groups of verbs that combine to give an x and y axis of motion. Clusters are a way of generalising keyboard input, thumbstick input, and dpad input into one interface. Clusters can be used with functions like `InputDirection()` and `InputX()` etc.

?> No, I'm not sure why the parameters are ordered this way either.

#### **Example**

```gml
Expand All @@ -107,8 +123,30 @@ InputDefineCluster(INPUT_CLUSTER.NAVIGATION, INPUT_VERB.UP, INPUT_VERB.RIGHT, IN
Adding a new verb is a two step process:
1. Add the new verb to the `INPUT_VERB` enum in `__InputConfigVerbs`
1. Add the new verb to the `INPUT_VERB` enum in `__InputConfigVerbs`.
2. Call `InputDefineVerb()` in `__InputConfigVerbs` to set up a default binding for the verb.
If you want to use a verb in a cluster, you'll need to add that verb to the cluster by calling `InputDefineCluster()`.
If you want to use a verb in a cluster, you'll need to add that verb to the cluster by calling `InputDefineCluster()`. And that's it! Once you've added a verb then you'll be able to use that verb wherever you want in your game.
A few points to consider:
- Verbs can share the same binding (e.g. two verbs bound to `vk_space`) but this may cause problems when rebinding controls. Generally, we recommend trying to stick to one binding to one verb if possible.
- Once you decide on an export name (see `InputDefineVerb` function documentation above) you **should never change it**. If you change the export name then any bindings that you have saved to a file run the risk of becoming corrupted.
- Additionally, two verbs cannot share the same export name.
- There is a minor performance penalty for each verb you add to your game. If any verbs are unused, we recommend that you remove them to squeeze a little more performance out of your game.
 
## `__InputConfig`
This script is simpler than `__InputConfigVerbs` - it is a list of macros that can be edited to adjust how the library behaves.
### `INPUT_MAX_PLAYERS`
_Typical value:_ `1`
The maximum number of players that your game supports.

0 comments on commit 7a3264f

Please sign in to comment.