Skip to content

Instantly share code, notes, and snippets.

@decklin
Last active August 29, 2015 14:10
Show Gist options
  • Save decklin/7e50cc3cd20eb087f006 to your computer and use it in GitHub Desktop.
Save decklin/7e50cc3cd20eb087f006 to your computer and use it in GitHub Desktop.
GriffinPowerMate.registerInputPackets = function() {
// The PowerMate only sends one kind of packet, which is 6 bytes:
//
// - Byte 0: pushed (0 or 1). Updates immediately on push or release.
//
// - Byte 1: turn (signed 8-bit value). +1 or -1 for every 3 degrees
// or so of rotation. May require turning a few degrees before you
// get to the next "tick" (there are no physical detents; the motion
// is very smooth). If you turn very quickly, a single packet will
// be sent with value of greater magnitude (2 ticks = -2 or +2, etc;
// I can get it to go up to about 7). If you turn consistently,
// several identical packets will be sent, so we need to take care
// to not coalesce "unchanged" values.
//
// - Bytes 2-5: always the same values (0x00, 0x4F, 0x10, 0x00).
// Perhaps some kind of device identifer magic. Ignored.
var packet = new HIDPacket('control', [], 6);
packet.addControl('knob', 'push', 0, 'B', 0x01);
packet.addControl('knob', 'turn', 1, 'b');
// WARNING: Need to hack common script to make this have an effect.
// Pull request sent in at https://github.com/mixxxdj/mixxx/pull/406
packet.setMinDelta('knob', 'turn', undefined);
this.controller.registerInputPacket(packet);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment