PhoneGap and Hardware: Pressure-Sensitive Sketching and the Moga Gamepad
The recording for my session “PhoneGap and Hardware” from PhoneGap Day back in July is now available! Be sure to check it out. There were apparently some issues with the audio, but you can still hear everything.
I’d like to express a huge Thank You to everyone who attended, and to everyone who watches this video!
Below are the sample projects I showed in the presentation, including source code. However, keep in mind that all of these examples were written before PhoneGap 3.0. The native plugin syntax and inclusion methods have changed.
Pressure Sensitive Sketching in PhoneGap
In this example, the pressure-sensitive Pogo Connect Stylus uses a low energy Bluetooth 4 connection to relay touch/pressure information back to the PhoneGap application. This makes for a unique drawing and sketching experience powered with the HTML5 Canvas element. I’ve written about this example previously … check out the video below to see it in action, and read the blog post for technical details and source code.
The second example that I explored is a PhoneGap native plugin that is used to handle input from a Moga game controller inside of a PhoneGap application on Android.
This implementation is intended to be a proof of concept demonstrating how you could integrate the gamepad within your application. It currently only supports input from the joysticks (axisX and axisY) and the A and B buttons, and it does not handle all possible input from the controller.
This implementation is adapted directly from the com.bda.controller.example.demo.listen example from the Moga developers SDK samples available for download at: http://www.mogaanywhere.com/developers/
Check out the video below to see it in action:
The game is based on the Universe prototype that was used as a sub-game inside of the MaxMe app for the recent Adobe MAX conference. I make no guarantees about the code for this game, it was in a huge rush!
- Source code for the Pogo Connect iOS pressure sensitive stylus sample
- Source code for the Moga gamepad Android sample
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)