Last active
August 29, 2015 14:10
-
-
Save 2bbb/d85e39c34232abbf1a97 to your computer and use it in GitHub Desktop.
PS3 Controller parser for Max
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| autocompile = true; | |
| outlets = 2; | |
| var Controller = { | |
| Buttons: { | |
| Push: { | |
| x: 19, a: 20, b: 21, y: 22, | |
| top: 11, right: 12, bottom: 13, left: 14, | |
| l1: 17, r1: 18, l2: 15, r2: 16, | |
| select: 7, start: 10, ps: 23 | |
| }, | |
| Pressure: { | |
| x: 43, a: 44, b: 45, y: 46, | |
| top: 35, right: 36, bottom: 37, left: 38, | |
| l1: 41, r1: 42, l2: 39, r2: 40 | |
| } | |
| }, | |
| Dualshock: { | |
| Left: { | |
| horizontal: 26, | |
| vertical: 27, | |
| click: 8 | |
| }, | |
| Right: { | |
| horizontal: 28, | |
| vertical: 29, | |
| click: 9 | |
| } | |
| }, | |
| Motion: { | |
| Accel: { | |
| x: 63, | |
| y: 65, | |
| z: 67 | |
| }, | |
| Gyro: { | |
| x: 62, | |
| y: 64, | |
| z: 66 | |
| } | |
| } | |
| } | |
| var convertId = function(x) { return x; }, | |
| convertToggle = function(x) { return x * 255; }, | |
| convert7bit = function(x) { return x >> 1; }; | |
| var Buttons = Controller.Buttons, | |
| Dualshock = Controller.Dualshock, | |
| Motion = Controller.Motion, | |
| OSCAdderss = {}, | |
| Convert = {}, | |
| PS3Map = {}; | |
| // **** **** | |
| OSCAdderss[Buttons.Push.x] = "/buttons/push/x"; | |
| OSCAdderss[Buttons.Push.a] = "/buttons/push/a"; | |
| OSCAdderss[Buttons.Push.b] = "/buttons/push/b"; | |
| OSCAdderss[Buttons.Push.y] = "/buttons/push/y"; | |
| OSCAdderss[Buttons.Push.top] = "/buttons/push/top"; | |
| OSCAdderss[Buttons.Push.right] = "/buttons/push/right"; | |
| OSCAdderss[Buttons.Push.bottom] = "/buttons/push/bottom"; | |
| OSCAdderss[Buttons.Push.left] = "/buttons/push/left"; | |
| OSCAdderss[Buttons.Push.l1] = "/buttons/push/l1"; | |
| OSCAdderss[Buttons.Push.r1] = "/buttons/push/r1"; | |
| OSCAdderss[Buttons.Push.l2] = "/buttons/push/l2"; | |
| OSCAdderss[Buttons.Push.r2] = "/buttons/push/r2"; | |
| OSCAdderss[Buttons.Push.select] = "/buttons/push/select"; | |
| OSCAdderss[Buttons.Push.start] = "/buttons/push/start"; | |
| OSCAdderss[Buttons.Push.ps] = "/buttons/push/ps"; | |
| OSCAdderss[Buttons.Pressure.x] = "/buttons/pressure/x"; | |
| OSCAdderss[Buttons.Pressure.a] = "/buttons/pressure/a"; | |
| OSCAdderss[Buttons.Pressure.b] = "/buttons/pressure/b"; | |
| OSCAdderss[Buttons.Pressure.y] = "/buttons/pressure/y"; | |
| OSCAdderss[Buttons.Pressure.top] = "/buttons/pressure/top"; | |
| OSCAdderss[Buttons.Pressure.right] = "/buttons/pressure/right"; | |
| OSCAdderss[Buttons.Pressure.bottom] = "/buttons/pressure/bottom"; | |
| OSCAdderss[Buttons.Pressure.left] = "/buttons/pressure/left"; | |
| OSCAdderss[Buttons.Pressure.l1] = "/buttons/pressure/l1"; | |
| OSCAdderss[Buttons.Pressure.r1] = "/buttons/pressure/r1"; | |
| OSCAdderss[Buttons.Pressure.l2] = "/buttons/pressure/l2"; | |
| OSCAdderss[Buttons.Pressure.r2] = "/buttons/pressure/r2"; | |
| OSCAdderss[Dualshock.Left.horizontal] = "/dualshock/left/horizontal"; | |
| OSCAdderss[Dualshock.Left.vertical] = "/dualshock/left/vertical"; | |
| OSCAdderss[Dualshock.Left.click] = "/dualshock/left/click"; | |
| OSCAdderss[Dualshock.Right.horizontal] = "/dualshock/right/horizontal"; | |
| OSCAdderss[Dualshock.Right.vertical] = "/dualshock/right/vertical"; | |
| OSCAdderss[Dualshock.Right.click] = "/dualshock/right/click"; | |
| OSCAdderss[Motion.Accel.x] = "/motion/accel/x"; | |
| OSCAdderss[Motion.Accel.y] = "/motion/accel/y"; | |
| OSCAdderss[Motion.Accel.z] = "/motion/accel/z"; | |
| OSCAdderss[Motion.Gyro.x] = "/motion/gyro/x"; | |
| OSCAdderss[Motion.Gyro.y] = "/motion/gyro/y"; | |
| OSCAdderss[Motion.Gyro.z] = "/motion/gyro/z"; | |
| // **** **** | |
| Convert[Buttons.Push.x] = convertToggle; | |
| Convert[Buttons.Push.a] = convertToggle; | |
| Convert[Buttons.Push.b] = convertToggle; | |
| Convert[Buttons.Push.y] = convertToggle; | |
| Convert[Buttons.Push.top] = convertToggle; | |
| Convert[Buttons.Push.right] = convertToggle; | |
| Convert[Buttons.Push.bottom] = convertToggle; | |
| Convert[Buttons.Push.left] = convertToggle; | |
| Convert[Buttons.Push.l1] = convertToggle; | |
| Convert[Buttons.Push.r1] = convertToggle; | |
| Convert[Buttons.Push.l2] = convertToggle; | |
| Convert[Buttons.Push.r2] = convertToggle; | |
| Convert[Buttons.Push.select] = convertToggle; | |
| Convert[Buttons.Push.start] = convertToggle; | |
| Convert[Buttons.Push.ps] = convertToggle; | |
| Convert[Buttons.Pressure.x] = convert7bit; | |
| Convert[Buttons.Pressure.a] = convert7bit; | |
| Convert[Buttons.Pressure.b] = convert7bit; | |
| Convert[Buttons.Pressure.y] = convert7bit; | |
| Convert[Buttons.Pressure.top] = convert7bit; | |
| Convert[Buttons.Pressure.right] = convert7bit; | |
| Convert[Buttons.Pressure.bottom] = convert7bit; | |
| Convert[Buttons.Pressure.left] = convert7bit; | |
| Convert[Buttons.Pressure.l1] = convert7bit; | |
| Convert[Buttons.Pressure.r1] = convert7bit; | |
| Convert[Buttons.Pressure.l2] = convert7bit; | |
| Convert[Buttons.Pressure.r2] = convert7bit; | |
| Convert[Dualshock.Left.horizontal] = convert7bit; | |
| Convert[Dualshock.Left.vertical] = convert7bit; | |
| Convert[Dualshock.Left.click] = convertToggle; | |
| Convert[Dualshock.Right.horizontal] = convert7bit; | |
| Convert[Dualshock.Right.vertical] = convert7bit; | |
| Convert[Dualshock.Right.click] = convertToggle; | |
| Convert[Motion.Accel.x] = convert7bit; | |
| Convert[Motion.Accel.y] = convert7bit; | |
| Convert[Motion.Accel.z] = convert7bit; | |
| Convert[Motion.Gyro.x] = convertId; | |
| Convert[Motion.Gyro.y] = convertId; | |
| Convert[Motion.Gyro.z] = convertId; | |
| // **** **** | |
| PS3Map[Buttons.Push.x] = 19; | |
| PS3Map[Buttons.Push.a] = 20; | |
| PS3Map[Buttons.Push.b] = 21; | |
| PS3Map[Buttons.Push.y] = 22; | |
| PS3Map[Buttons.Push.top] = 11; | |
| PS3Map[Buttons.Push.right] = 12; | |
| PS3Map[Buttons.Push.bottom] = 13; | |
| PS3Map[Buttons.Push.left] = 14; | |
| PS3Map[Buttons.Push.l1] = 17; | |
| PS3Map[Buttons.Push.r1] = 18; | |
| PS3Map[Buttons.Push.l2] = 15; | |
| PS3Map[Buttons.Push.r2] = 16; | |
| PS3Map[Buttons.Push.select] = 7; | |
| PS3Map[Buttons.Push.start] = 10; | |
| PS3Map[Buttons.Push.ps] = 23; | |
| PS3Map[Buttons.Pressure.x] = 43; | |
| PS3Map[Buttons.Pressure.a] = 44; | |
| PS3Map[Buttons.Pressure.b] = 45; | |
| PS3Map[Buttons.Pressure.y] = 46; | |
| PS3Map[Buttons.Pressure.top] = 35; | |
| PS3Map[Buttons.Pressure.right] = 36; | |
| PS3Map[Buttons.Pressure.bottom] = 37; | |
| PS3Map[Buttons.Pressure.left] = 38; | |
| PS3Map[Buttons.Pressure.l1] = 41; | |
| PS3Map[Buttons.Pressure.r1] = 42; | |
| PS3Map[Buttons.Pressure.l2] = 39; | |
| PS3Map[Buttons.Pressure.r2] = 40; | |
| PS3Map[Dualshock.Left.horizontal] = 26; | |
| PS3Map[Dualshock.Left.vertical] = 27; | |
| PS3Map[Dualshock.Left.click] = 8; | |
| PS3Map[Dualshock.Right.horizontal] = 28; | |
| PS3Map[Dualshock.Right.vertical] = 29; | |
| PS3Map[Dualshock.Right.click] = 9; | |
| PS3Map[Motion.Accel.x] = 63; | |
| PS3Map[Motion.Accel.y] = 65; | |
| PS3Map[Motion.Accel.z] = 67; | |
| PS3Map[Motion.Gyro.x] = 62; | |
| PS3Map[Motion.Gyro.y] = 64; | |
| PS3Map[Motion.Gyro.z] = 66; | |
| function ps3(address, value) { | |
| if(address == 30 || address == 69 || address == 56 || address == 54) { | |
| } else { | |
| outlet(0, 177, PS3Map[address], Convert[address](value)); | |
| outlet(1, OSCAdderss[address], value); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment