//
//  remapGameControls.js
//
//  Created by Alexia Mandeville on 3/6/2018
//  Copyright 2018 High Fidelity, Inc.
//
//  Distributed under the Apache License, Version 2.0.
//  See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//

// This script updates the control scheme for keyboard navigation.
// If you want to change any of the mappings, you can use our API reference for input devices here: 
// https://docs.highfidelity.com/api-reference/namespaces/controller

// The name of the new mapping
var MAPPING_NAME = "com.highfidelity.controllers.remapGameControls";

// Create a new mapping object
var mapping = Controller.newMapping(MAPPING_NAME);

// *Remap* //

// Let's put jump and upfly on E...
mapping.from(Controller.Hardware.Keyboard.E).to(Controller.Actions.Up);

// and map downfly to C.
mapping.from(Controller.Hardware.Keyboard.C).to(Controller.Actions.Down);

// *The next two mappings include modifiers!* //

// Remap Shift + W to pitch the camera up.
mapping.from(Controller.Hardware.Keyboard.W).when(Controller.Hardware.Keyboard.Shift).to(Controller.Actions.PitchUp);

// Remap Shift + S to pitch the camera down.
mapping.from(Controller.Hardware.Keyboard.S).when(Controller.Hardware.Keyboard.Shift).to(Controller.Actions.PitchDown);

// Enable the new mapping.
Controller.enableMapping(MAPPING_NAME);

// Disable the new mapping when the script ends.
Script.scriptEnding.connect(function () {
    Controller.disableMapping(MAPPING_NAME);
});