Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to use Mathematica to illustrate mixed strategies in Game Theory. I want my students to be able to use common joysticks as controllers. What I find, however, is that in addition to doing what I want, moving one of the controls on my gamepad rotates the 3D graphics in such a way as to ruin the presentation. Basically, all I want the controls to do is change the strategy each player uses. The Graphics3D object should not rotate. Here's a very simplified of the code that illustrates the undesired behavior.

Column[{x, y, 
Show[Graphics3D[{Line[{{x, y, 0}, {x + 1, y + 1, 1}}]}, 
 Axes -> True, ImageSize -> 400], 
     Graphics3D[{Tube[{{x, y, 0}, {x - 1, x - y, 1}}]}]]}], 
"X1" -> {{x, 0.71}, 0, 1}, "Z1" -> {{y, 0.5}, 0, 1}, 
ControllerPath -> "Joystick"]

Mathematica graphics

I also thought it might be useful to show you the following, which is the results from

ControllerState["PLAYSTATION(R)3 Controller", "Mapping"]

(* {"X2" -> "Z Axis", "Y2" -> -"Z Rotation", "JB" -> "Button 11", 
 "JB1" -> "Button 11", "JB2" -> "Button 12", "JB3" -> None, 
 "TLB" -> "Button 5", "TRB" -> "Button 6", "BLB" -> "Button 7", 
 "BRB" -> "Button 8", "X" -> "X Axis", "Y" -> -"Y Axis", 
 "Z" -> "Z Axis", "X1" -> "X Axis", "Y1" -> -"Y Axis", 
 "Z1" -> "Z Axis", "X2" -> "Z Rotation", "Y2" -> -"Slider", 
 "Z2" -> None, "X3" -> "Hatswitch X Axis", 
 "Y3" -> -"Hatswitch Y Axis", "Z3" -> None, 
 "X4" -> Switch[{"Button 1", "Button 3"},
   {False, False}, 0,
   {True, False}, -1,
   {False, True}, 1,
   {True, True}, 0.00001], "Y4" -> Switch[{"Button 2", "Button 4"},
   {False, False}, 0,
   {True, False}, -1,
   {False, True}, 1,
   {True, True}, 0.00001], "X5" -> Switch[{"Button 7", "Button 5"},
   {False, False}, 0,
   {True, False}, -1,
   {False, True}, 1,
   {True, True}, 0.00001], "Y5" -> Switch[{"Button 8", "Button 6"},
   {False, False}, 0,
   {True, False}, -1,
   {False, True}, 1,
   {True, True}, 0.00001], "X6" -> Switch[{"Button 9", "Button 10"},
   {False, False}, 0,
   {True, False}, -1,
   {False, True}, 1,
   {True, True}, 0.00001], "B1" -> "Button 1", "B2" -> "Button 2", 
 "B3" -> "Button 3", "B4" -> "Button 4", "B5" -> "Button 5", 
 "B6" -> "Button 6", "B7" -> "Button 7", "B8" -> "Button 8", 
 "B9" -> "Button 9", "B10" -> "Button 10", "B11" -> "Button 11", 
 "B12" -> "Button 12", "DefaultAbsolute" -> False} *)

Also, for what it's worth, the Sony Playstation gamepad I am using has two main analog controls that appear to move in at least a left right and up down configuration. Moving the left control left and right appears to correspond to "X1" and moving the right control left and right appears to correspond to "Z1". I'm hoping my problem is not Sony PS3 controller specific but is due to some lack of understanding on my part about how to map the physical controls to Mathematica behavior.

share|improve this question
By adding ViewPoint -> {1.3, -2.4, 2} (the default setting) to each Graphics3D object you get a partial solution. It still rotates if you press directly up or down on the left joystick. I am not sure as to why as of yet. –  James Rohal Mar 21 '13 at 18:46
add comment

1 Answer

This can be achieved by adding the ControllerLinking -> False option to any Graphics3D objects that you do not wish to be affected by the external controller.

For example with

 Graphics3D[{FaceForm[Hue[x]], Cuboid[]}, ControllerLinking -> False],
 {x, 0, 1}]

my joystick x-axis changes the colour but the cube doesn't rotate.

share|improve this answer
Doesn't seem to work for me - Mac OS X, Mathematica version 9.0... –  cormullion Aug 6 '13 at 8:55
@cormullion I've added a simple example that works for me in Mac OS X (10.6) and Mathematica 9.0.1 with a PS2 external controller. –  MikeLimaOscar Aug 6 '13 at 9:47
Oh, you're right, that example works fine. I just added ControllerLinking -> False at the end of Seth's original example, and it didn't work, whereas yours does. Have that up vote now! –  cormullion Aug 6 '13 at 14:26
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.