Possibility of operating Cesium with a Joystick/Gamepad/Controller

Hello World,
I am trying to convince my seniors at the office to take up Cesium for our requirement of creating an interactive fly-through application. I was able to give them a taste of a virtual fly-through using Google Earth's Flight Simulator controlled with a PS3 Sixaxis Controller. They are impressed but want added features that need customization.

Can someone please point me in the right direction if some work has been done in this regard. I tried looking things up using common keywords like "Cesium", "Joystick", "PS3 Controller" etc. but they do not fetch me anything I can really work upon.

I hope to land up with this project so that I can be doing what I really enjoy.


Gaurav Kumar

All that stuff should be covered by GamePad API. While I’m targeting my Space Navigator plugin https://groups.google.com/d/msg/cesium-dev/PHEkXPyLKQw/-FQuJswORjwJ for 3D Mice, I could easily modify it for Joysticks/Gamepads/Controllers.

Try out your controllers at http://www.html5rocks.com/en/tutorials/doodles/gamepad/gamepad-tester/tester.html

Let me know which way is positive/negative for each axis and what movement you want for each axis and I could get it working with my plugin very quickly.

Eventually I’ll create a configuration screen allowing users to configure all of that themselves, though I hope to provide some good defaults to start with for each type of controller.

Wow, that has lots of inputs! Pressure sensitive buttons, GamePad API can get the pressure reading from those as well.

About the accelerometers, it could be setup so that the camera pitch matches the pitch of the controller. I should get a hold of one of these controllers to test it out.

Thanks for taking the time to reply!

I was very confused yesterday when I went to the html5rocks.com link on my Windows 7 (32 bit) machine and it would simply not detect my PS controller. I have been frustrated on that machine in the past too as no amount of effort (involving motioninjoy or other such DS3 drivers) could recognize the controller.

So, it was an utter joy when I could make it work right out of the box on my Linux Mint machine. However, I noticed a small issue that the keys mapping was off in case of Firefox while it was perfectly right for Chrome. Outside of the browser, I have been able to get my controller recognized on mint using antimicro (https://github.com/Ryochan7/antimicro).

Now, I can make it work with Cesium in two ways. The correct way would be to make use of the key mapping and incorporate it in my html5 code. But before that, I figured out a way I can try it on the existing hello world application of Cesium by mapping the existing mouse gestures of zoom and tilt/rotate onto the controller.

The only thing missing is to have mapping to something like Google Earth where you can use the arrow keys on the keyboard to move the camera. What would be the quickest way to get it done in sandcastle? If done, I can be ready with a demo on monday and it would help my cause. :smiley:

Cheers and thanks again!

I am really kicking myself for not having gone through the tutorial before I posted my last reply. My query about camera movement using WSAD Keys has been already discussed as an example at:

I hope I can come up with an impressive demo.

Thanks again!

So it’s not recognized in Windows Chrome, but is in Linux Chrome? Are you taking advantage of variable axis and pressure sensitive buttons? I wonder if the accelerometer data is exposed to GamePad API.

So it’s not recognized in Windows Chrome, but is in Linux Chrome?

Yes, it is so. I do not have access to another windows machine (connected to the internet ie…) as of now, so I cannot say if it is a one off thing.

Are you taking advantage of variable axis and pressure sensitive buttons?

I certainly intend to make my camera move/zoom faster/slower faster using the possibilities that pressure sensitive buttons has opened up.

I wonder if the accelerometer data is exposed to GamePad API.

I do not think so. While it would have been awesome (imagine turning the camera just by rotating the controller), those events are not exposed: neither in the browser, nor in the Antimicro setup. I wonder if it has something to do with the controller being tethered through the USB cable. Maybe there is a way of setting it free through the Bluetooth. Otherwise, I have been thinking of a setup where I can expose the accelerometer data from an old Android device that I have lying around. Or, when I get the VR thing working, I could read it off the head mounted device.

I guess I am thinking too much ahead. Breathe… that is the key.


You should open up an issue on https://code.google.com/p/chromium/issues/list to get it working on Windows Chrome as well. I’ve read about people getting accelerometer data over USB, but haven’t yet figured out how to get it from Bluetooth.