Last active
December 22, 2021 15:23
-
-
Save tancredi/e6530a5a6a6e263589f44827ce5a5cd3 to your computer and use it in GitHub Desktop.
Griffin PowerMater as FX knob - Mixxx HID controller mappings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GPM = { friction: 10, deck: 0 }; | |
GPM.init = function (id) { | |
GPM.controller = new HIDController(); | |
GPM.id = id; | |
GPM.controller.activeDeck = 1; | |
GPM.registerInputPackets(); | |
GPM.registerOutputPackets(); | |
GPM.registerCallbacks(); | |
}; | |
GPM.shutdown = function () { | |
GPM.controller.close(); | |
}; | |
GPM.registerOutputPackets = function () { | |
const packet = new HIDPacket("out"); | |
packet.addControl("hid", "led", 0, "B"); | |
GPM.controller.registerOutputPacket(packet); | |
}; | |
GPM.registerInputPackets = function () { | |
const packet = new HIDPacket("control"); | |
packet.addControl("hid", "button", 0, "B", 0x01); | |
packet.addControl("hid", "wheel", 1, "b"); | |
packet.setMinDelta("hid", "wheel", undefined); | |
this.controller.registerInputPacket(packet); | |
}; | |
GPM.incomingData = function (data, length) { | |
GPM.controller.parsePacket(data, length); | |
}; | |
GPM.registerCallbacks = function (id) { | |
const controller = GPM.controller; | |
controller.setCallback("control", "hid", "button", GPM.button); | |
controller.setCallback("control", "hid", "wheel", GPM.wheel); | |
}; | |
GPM.toggleLED = function (on) { | |
const packet = GPM.controller.getOutputPacket("out"); | |
const field = packet.getField("hid", "led"); | |
field.value = on ? 255 : 0; | |
packet.send(); | |
}; | |
GPM.updateLED = function () { | |
GPM.toggleLED(GPM.deck === 0); | |
}; | |
GPM.changeDeck = function () { | |
GPM.deck = GPM.deck === 1 ? 0 : 1; | |
GPM.updateLED(); | |
}; | |
GPM.button = function (field) { | |
field.value === 1 && GPM.changeDeck(); | |
}; | |
GPM.getActiveFxID = function () { | |
const index = GPM.deck + 1; | |
return "[EffectRack1_EffectUnit" + index + "]"; | |
}; | |
GPM.wheel = function (field) { | |
const fxID = GPM.getActiveFxID(); | |
const current = engine.getValue(fxID, "mix"); | |
const shift = field.value / GPM.friction; | |
engine.setValue(fxID, "mix", current + shift); | |
field.value = 0; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='utf-8'?> | |
<MixxxControllerPreset schemaVersion="1" mixxxVersion="1.11+"> | |
<info> | |
<name>Griffin Powermate - FX knob</name> | |
<author>Tancredi Trugenberger</author> | |
<description>Griffin Powermate HID mapping to control the effects main knobs across 2 decks (press to change active deck)</description> | |
</info> | |
<controller id="Griffin"> | |
<scriptfiles> | |
<file filename="common-hid-packet-parser.js" functionprefix=""/> | |
<file filename="griffin-powermate-fx-knob.hid.js" functionprefix="GPM"/> | |
</scriptfiles> | |
</controller> | |
</MixxxControllerPreset> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment