/usr/share/mixxx/controllers/common-hid-devices.js is in mixxx-data 2.0.0~dfsg-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | // Generic HID trackpad implementation
function HIDTrackpadDevice() {
this.controller = new HIDController();
this.registerInputPackets = function() {
// Example how to register a callback directly on a packet
packet = new HIDPacket("control",[],4,this.mouseInput);
packet.addControl("hid","byte_1",3,"B");
packet.addControl("hid","byte_2",4,"B");
packet.addControl("hid","byte_3",5,"B");
packet.addControl("hid","byte_4",6,"B");
this.controller.registerInputPacket(packet);
}
// HID trackpads have no output controls
this.registerOutputPackets = function() { }
// No need to do scaling for keyboard presses
this.registerScalers = function() { }
// No need for callbacks here, we bound whole input packet to mouseInput
this.registerCallbacks = function() { }
// Example to process the mouse input packet all yourself
this.mouseInput = function(packet,delta) {
HIDDebug("Trackpad INPUT " + packet.name);
if (!delta.length) {
HIDDebug("No changed data received in HID packet");
return;
}
for (var field_name in delta) {
var field = delta[field_name];
HIDDebug("FIELD " + field.id + " VALUE " + value);
}
}
}
// Generic HID keyboard implementation
function HIDKeyboardDevice() {
this.controller = new HIDController();
this.registerInputPackets = function() {
packet = new HIDPacket("control",[0x1,0x0,0x0],9);
packet.addControl("hid","keycode_1",3,"B");
packet.addControl("hid","keycode_2",4,"B");
packet.addControl("hid","keycode_3",5,"B");
packet.addControl("hid","keycode_4",6,"B");
packet.addControl("hid","keycode_5",7,"B");
packet.addControl("hid","keycode_6",8,"B");
this.controller.registerInputPacket(packet);
}
// HID keyboards have no output controls
this.registerOutputPackets = function() { }
// No need to do scaling for keyboard presses
this.registerScalers = function() { }
// Example to bind the bytes to a callback
this.registerCallbacks = function() {
this.controller.setCallback("control","hid","keycode_1",this.keyPress);
this.controller.setCallback("control","hid","keycode_2",this.keyPress);
this.controller.setCallback("control","hid","keycode_3",this.keyPress);
this.controller.setCallback("control","hid","keycode_4",this.keyPress);
this.controller.setCallback("control","hid","keycode_5",this.keyPress);
this.controller.setCallback("control","hid","keycode_6",this.keyPress);
}
// Example to do something with the keycodes received
this.keyPress = function(field) {
if (field.value!=0)
HIDDebug("KEY PRESS " + field.id + " CODE " + field.value);
else
HIDDebug("KEY RELEASE " + field.id);
}
}
|