Input Syntax: Difference between revisions

From Dolphin Emulator Wiki
Jump to navigation Jump to search
No edit summary
 
(16 intermediate revisions by 3 users not shown)
Line 1: Line 1:
As a follow-up by right-clicking the button in GameCube, Wiimote, and Hotkey configuration windows, this page explains how to properly assign multiple input and combination of each command in hotkey and controller configuration window.
This page explains how to properly assign multiple controls (inputs or outputs) and the control expression syntax in the input configuration dialogs.


== Assignment Buttons ==
== Window Buttons ==
When opening Configuring Controller window the text cursor will be placed on beginning of lines in small text field.


{| class="wikitable"
{| class="wikitable"
|-
|-
! ''Detect''
! ''Detect''
| It will automatically highlight the selected input in the list which can save your time looking through there. It will wait for input from the selected device in '''Device''' dropdown for 3 seconds.
| Wait for input from the selected device, and highlight the corresponding input in the list.
|-
|-
! ''Select''
! ''Select''
| Assigns the selected input from the list to the current text cursor location in small text field.
| Copy the selected input name into the control expression field.
|-
|-
! ''| OR''
! ''Operator''
| Similar to '''''Select''''', adds "<var> &#124; </var>" before a selected input. Input parameter with '''''&#124; OR''''' can trigger the same command independently. Differences between this and '''''+ ADD''''' unknown.
| Contains a list of mathematical operators.
* Syntax error when selected first.
|-
|-
! ''& AND''
! ''Functions''
| Similar to '''''Select''''', adds "<var> & </var>" before a selected input. Input parameter with '''''& AND''''' will wait for the last input parameter to active to trigger the command.
| Contains a list of functions.
* Syntax error when selected first.
|-
! ''! NOT''
| Similar to '''''Select''''', adds "<var>!</var>" before a selected input. Input parameter with '''''! NOT''''' will disable the next input parameter so that input will not trigger the current command.
* This is one confusing part, requires additional combination and/or manual editing in the text field. Check the [[#Using ! NOT|#! NOT]] example in next section.
|-
! ''+ ADD''
| Similar to '''''Select''''', adds "<var> + </var>" before a selected input.  Input parameter with '''''+ ADD''''' can trigger the same command independently. Differences between this and '''''&#124; OR''''' unknown.
* Syntax error when selected first.
|}
|}


== Parentheses ==
== Syntax ==
Using '''''()''''' parentheses can group input parameters together and thus can solve '''''& AND''''' troubles.


{|
{| class="wikitable"
|- style="vertical-align: text-top;"
|-
| width=50%| The first two parameters don't work.
! scope="col" | Token
<pre>`Pad W` & `Button X` | `Pad E` & `Button B`</pre>
! scope="col" | Explanation
| width=50%| However using parentheses can solve this.
! scope="col" | Example usage
<pre>(`Pad W` & `Button X`) | (`Pad E` & `Button B`)</pre>
|-----------
! ''`''
| The backtick is used in cases where the expression is ambiguous.
| <code>Button 1</code> results in a syntax error, because the expression is ambiguous.
Adding backticks around the button name makes it able to be parsed correctly: <code>`Button 1`</code>
|-----------
! ''(''
| The left parenthesis is used to open an expression group.
| rowspan="2" | <code>(`Button 1` & `Button 2`) | `Button 3`</code>
The virtual controller button will be pressed if both Button 1 and Button 2 are pressed, and/or Button 3 is pressed.
|-----------
! '')''
| The right parenthesis is used to close an expression group.
|-----------
! '':''
| The LHS is used as the device name, and the RHS is used as the control name. The whole expression may need to be wrapped around backticks so it parses correctly.
| <code>`evdev/0/Device:Button 0`</code>
The virtual controller button will be pressed if Button 0 (from device "evdev/0/Device") is pressed.
|-----------
|}
|}


== Parameter Examples ==
This is personalized input combination for Fullscreen in hotkey setting. The first parameter is for Guide (Big "X") button on Xbox 360 controller and the final parameters are for Alt + Enter key combination on keyboard. Both devices can trigger Fullscreen.
<pre>Guide | `DInput/0/Keyboard Mouse:RMENU` & `DInput/0/Keyboard Mouse:RETURN`</pre>


=== Using ! NOT ===
=== Operators ===
{|
 
|- style="vertical-align: text-top;"
{| class="wikitable"
| width=50%| Command will always active unless this input is triggered.
<pre>!`Pad W`</pre>
| width=50%| Command will active when Button X is pressed, but it won't be triggered when Pad W is also pressed.
<pre>!`Pad W` & `Button X`</pre>
|-
|-
| width=50%| The first two parameters will not work anymore. [[#Parentheses]] can help.
! scope="col" | Token
<pre>!`Pad W` & `Button X` &#124; !`Pad E` & `Button B`</pre>
! scope="col" | Explanation
| width=50%| This will work too.
! scope="col" | Example usage
<pre>`Button X` & !`Pad W` &#124; `Button B` & !`Pad E`</pre>
|-----------
! ''&#124;''
| The expression is true if the left-hand side (LHS) or the right-hand side (RHS) are true. (This is not an exclusive OR.)
Technically, this is implemented by taking the smaller of the LHS and RHS.
| <code>`Button 1` &#124; `Button 2`</code>
The virtual controller button will be pressed if and only if Button 1 and/or Button 2 are pressed.
|-----------
! ''^''
| The expression is true if the LHS or the RHS is true. (This is an exclusive OR.)
| <code>`Button 1` ^ `Button 2`</code>
The virtual controller button will be pressed if and only if Button 1 or Button 2 is pressed.
|-----------
! ''&amp;''
| The expression is true if both the LHS and the RHS are true.
Technically, this is implemented by taking the greater of the LHS and RHS.
| <code>`Button 1` &amp; `Button 2`</code>
The virtual controller button will be pressed if and only if both Button 1 and Button 2 are pressed.
|-----------
! ''!''
| Negates the following expression's value.
Technically, this is implemented by subtracting the value from 1.
| <code>!`Button 1`</code>
The virtual controller button will be pressed if and only if Button 1 is not pressed.
|-----------
! ''+''
| Sums up the LHS value and the RHS value.
| <code>`Axis 1+` + `Axis 2+`</code>
|-----------
! ''-''
| Subtracts the RHS value from the LHS value.
| <code>`Axis 1+` - `Axis 2+`</code>
|-----------
! ''*''
| Multiplies LHS value and the RHS value.
| <code>`Axis 1+` * `Axis 2+`</code>
|-----------
! ''/''
| Divides the LHS value by the RHS value.
| <code>`Axis 1+` / `Axis 2+`</code>
|-----------
! ''%''
| Gives the value of LHS value modulos RHS value.
This means that the remainder of LHS value divided by RHS value is given.
| <code>`Axis 1+` % `Axis 2+`</code>
|-----------
! ''>''
| The expression is true if the LHS value is bigger than the RHS value.
| <code>`Axis 1+` > `Axis 2+`</code>
|-----------
! ''<''
| The expression is true if the LHS value is smaller than the RHS value.
| <code>`Axis 1+` < `Axis 2+`</code>
|-----------
|}
|}


[[Category:Tutorials]]
[[Category:Tutorials]]

Latest revision as of 18:25, 1 June 2020

This page explains how to properly assign multiple controls (inputs or outputs) and the control expression syntax in the input configuration dialogs.

Window Buttons

Detect Wait for input from the selected device, and highlight the corresponding input in the list.
Select Copy the selected input name into the control expression field.
Operator Contains a list of mathematical operators.
Functions Contains a list of functions.

Syntax

Token Explanation Example usage
` The backtick is used in cases where the expression is ambiguous. Button 1 results in a syntax error, because the expression is ambiguous.

Adding backticks around the button name makes it able to be parsed correctly: `Button 1`

( The left parenthesis is used to open an expression group. (`Button 1` & `Button 2`) | `Button 3`

The virtual controller button will be pressed if both Button 1 and Button 2 are pressed, and/or Button 3 is pressed.

) The right parenthesis is used to close an expression group.
: The LHS is used as the device name, and the RHS is used as the control name. The whole expression may need to be wrapped around backticks so it parses correctly. `evdev/0/Device:Button 0`

The virtual controller button will be pressed if Button 0 (from device "evdev/0/Device") is pressed.


Operators

Token Explanation Example usage
| The expression is true if the left-hand side (LHS) or the right-hand side (RHS) are true. (This is not an exclusive OR.)

Technically, this is implemented by taking the smaller of the LHS and RHS.

`Button 1` | `Button 2`

The virtual controller button will be pressed if and only if Button 1 and/or Button 2 are pressed.

^ The expression is true if the LHS or the RHS is true. (This is an exclusive OR.) `Button 1` ^ `Button 2`

The virtual controller button will be pressed if and only if Button 1 or Button 2 is pressed.

& The expression is true if both the LHS and the RHS are true.

Technically, this is implemented by taking the greater of the LHS and RHS.

`Button 1` & `Button 2`

The virtual controller button will be pressed if and only if both Button 1 and Button 2 are pressed.

! Negates the following expression's value.

Technically, this is implemented by subtracting the value from 1.

!`Button 1`

The virtual controller button will be pressed if and only if Button 1 is not pressed.

+ Sums up the LHS value and the RHS value. `Axis 1+` + `Axis 2+`
- Subtracts the RHS value from the LHS value. `Axis 1+` - `Axis 2+`
* Multiplies LHS value and the RHS value. `Axis 1+` * `Axis 2+`
/ Divides the LHS value by the RHS value. `Axis 1+` / `Axis 2+`
% Gives the value of LHS value modulos RHS value.

This means that the remainder of LHS value divided by RHS value is given.

`Axis 1+` % `Axis 2+`
> The expression is true if the LHS value is bigger than the RHS value. `Axis 1+` > `Axis 2+`
< The expression is true if the LHS value is smaller than the RHS value. `Axis 1+` < `Axis 2+`