diff --git a/res/controllers/Roland_DJ-505-scripts.js b/res/controllers/Roland_DJ-505-scripts.js
index da386d86ebe..a5fb3d4e751 100644
--- a/res/controllers/Roland_DJ-505-scripts.js
+++ b/res/controllers/Roland_DJ-505-scripts.js
@@ -227,7 +227,7 @@ DJ505.browseEncoder = new components.Encoder({
});
DJ505.backButton = new components.Button({
- // TODO: Map the BACK/SONG button
+ // TODO: Map the BACK button
midi: [0x9F, 0x07],
shiftOffset: 11,
sendShifted: true,
@@ -236,7 +236,6 @@ DJ505.backButton = new components.Button({
});
DJ505.addPrepareButton = new components.Button({
- // TODO: Map the ARTIST button
midi: [0x9F, 0x1B],
shiftOffset: -7,
sendShifted: true,
@@ -246,6 +245,33 @@ DJ505.addPrepareButton = new components.Button({
type: components.Button.prototype.types.toggle,
});
+
+DJ505.sortLibrary = function (channel, control, value, status, group) {
+ if (value === 0) {
+ return;
+ }
+
+ var sortColumn;
+ switch(control) {
+ case 0x12: // SONG
+ sortColumn = 1;
+ break;
+ case 0x13: // BPM
+ sortColumn = 14;
+ break;
+ case 0x14: // ARTIST
+ sortColumn = 0;
+ break;
+ case 0x1E: // KEY
+ sortColumn = 19;
+ break;
+ default:
+ // unknown sort column
+ return;
+ }
+ engine.setValue("[Library]", "sort_column_toggle", sortColumn);
+};
+
DJ505.crossfader = new components.Pot({
midi: [0xBF, 0x08],
group: "[Master]",
diff --git a/res/controllers/Roland_DJ-505.midi.xml b/res/controllers/Roland_DJ-505.midi.xml
index ebf7a5456dc..8331d6263bb 100644
--- a/res/controllers/Roland_DJ-505.midi.xml
+++ b/res/controllers/Roland_DJ-505.midi.xml
@@ -3343,9 +3343,9 @@
-
[Library]
DJ505.browseEncoder.input
@@ -3405,7 +3405,7 @@
[Library]
- DJ505.backButton.input
+ DJ505.sortLibrary
SONG
0x9F
0x12
@@ -3425,7 +3425,7 @@
[Library]
- DJ505.addPrepareButton.input
+ DJ505.sortLibrary
ARTIST
0x9F
0x14