Permalink
Browse files

Merge branch 'master' of https://github.com/jokio/jok-pitching.git

  • Loading branch information...
2 parents 856150c + a036f68 commit bfef8b40327304e69c8f8f12cae62f0fb2a3f15c @playerx playerx committed Feb 26, 2014
Showing with 2,862 additions and 8 deletions.
  1. +1 −1 Mobile/config.xml
  2. +24 −1 Mobile/platforms/ios/.staging/www/cordova_plugins.js
  3. +22 −0 Mobile/platforms/ios/.staging/www/plugins/gamecenter/www/gamecenter.js
  4. +31 −0 Mobile/platforms/ios/.staging/www/plugins/org.apache.cordova.device-motion/www/Acceleration.js
  5. +171 −0 Mobile/platforms/ios/.staging/www/plugins/org.apache.cordova.device-motion/www/accelerometer.js
  6. +25 −2 Mobile/platforms/ios/Pitching.xcodeproj/project.pbxproj
  7. BIN ...s/Pitching.xcodeproj/project.xcworkspace/xcuserdata/ez.xcuserdatad/UserInterfaceState.xcuserstate
  8. BIN Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default-568h@2x~iphone.png
  9. BIN Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default-Landscape@2x~ipad.png
  10. BIN Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default-Landscape~ipad.png
  11. BIN Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default@2x~iphone.png
  12. BIN Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default~iphone.png
  13. +5 −1 Mobile/platforms/ios/Pitching/Pitching-Info.plist
  14. +17 −0 Mobile/platforms/ios/Pitching/Plugins/gamecenter/GameCenter.h
  15. +140 −0 Mobile/platforms/ios/Pitching/Plugins/gamecenter/GameCenter.m
  16. +39 −0 Mobile/platforms/ios/Pitching/Plugins/org.apache.cordova.device-motion/CDVAccelerometer.h
  17. +138 −0 Mobile/platforms/ios/Pitching/Plugins/org.apache.cordova.device-motion/CDVAccelerometer.m
  18. +7 −1 Mobile/platforms/ios/Pitching/config.xml
  19. +24 −1 Mobile/platforms/ios/www/cordova_plugins.js
  20. +22 −0 Mobile/platforms/ios/www/plugins/gamecenter/www/gamecenter.js
  21. +31 −0 Mobile/platforms/ios/www/plugins/org.apache.cordova.device-motion/www/Acceleration.js
  22. +171 −0 Mobile/platforms/ios/www/plugins/org.apache.cordova.device-motion/www/accelerometer.js
  23. +1 −0 Mobile/plugins/gamecenter/.fetch.json
  24. +61 −0 Mobile/plugins/gamecenter/README.md
  25. +23 −0 Mobile/plugins/gamecenter/plugin.xml
  26. +17 −0 Mobile/plugins/gamecenter/src/ios/GameCenter.h
  27. +140 −0 Mobile/plugins/gamecenter/src/ios/GameCenter.m
  28. +20 −0 Mobile/plugins/gamecenter/www/gamecenter.js
  29. +1 −1 Mobile/plugins/ios.json
  30. +1 −0 Mobile/plugins/org.apache.cordova.device-motion/.fetch.json
  31. +202 −0 Mobile/plugins/org.apache.cordova.device-motion/LICENSE
  32. +22 −0 Mobile/plugins/org.apache.cordova.device-motion/README.md
  33. +57 −0 Mobile/plugins/org.apache.cordova.device-motion/RELEASENOTES.md
  34. +156 −0 Mobile/plugins/org.apache.cordova.device-motion/doc/index.md
  35. +15 −0 Mobile/plugins/org.apache.cordova.device-motion/package.json
  36. +133 −0 Mobile/plugins/org.apache.cordova.device-motion/plugin.xml
  37. +295 −0 Mobile/plugins/org.apache.cordova.device-motion/src/android/AccelListener.java
  38. +45 −0 Mobile/plugins/org.apache.cordova.device-motion/src/blackberry10/index.js
  39. +21 −0 Mobile/plugins/org.apache.cordova.device-motion/src/firefoxos/accelerometer.js
  40. +39 −0 Mobile/plugins/org.apache.cordova.device-motion/src/ios/CDVAccelerometer.h
  41. +138 −0 Mobile/plugins/org.apache.cordova.device-motion/src/ios/CDVAccelerometer.m
  42. +30 −0 Mobile/plugins/org.apache.cordova.device-motion/src/tizen/AccelerometerProxy.js
  43. +58 −0 Mobile/plugins/org.apache.cordova.device-motion/src/ubuntu/accelerometer.cpp
  44. +55 −0 Mobile/plugins/org.apache.cordova.device-motion/src/ubuntu/accelerometer.h
  45. +70 −0 Mobile/plugins/org.apache.cordova.device-motion/src/windows8/AccelerometerProxy.js
  46. +196 −0 Mobile/plugins/org.apache.cordova.device-motion/src/wp/Accelerometer.cs
  47. +29 −0 Mobile/plugins/org.apache.cordova.device-motion/www/Acceleration.js
  48. +169 −0 Mobile/plugins/org.apache.cordova.device-motion/www/accelerometer.js
View
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<widget id="io.jok.pitching" version="0.1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+<widget id="io.jok.pitching" version="1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Pitching</name>
@@ -41,6 +41,27 @@ module.exports = [
"clobbers": [
"window.Media"
]
+ },
+ {
+ "file": "plugins/org.apache.cordova.device-motion/www/Acceleration.js",
+ "id": "org.apache.cordova.device-motion.Acceleration",
+ "clobbers": [
+ "Acceleration"
+ ]
+ },
+ {
+ "file": "plugins/org.apache.cordova.device-motion/www/accelerometer.js",
+ "id": "org.apache.cordova.device-motion.accelerometer",
+ "clobbers": [
+ "navigator.accelerometer"
+ ]
+ },
+ {
+ "file": "plugins/gamecenter/www/gamecenter.js",
+ "id": "gamecenter.GameCenter",
+ "clobbers": [
+ "gamecenter"
+ ]
}
];
module.exports.metadata =
@@ -51,7 +72,9 @@ module.exports.metadata =
"org.apache.cordova.inappbrowser": "0.3.1",
"org.apache.cordova.vibration": "0.3.7",
"com.phonegap.plugins.jokutils": "0.1.0",
- "org.apache.cordova.media": "0.2.8"
+ "org.apache.cordova.media": "0.2.8",
+ "org.apache.cordova.device-motion": "0.2.6",
+ "gamecenter": "0.2.3"
}
// BOTTOM OF METADATA
});
@@ -0,0 +1,22 @@
+cordova.define("gamecenter.GameCenter", function(require, exports, module) {
+var exec = require("cordova/exec");
+
+var GameCenter = function () {
+ this.name = "GameCenter";
+};
+
+GameCenter.prototype.auth = function (success, failure) {
+ exec(success, failure, "GameCenter", "auth", []);
+};
+
+GameCenter.prototype.submitScore = function (success, failure, data) {
+ exec(success, failure, "GameCenter", "submitScore", [data]);
+};
+
+GameCenter.prototype.showLeaderboard = function (success, failure, data) {
+ exec(success, failure, "GameCenter", "showLeaderboard", [data]);
+};
+
+module.exports = new GameCenter();
+
+});
@@ -0,0 +1,31 @@
+cordova.define("org.apache.cordova.device-motion.Acceleration", function(require, exports, module) { /*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var Acceleration = function(x, y, z, timestamp) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.timestamp = timestamp || (new Date()).getTime();
+};
+
+module.exports = Acceleration;
+
+});
@@ -0,0 +1,171 @@
+cordova.define("org.apache.cordova.device-motion.accelerometer", function(require, exports, module) { /*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+/**
+ * This class provides access to device accelerometer data.
+ * @constructor
+ */
+var argscheck = require('cordova/argscheck'),
+ utils = require("cordova/utils"),
+ exec = require("cordova/exec"),
+ Acceleration = require('./Acceleration');
+
+// Is the accel sensor running?
+var running = false;
+
+// Keeps reference to watchAcceleration calls.
+var timers = {};
+
+// Array of listeners; used to keep track of when we should call start and stop.
+var listeners = [];
+
+// Last returned acceleration object from native
+var accel = null;
+
+// Tells native to start.
+function start() {
+ exec(function(a) {
+ var tempListeners = listeners.slice(0);
+ accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
+ for (var i = 0, l = tempListeners.length; i < l; i++) {
+ tempListeners[i].win(accel);
+ }
+ }, function(e) {
+ var tempListeners = listeners.slice(0);
+ for (var i = 0, l = tempListeners.length; i < l; i++) {
+ tempListeners[i].fail(e);
+ }
+ }, "Accelerometer", "start", []);
+ running = true;
+}
+
+// Tells native to stop.
+function stop() {
+ exec(null, null, "Accelerometer", "stop", []);
+ running = false;
+}
+
+// Adds a callback pair to the listeners array
+function createCallbackPair(win, fail) {
+ return {win:win, fail:fail};
+}
+
+// Removes a win/fail listener pair from the listeners array
+function removeListeners(l) {
+ var idx = listeners.indexOf(l);
+ if (idx > -1) {
+ listeners.splice(idx, 1);
+ if (listeners.length === 0) {
+ stop();
+ }
+ }
+}
+
+var accelerometer = {
+ /**
+ * Asynchronously acquires the current acceleration.
+ *
+ * @param {Function} successCallback The function to call when the acceleration data is available
+ * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
+ * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
+ */
+ getCurrentAcceleration: function(successCallback, errorCallback, options) {
+ argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
+
+ var p;
+ var win = function(a) {
+ removeListeners(p);
+ successCallback(a);
+ };
+ var fail = function(e) {
+ removeListeners(p);
+ errorCallback && errorCallback(e);
+ };
+
+ p = createCallbackPair(win, fail);
+ listeners.push(p);
+
+ if (!running) {
+ start();
+ }
+ },
+
+ /**
+ * Asynchronously acquires the acceleration repeatedly at a given interval.
+ *
+ * @param {Function} successCallback The function to call each time the acceleration data is available
+ * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
+ * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
+ * @return String The watch id that must be passed to #clearWatch to stop watching.
+ */
+ watchAcceleration: function(successCallback, errorCallback, options) {
+ argscheck.checkArgs('fFO', 'accelerometer.watchAcceleration', arguments);
+ // Default interval (10 sec)
+ var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
+
+ // Keep reference to watch id, and report accel readings as often as defined in frequency
+ var id = utils.createUUID();
+
+ var p = createCallbackPair(function(){}, function(e) {
+ removeListeners(p);
+ errorCallback && errorCallback(e);
+ });
+ listeners.push(p);
+
+ timers[id] = {
+ timer:window.setInterval(function() {
+ if (accel) {
+ successCallback(accel);
+ }
+ }, frequency),
+ listeners:p
+ };
+
+ if (running) {
+ // If we're already running then immediately invoke the success callback
+ // but only if we have retrieved a value, sample code does not check for null ...
+ if (accel) {
+ successCallback(accel);
+ }
+ } else {
+ start();
+ }
+
+ return id;
+ },
+
+ /**
+ * Clears the specified accelerometer watch.
+ *
+ * @param {String} id The id of the watch returned from #watchAcceleration.
+ */
+ clearWatch: function(id) {
+ // Stop javascript timer & remove from timer list
+ if (id && timers[id]) {
+ window.clearInterval(timers[id].timer);
+ removeListeners(timers[id].listeners);
+ delete timers[id];
+ }
+ }
+};
+module.exports = accelerometer;
+
+});
Oops, something went wrong.

0 comments on commit bfef8b4

Please sign in to comment.