This plugin has been published in the Cordova Plugin Registry (Plugman) so adding it to any Cordova project version 3.0 and above can be done using the Cordova Command Line Interface (CLI).
Install the plugin with the following command line:
cordova plugin add com.judax.cordova.plugin.firephoneheadtracking
4.- The API that is exposed is exactly the same as the JavaScrip API Amazon has released for their Amazon Web Apps. You can follow a complete tutorial at the following link: https://developer.amazon.com/public/community/post/TxX1C30LEEOJP2/Adding-Dynamic-Perspective-to-Your-HTML5-Games-Tutorial
NOTE: I haven't been able to find very good online API documentation about the Amazon HTML5 Head Tracking API, although if you download the full FirePhone SDK, it provides a great guide on how to use it in PDF format that I have included inside the doc folder in this repository.
Not many modifications are needed in order to be able use the the plugin. Indeed only the inclusion of the "FirePhoneHeadTracking.js" file is required (and even this requirement might be removed in the future by using Cordova plugin modules).
... <head> <script src="FirePhoneHeadTracking.js"></script> ...
IMPORTANT: The whole API (the registering head tracking event listeners) won't be available until the Cordova
deviceready event is fired, so make sure that your application does not try to call or use it before that event.
A sweet tutorial on how to include the head tracking HTML5 API inside your games by Jesse Freeman: https://developer.amazon.com/public/community/post/TxX1C30LEEOJP2/Adding-Dynamic-Perspective-to-Your-HTML5-Games-Tutorial
More information about the FirePhone and the Head Tracking or Dynamic Perspective feature: https://developer.amazon.com/public/solutions/devices/fire-phone#DP