The goal of this example is to demonstrate how to combine generic buttons to trigger multiple functions. This assumes that the reader is familiar with the basics of creating Building Blocks as shown in the Detailed Tutorial.
This is a fairly complex example that will use two buttons on the SteelSeries World of Warcraft: Cataclysm Gaming Mouse to trigger three functions. Two of the functions will occur when the buttons are pushed separately, and the third will occur when the buttons are pushed at the same time. The functions that will be triggered are OS X Finder commands that operate on the item that is currently under the cursor.
Trigger | Function |
---|---|
Button #7 | Get Info |
Button #10 | Open |
Button #7 + Button #10 | Move to Trash |
When configuring buttons to perform one function when pressed independently, and another function when pressed together, an important thing to remember is that two buttons are almost never pressed at exactly the same time. One button will usually be pressed shortly before the other. Therefore, a delay must be added before responding to a single button to allow time to determine if the second button will be pressed.
Once a button combination is detected, then the combined function needs to be performed. At the same time, the functions that the buttons would perform independently need to be inhibited.
Lastly, when the buttons are released, they are usually never released at exactly the same time. Therefore, it is necessary to prevent the buttons' independent functions from occurring until both buttons have been released.
To perform the "Get Info" function, two building blocks will be used. A Mouse Button block to select the file that is currently under the cursor and a Single Key block to perform Command-I to open the file info window.
To perform the "Open" function, a Mouse Button block will be used to double-click on the file that is currently under the cursor.
To perform the "Move to Trash" function, three building blocks will be used. A Mouse Button block to select the file that is currently under the cursor, a Delay block to wait 1.0s to prevent accidental deletes, and a Single Key block to perform Command-Backspace to move the file to the trash.
The full implementation of these functions is shown first, a description of each portion follows below.
In this solution, the ON/OFF Latch building block in the center controls whether the combined function occurs, or whether the individual functions occur. When the output of this block is turned ON, the function for the button combination is performed. When the output of this block is turned OFF, the individual button functions are permitted to occur.
The building blocks in the upper-left portion of the solution control when the ON/OFF Latch turns ON:
When either button is pressed on the mouse, the corresponding Button building block turns ON and triggers a Pulse building block. Each Pulse block will turn its output ON for 0.05s, then turn its output OFF. If the outputs of both Pulse building blocks are ON at the same time, then the mouse buttons must have been pressed within 0.05s of each other. When that occurs, the AND building block will turn its output ON.
When the AND block turns its output ON, it turns on the "ON" input of the ON/OFF Latch building block. That will cause the output of the ON/OFF Latch block to turn ON and trigger the "Move File to Trash" function.
Once the ON/OFF Latch block has turned its output ON, it will remain ON until the "OFF" input turns ON. Until that happens, none of the functions that these building blocks implement will occur. The building blocks in the upper-right portion control when the ON/OFF Latch turns OFF:
When both mouse buttons are released for 0.05s, the Delay building block will turn its output ON. When the Delay block turns ON, it will turn ON the "OFF" input of the ON/OFF Latch. That will cause the output of the ON/OFF Latch block to turn OFF.
Along with triggering the function performed by the button combination, the ON/OFF Latch also controls when the individual button functions are permitted to occur:
When the output of the ON/OFF Latch is ON (indicating that the combined function occurred), the NOT building block will turn its output OFF. This will turn OFF the "GATE" input of the ON/OFF Gate building blocks. While the "GATE" input is OFF, the output of the ON/OFF Gate blocks will remain OFF. This inhibits the individual button functions.
The values from the Button building blocks at the bottom of the solution are delayed 0.05s by the Delay building blocks. This allows time for the building blocks at the top of the solution to determine if a button combination occurs. If a button combination does not occur, and the ON/OFF Latch remains OFF, the delayed values from the Button blocks will pass through the ON/OFF Gate building blocks and trigger the individual functions.
To allow the individual functions to operate with very short taps on the mouse buttons, the Allow the delay to continue option must be selected for the lower two Delay building blocks.
Also, the ON/OFF Gate building blocks need to be configured such that their outputs will turn OFF when their "GATE" inputs turn off.
This solution can be customized by changing the time delays in the Delay and Pulse building blocks. Shorter times will make the individual buttons more sensitive, but will also require more accuracy when pressing the buttons at the same time. Longer times will permit less accuracy when pressing both buttons, but will make the individual buttons less sensitive.