FilGee, thanks to tutorial!
here's my script for Xbox360 joystick and EZX Metal Machine. All adjustable parameters are highlighted in a separate section.
Mapping on the picture:
Code:
/* Config for XBOX360 as Reaper Midi Joystick. 17.11.2013 */
// buttons (bitmask), numbuttons (valid bits in buttons)
// systime (time in seconds)
// axis(x), numaxis (number actually supported)
// pov(x), numpov, pov(x) > 360 if not pointing
// event(msg1,msg2,msg3) to send events
// memory map. don't change.
oldaxis = 100;
buttons_codes = 200;
buttons_notes = 300;
pov_codes = 400;
pov_notes = 500;
//********************* CONFIG (change here) ********************
buttons_count = 6;
buttons_codes[0] = $x4; /* blue X */ buttons_notes[0] = 42; // closed HH
buttons_codes[1] = $x1; /* green A */ buttons_notes[1] = 49; // Crash A
buttons_codes[2] = $x2; /* red B */ buttons_notes[2] = 57; // Crash B (Sustained)
buttons_codes[3] = $x8; /* yellow Y */ buttons_notes[3] = 46; // OpenHH
buttons_codes[4] = $x10;/* LB */ buttons_notes[4] = 36; // kick
buttons_codes[5] = $x20;/* RB */ buttons_notes[5] = 36; // kick
pov_count = 4;
pov_codes[0] = 0; /* up */ pov_notes[0] = 33; // Snare (left)
pov_codes[1] = 90; /* right */ pov_notes[1] = 43; // floorT head
pov_codes[2] = 180; /* down */ pov_notes[2] = 41; // floorT
pov_codes[3] = 270; /* left */ pov_notes[3] = 45; // Rack T2
//******************* END CONFIG ********************
hasrun ? (
(oldbuttons != buttons) ? (
i=0;
loop(buttons_count,
(buttons & buttons_codes[i]) != (oldbuttons & buttons_codes[i]) ? (
event($x90, buttons_notes[i], (buttons & buttons_codes[i]) ? 127 : 0);
);
i+=1;
);
); // button states
LT = axis(2);
oldaxis[2] != LT ? (
(abs(LT - oldLT) >= 0.4) ? (
event($x90, buttons_notes[4], 127);
oldLT = LT;
)
); // LT states
(oldpov != pov(0)) ? (
i=0;
loop(pov_count,
(pov(0) == pov_codes[i]) ? (
event($x90, pov_notes[i], (pov(0) < 360) ? 127 : 0);
);
i+=1;
);
); // pov states
) : hasrun=1;
oldbuttons = buttons;
oldaxis[2] = axis(2);
oldpov = pov(0);