Skip to content

Commit

Permalink
Adds input method docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Dec 6, 2023
1 parent c3e59de commit 84cfeef
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions latest/iotaclock.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,56 @@ As above, but the value is interpolated as an angle measured in degrees. The out



<details><summary><code>.DefineInput(inputName, defaultValue)</code></summary>
&nbsp;

**Returns:** N/A (`undefined`)

|Name |Datatype |Purpose |
|------------|---------|-----------------------------------|
|inputName |string |Name of the input to define |
|defaultValue|any |Default value of the input if unset|

Adds a named input to the clock. This should be used to funnel user input into the clock. Defined inputs should be set using the `.SetInput()` method (see below) and can be read in a clock cycle method using `IotaGetInput()`. `.DefineInput()` should be used for "continuous" values such as those returned by `keyboard_check()` or `gamepad_axis_value()` or `mouse_x`.

&nbsp;
</details>

<details><summary><code>.DefineInputMomentary(inputName, defaultValue)</code></summary>
&nbsp;

**Returns:** N/A (`undefined`)

|Name |Datatype |Purpose |
|------------|---------|-----------------------------------|
|inputName |string |Name of the input to define |
|defaultValue|any |Default value of the input if unset|

See above for the general purpose for this method. `.DefineInputMomentary()` additionally marks an input as "momentary" which does two things:

1. Momentary input values are reset to their defaults at the end of the first cycle per tick.
2. Momentary input values are treated differently when setting values using `.SetInput().` See below for more information.

&nbsp;
</details>

<details><summary><code>.SetInput(inputName, value)</code></summary>
&nbsp;

**Returns:** N/A (`undefined`)

|Name Datatype |Purpose |
|------------------|--------------------------|
|inputNamestring |Name of the input to set |
|value any |Value to set for the input|

Sets the value of an input defined using one of the two prior methods. For non-momentary "continuous" inputs, `.SetInput()` will simply set the value of the input as you'd expect. However, if an input has been defined as "momentary" then a value will only be set if it is different to the default value for the input. This means that, once set to a different value, an input cannot be reset to the default. This solves problems with dropped inputs when the application framerate is significantly higher than the clock update frequency.

&nbsp;
</details>



<details><summary><code>.AddAlarm(milliseconds, method)</code></summary>
&nbsp;

Expand Down

0 comments on commit 84cfeef

Please # to comment.