Skip to content

Control Query Language

Max Krieger edited this page Dec 8, 2016 · 13 revisions

To keep control mappings clean, we opted for a centralized way to query for the values of your given gamepad control. This allows us to easily reconfigure control mappings by just changing a string. We can also monopolize all inputs if we want to simulate their playback or debounce them. The structure is very simple:

<Shift?><Control><Gamepad #>

  • Shift - an optional ^ character to add to the beginning to check for the set button assigned to shift.
  • Control - the control we are querying for. Different controls detailed below.
  • Gamepad # - in a standard FTC game, there are two gamepads. We want to query one of them. It can either be 1 or 2. If you want a control to be available for both gamepads, instead use the wildcard-copilot operator, *, as in Y*, but this currently only works for buttons.

##Example

To check whether both Shift and A are being pressed on Gamepad 1, your query would be:

^A1

##Controls

Human Legacy CQL Returns
button a a A boolean
button b b B boolean
button x x X boolean
button y y Y boolean
button back back BK boolean
button start start ST boolean
button guide (the logitech logo) guide GD boolean
dpad down dpad_down DD boolean
dpad left dpad_left DL boolean
dpad right dpad_right DR boolean
dpad up dpad_up DU boolean
left bumper left_bumper LB boolean
right bumper right_bumper RB boolean
left trigger left_trigger LT ArrayList<float> [Float y] or boolean (works as button)
right trigger right_trigger RT ArrayList<float> [Float y] or boolean (works as button)
right stick button right_stick_button RSB boolean
left stick button left_stick_button LSB boolean
right stick x and y right_stick_x, right_stick_y RS ArrayList<float> [Float x, Float y]
left stick x and y left_stick_x, left_stick_y LS ArrayList<float> [Float x, Float y]

##ControlParser

CQL's use is available as ControlParser, which is wired already to the controllers. For float-related controls, you call ControlParser.range("MYQUERY"). For bool-related controls, call ControlParser.button("MYQUERY");. The shift key is assigned in the ControlParser's constructor.

Clone this wiki locally