void CAccelerometer::Init()
{
    IwTrace(WM_MODULE_ACCEL,("Accelerometer: Init"));
    m_Status = WM_STATUS_ACC_OFF;
}
static void s3eGPGSubmitLeaderboardScore_wrap(const char* leaderboardID, int score)
{
    IwTrace(GOOGLEPLAYGAMES_VERBOSE, ("calling s3eGooglePlayGames func on main thread: s3eGPGSubmitLeaderboardScore"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)s3eGPGSubmitLeaderboardScore, 2, leaderboardID, score);
}
static void s3eGPGShowAllLeaderBoardsUI_wrap()
{
    IwTrace(GOOGLEPLAYGAMES_VERBOSE, ("calling s3eGooglePlayGames func on main thread: s3eGPGShowAllLeaderBoardsUI"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)s3eGPGShowAllLeaderBoardsUI, 0);
}
static s3eResult s3eGPGInitialize_wrap()
{
    IwTrace(GOOGLEPLAYGAMES_VERBOSE, ("calling s3eGooglePlayGames func on main thread: s3eGPGInitialize"));
    return (s3eResult)(intptr_t)s3eEdkThreadRunOnOS((s3eEdkThreadFunc)s3eGPGInitialize, 0);
}
static void s3eGPGUnRegisterCallback_wrap(s3eGPGCallbackType callbackID, s3eCallback callbackFn)
{
    IwTrace(GOOGLEPLAYGAMES_VERBOSE, ("calling s3eGooglePlayGames func on main thread: s3eGPGUnRegisterCallback"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)s3eGPGUnRegisterCallback, 2, callbackID, callbackFn);
}
static void OuyaPlugin_asyncOuyaRequestPurchase_wrap(const char* purchasable, s3eCallback onSuccess, s3eCallback onFailure, s3eCallback onCancel)
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_asyncOuyaRequestPurchase"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_asyncOuyaRequestPurchase, 4, purchasable, onSuccess, onFailure, onCancel);
}
static int OuyaPlugin_JSONObject_Construct_wrap()
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_JSONObject_Construct"));
    return (int)(intptr_t)s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_JSONObject_Construct, 0);
}
void AdFound(void* data) { IwTrace(Presage, ("PRESAGE AD FOUND")); }
void AdNotFound(void* data) { IwTrace(Presage, ("PRESAGE AD NOT FOUND")); }
void AdError(void* data) { IwTrace(Presage, ("PRESAGE AD ERROR")); }
void AdDisplayed(void* data) { IwTrace(Presage, ("PRESAGE AD DISPLAYED")); }
Beispiel #12
0
int Strike::strikeUpdate(int32 x, int32 y, int32 z) {
	int i;

	float phoneAccel = (float)sqrt(z*z + y*y);
	phoneAccel = (z+y) < 0 ? phoneAccel*-1 : phoneAccel*1;

	if (phoneAccel < -200 || phoneAccel > 200) 
		IwTrace(GHOST_HUNTER, ("Strike x: %d y: %d z: %d accel: %f", x, y, z, phoneAccel));

	// 1) Should the strike init?
	if (!striking && phoneAccel > ACCEL_TO_START_STRKE) {
		striking = true;
			
		IwTrace(GHOST_HUNTER, ("Strike started with accel %f", phoneAccel));

		// Initialize variables
		strikeInitTime = clock();
		peakAccel = 0;
		accelDecreasing = false;
	}

	int timeUsed = clock() - strikeInitTime;

	if (striking) {
		IwTrace(GOHU, ("accel %f", phoneAccel));

		if (timeUsed < MIN_STRIKE_TIME && z + y < ACCEL_TO_START_STRKE/2 && (x < 100 && y < 100)) {
			// 2) Is the phone already slowing or going backward?
			striking = false;
			IwTrace(GHOST_HUNTER, ("Strike ended too early"));
		} else if (timeUsed > MAX_STRIKE_TIME) {
			// 2) Is the time up?
			IwTrace(GHOST_HUNTER, ("Strike timed out"));
			striking = false;
		}
	}

		
	if (striking && timeUsed >= MIN_STRIKE_TIME) {
		peakAccel = phoneAccel > peakAccel ? phoneAccel : peakAccel;
		if (phoneAccel < peakAccel - 20) {
			// 3) Acceleration is decreasing
			if (!accelDecreasing) {
				// 3) Initialize the end phase
				accelDecreasing = true;
				accelDecreasingTime = clock();
			}
		}
		IwTrace(GOHU, ("Peak accel %f", peakAccel));

		if (phoneAccel < REQUIRED_BLOW_STR) {
			// If the final stop/blow of the strike is strong enough
			// accept the hit
			IwTrace(GHOST_HUNTER, ("Final phone accel %f", phoneAccel));
			striking = false;
			return 1;
		} else {
			IwTrace(GHOST_HUNTER, ("The blow was too weak with accel %f", 
				phoneAccel));
		}
	}

	return 0;
}
static char * s3eGPUImageTake_wrap(s3eGPUImageEventDoIt evnt, void * userData)
{
    IwTrace(GPUIMAGE_VERBOSE, ("calling s3eGPUImage func on main thread: s3eGPUImageTake"));
    return (char *)(intptr_t)s3eEdkThreadRunOnOS((s3eEdkThreadFunc)s3eGPUImageTake, 2, evnt, userData);
}
//C++ user init code
void CAccelerometer::OnReady()
{
    IwTrace(WM_MODULE_ACCEL, ("Accelerometer: OnReady."));
}
static void OuyaPlugin_initOuyaPlugin_wrap(const char* jsonData, s3eCallback onSuccess, s3eCallback onFailure)
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_initOuyaPlugin"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_initOuyaPlugin, 3, jsonData, onSuccess, onFailure);
}
void AdClosed(void* data) { IwTrace(Presage, ("PRESAGE AD CLOSED")); }
static void OuyaPlugin_asyncOuyaRequestProducts_wrap(const char* productsJson, s3eCallback onSuccess, s3eCallback onFailure, s3eCallback onCancel)
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_asyncOuyaRequestProducts"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_asyncOuyaRequestProducts, 4, productsJson, onSuccess, onFailure, onCancel);
}
static void OuyaPlugin_JSONArray_Put_wrap(int jsonArray, int index, int jsonObject)
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_JSONArray_Put"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_JSONArray_Put, 3, jsonArray, index, jsonObject);
}
static void OuyaPlugin_asyncOuyaRequestReceipts_wrap(s3eCallback onSuccess, s3eCallback onFailure, s3eCallback onCancel)
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_asyncOuyaRequestReceipts"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_asyncOuyaRequestReceipts, 3, onSuccess, onFailure, onCancel);
}
static const char* OuyaPlugin_JSONArray_ToString_wrap(int jsonArray)
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_JSONArray_ToString"));
    return (const char*)(intptr_t)s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_JSONArray_ToString, 1, jsonArray);
}
static void OuyaPlugin_JSONObject_Put_wrap(int jsonObject, const char* name, const char* value)
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_JSONObject_Put"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_JSONObject_Put, 3, jsonObject, name, value);
}
static int OuyaPlugin_getAxis_wrap(int deviceId, int axis)
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_getAxis"));
    return (int)(intptr_t)s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_getAxis, 2, deviceId, axis);
}
static void s3eGPGDeInitialize_wrap()
{
    IwTrace(GOOGLEPLAYGAMES_VERBOSE, ("calling s3eGooglePlayGames func on main thread: s3eGPGDeInitialize"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)s3eGPGDeInitialize, 0);
}
static bool OuyaPlugin_isPressedUp_wrap(int deviceId, int keyCode)
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_isPressedUp"));
    return (bool)(intptr_t)s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_isPressedUp, 2, deviceId, keyCode);
}
static void s3eGPGUnlockIncrementalAchievement_wrap(const char* id, int increment)
{
    IwTrace(GOOGLEPLAYGAMES_VERBOSE, ("calling s3eGooglePlayGames func on main thread: s3eGPGUnlockIncrementalAchievement"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)s3eGPGUnlockIncrementalAchievement, 2, id, increment);
}
static void OuyaPlugin_clearButtonStates_wrap()
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_clearButtonStates"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_clearButtonStates, 0);
}
static void s3eGPGShowLeaderboardUI_wrap(const char* leaderboardID)
{
    IwTrace(GOOGLEPLAYGAMES_VERBOSE, ("calling s3eGooglePlayGames func on main thread: s3eGPGShowLeaderboardUI"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)s3eGPGShowLeaderboardUI, 1, leaderboardID);
}
static const char* OuyaPlugin_getDeviceName_wrap(int playerNum)
{
    IwTrace(ODK_VERBOSE, ("calling ODK func on main thread: OuyaPlugin_getDeviceName"));
    return (const char*)(intptr_t)s3eEdkThreadRunOnOS((s3eEdkThreadFunc)OuyaPlugin_getDeviceName, 1, playerNum);
}
static void s3eAppsFlyerDisableAppleAdSupportTracking_wrap(s3eBool _disable)
{
    IwTrace(APPSFLYER_VERBOSE, ("calling s3eAppsFlyer func on main thread: s3eAppsFlyerDisableAppleAdSupportTracking"));
    s3eEdkThreadRunOnOS((s3eEdkThreadFunc)s3eAppsFlyerDisableAppleAdSupportTracking, 1, _disable);
}
static s3eResult initSDK_wrap()
{
    IwTrace(STARTAPP_VERBOSE, ("calling startapp func on main thread: initSDK"));
    return (s3eResult)(intptr_t)s3eEdkThreadRunOnOS((s3eEdkThreadFunc)initSDK, 0);
}