/****************************************************************/
/* Traktor Kontrol S2 MK2 HID controller script */
/* Copyright (C) 2020, Be <be@mixxx.org> */
/* Copyright (C) 2017, douteiful */
/* Based on: */
/* Traktor Kontrol S4 MK2 HID controller script v1.00 */
/* Copyright (C) 2015, the Mixxx Team */
/* but feel free to tweak this to your heart's content! */
/****************************************************************/
// ==== Friendly User Configuration ====
// The Cue button, when Shift is also held, can have two possible functions:
// 1. "REWIND": seeks to the very start of the track.
// 2. "REVERSEROLL": performs a temporary reverse or "censor" effect, where the track
// is momentarily played in reverse until the button is released.
var ShiftCueButtonAction = "REWIND";
// Set the brightness of button LEDs which are off and on. This uses a scale from 0 to 0x7f (127).
// If you don't have the optional power adapter and are using the controller with USB bus power,
// 0x09 is probably too dim to notice.
var ButtonBrightnessOff = 0x01;
var ButtonBrightnessOn = 0x7f;
// KNOWN ISSUES:
// * The effect button LEDs briefly flicker when pressing the effect focus button.
// eslint definitions
/* global controller, HIDController, HIDPacket */
var TraktorS2MK2 = new function() {
this.controller = new HIDController();
// When true, packets will not be sent to the controller.
// Used when updating multiple LEDs simultaneously.
this.batchingLEDUpdate = false;
// Previous values, used for calculating deltas for encoder knobs.
this.previousBrowse = 0;
this.previousPregain = {
"[Channel1]": 0,
"[Channel2]": 0
};
this.previousLeftEncoder = {
"[Channel1]": 0,
"[Channel2]": 0
};
this.previousRightEncoder = {
"[Channel1]": 0,
"[Channel2]": 0
};
this.wheelTouchInertiaTimer = {
"[Channel1]": 0,
"[Channel2]": 0
};
this.topEncoderPressed = {
"[Channel1]": false,
"[Channel2]": false
};
this.leftEncoderPressed = {
"[Channel1]": false,
"[Channel2]": false
};
this.shiftPressed = {
"[Channel1]":