Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traktor S3: Fix mapping crash on macOS #12840

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions res/controllers/Traktor-Kontrol-S3-hid-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,16 @@ TraktorS3.Controller = class {
engine.makeConnection(ch, "end_of_track",
TraktorS3.Channel.prototype.endOfTrackHandler.bind(chanob));
}
// Set each InputReport to the bitwise inverted state first,
// and than apply the non-inverted initial state.
// This is done, because the common-hid-packet-parser only triggers
// the callback functions in case of a delta to the previous data.
for (let inputReportIdx = 0x01; inputReportIdx <= 0x02; ++inputReportIdx) {
const reportData = new Uint8Array(controller.getInputReport(inputReportIdx));

// Query the current values from the controller and set them. The packet
// parser ignores the first time a value is set, so we'll need to set it
// with different values once. Report 2 contains the state of the mixer
// controls.
const report2Values = new Uint8Array(controller.getInputReport(2));
TraktorS3.incomingData(new Uint8Array([2, ...Uint8Array.from(report2Values.map(x => ~x))]));
TraktorS3.incomingData(new Uint8Array([2, ...Uint8Array.from(report2Values)]));

// Report 1 is the state of the deck controls. These shouldn't have any
// initial effect, and most of these values will be 0 anyways. We'll
// just tell the packet parser the current values so it won't ignore the
// next input.
const report1Values = new Uint8Array(controller.getInputReport(1));
TraktorS3.incomingData(new Uint8Array([1, ...Uint8Array.from(report1Values)]));
TraktorS3.incomingData([inputReportIdx, ...reportData.map(x => ~x)]);
TraktorS3.incomingData([inputReportIdx, ...reportData]);
}

// NOTE: Soft takeovers must only be enabled after setting the initial
// value, or the above line won't have any effect
Expand Down
Loading