void onPushNotification(jint id, jstring jtitle, jstring jtext, jint number, jstring jsound, jstring jcustom, jboolean didOpen) { JNIEnv *env = g_getJNIEnv(); const char *title = env->GetStringUTFChars(jtitle, NULL); const char *text = env->GetStringUTFChars(jtext, NULL); const char *sound = env->GetStringUTFChars(jsound, NULL); const char *custom = env->GetStringUTFChars(jcustom, NULL); gnotification_PushEvent *event = (gnotification_PushEvent*)gevent_CreateEventStruct4( sizeof(gnotification_PushEvent), offsetof(gnotification_PushEvent, title), title, offsetof(gnotification_PushEvent, text), text, offsetof(gnotification_PushEvent, sound), sound, offsetof(gnotification_PushEvent, custom), custom); event->id = (int)id; event->number = (int)number; event->didOpen = (bool)didOpen; env->ReleaseStringUTFChars(jtitle, title); env->ReleaseStringUTFChars(jtext, text); env->ReleaseStringUTFChars(jsound, sound); env->ReleaseStringUTFChars(jcustom, custom); gevent_EnqueueEvent(gid_, callback_s, NOTIFICATION_PUSH_EVENT, event, 1, this); }
void GHID::onKeyUpEvent(int keyCode, int playerId) { ghid_KeyEvent *event = (ghid_KeyEvent*)malloc(sizeof(ghid_KeyEvent)); event->keyCode = keyCode; event->playerId = playerId; gevent_EnqueueEvent(gid_, callback_s, GHID_KEY_UP_EVENT, event, 1, this); }
void ghttp_responseCallback(JNIEnv *env, jlong id, jbyteArray jdata, jint size, jint statusCode, jint hdrCount, jint hdrSize) { if (map_.find(id) == map_.end()) return; CallbackElement &element = map_[id]; jbyte *data = (jbyte*)env->GetPrimitiveArrayCritical(jdata, 0); ghttp_ResponseEvent *event = (ghttp_ResponseEvent*)malloc(sizeof(ghttp_ResponseEvent) + sizeof(ghttp_Header)*hdrCount + size + hdrSize); event->data = (char*)event + sizeof(ghttp_ResponseEvent) + sizeof(ghttp_Header)*hdrCount; memcpy(event->data, data, size + hdrSize); event->size = size; event->httpStatusCode = statusCode; int hdrn=0; char *hdrData=(char *)(event->data)+size; while (hdrCount--) { event->headers[hdrn].name=hdrData; hdrData+=(strlen(hdrData)+1); event->headers[hdrn].value=hdrData; hdrData+=(strlen(hdrData)+1); hdrn++; } event->headers[hdrn].name=NULL; event->headers[hdrn].value=NULL; gevent_EnqueueEvent(id, callback_s, GHTTP_RESPONSE_EVENT, event, 1, (void *)id); env->ReleasePrimitiveArrayCritical(jdata, data, 0); }
void onPurchaseStateChange(jint purchaseState, jstring jproductId, jstring jnotificationId, jlong purchaseTime, jstring jdeveloperPayload) { JNIEnv *env = g_getJNIEnv(); const char *productId = env->GetStringUTFChars(jproductId, NULL); const char *notificationId = jnotificationId ? env->GetStringUTFChars(jnotificationId, NULL) : NULL; const char *developerPayload = jdeveloperPayload ? env->GetStringUTFChars(jdeveloperPayload, NULL) : NULL; ggooglebilling_PurchaseStateChangeEvent *event = (ggooglebilling_PurchaseStateChangeEvent*)gevent_CreateEventStruct3( sizeof(ggooglebilling_PurchaseStateChangeEvent), offsetof(ggooglebilling_PurchaseStateChangeEvent, productId), productId, offsetof(ggooglebilling_PurchaseStateChangeEvent, notificationId), notificationId, offsetof(ggooglebilling_PurchaseStateChangeEvent, developerPayload), developerPayload); event->purchaseState = purchaseState; event->purchaseTime = purchaseTime / 1000; env->ReleaseStringUTFChars(jproductId, productId); if (jnotificationId) env->ReleaseStringUTFChars(jnotificationId, notificationId); if (jdeveloperPayload) env->ReleaseStringUTFChars(jdeveloperPayload, developerPayload); gevent_EnqueueEvent(gid_, callback_s, GGOOGLEBILLING_PURCHASE_STATE_CHANGE_EVENT, event, 1, this); }
void touchesCancel(int size, int *id, int *x, int *y, float *pressure) { for (int i = 0; i < size; ++i) { ginput_TouchEvent *touchEvent = newTouchEvent(size); touchEvent->touch.x = x[i]; touchEvent->touch.y = y[i]; touchEvent->touch.pressure = pressure[i]; touchEvent->touch.touchType = 0; touchEvent->touch.id = id[i]; for (int j = 0; j < size; ++j) { touchEvent->allTouches[j].x = x[j]; touchEvent->allTouches[j].y = y[j]; touchEvent->allTouches[j].pressure = pressure[j]; touchEvent->allTouches[j].touchType = 0; touchEvent->allTouches[j].id = id[j]; } ginput_MouseEvent *mouseEvent = NULL; if (isTouchToMouseEnabled_ && touchEvent->touch.id == 0) mouseEvent = newMouseEvent(touchEvent->touch.x, touchEvent->touch.y, GINPUT_LEFT_BUTTON); if (mouseTouchOrder_ == 0) { if (mouseEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); } gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_CANCEL_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); } else { gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_CANCEL_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); if (mouseEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); } } } }
void onMediaReceived(const char* path) { gmedia_ReceivedEvent *event = (gmedia_ReceivedEvent*)gevent_CreateEventStruct1( sizeof(gmedia_ReceivedEvent), offsetof(gmedia_ReceivedEvent, path), path); gevent_EnqueueEvent(gid_, callback_s, GMEDIA_RECEIVED_EVENT, event, 1, this); }
void GHID::onLeftTrigger(double strength, int playerId) { ghid_TriggerEvent *event = (ghid_TriggerEvent*)malloc(sizeof(ghid_TriggerEvent)); event->strength = strength; event->playerId = playerId; gevent_EnqueueEvent(gid_, callback_s, GHID_LEFT_TRIGGER_EVENT, event, 1, this); }
void onAdDisplayed(const char *ad, const char *type) { gads_SimpleEvent *event = (gads_SimpleEvent*)gevent_CreateEventStruct2( sizeof(gads_SimpleEvent), offsetof(gads_SimpleEvent, ad), ad, offsetof(gads_SimpleEvent, type), type); gevent_EnqueueEvent(gid_, callback_s, GADS_AD_DISPLAYED_EVENT, event, 1, this); }
void onAdActionEnd(const char *ad, const char *type) { gads_SimpleEvent *event = (gads_SimpleEvent*)gevent_CreateEventStruct2( sizeof(gads_SimpleEvent), offsetof(gads_SimpleEvent, ad), ad, offsetof(gads_SimpleEvent, type), type); gevent_EnqueueEvent(gid_, callback_s, GADS_AD_ACTION_END_EVENT, event, 1, this); }
void touchBegin(int size, int *id, int *x, int *y, float *pressure, int actionIndex) { ginput_TouchEvent *touchEvent = newTouchEvent(size); touchEvent->touch.x = x[actionIndex]; touchEvent->touch.y = y[actionIndex]; touchEvent->touch.pressure = pressure[actionIndex]; touchEvent->touch.touchType = 0; touchEvent->touch.id = id[actionIndex]; for (int i = 0; i < size; ++i) { touchEvent->allTouches[i].x = x[i]; touchEvent->allTouches[i].y = y[i]; touchEvent->allTouches[i].pressure = pressure[i]; touchEvent->allTouches[i].touchType = 0; touchEvent->allTouches[i].id = id[i]; } ginput_MouseEvent *mouseEvent = NULL; if (isTouchToMouseEnabled_ && touchEvent->touch.id == 0) mouseEvent = newMouseEvent(touchEvent->touch.x, touchEvent->touch.y, GINPUT_LEFT_BUTTON); if (mouseTouchOrder_ == 0) { if (mouseEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_DOWN_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); } gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_BEGIN_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); } else { gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_BEGIN_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); if (mouseEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_DOWN_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); } } }
void onDisconnected(jint playerId) { JNIEnv *env = g_getJNIEnv(); ghid_DeviceEvent *event = (ghid_DeviceEvent*)malloc(sizeof(ghid_DeviceEvent)); event->playerId = (int)playerId; gevent_EnqueueEvent(gid_, callback_s, GHID_DISCONNECTED_EVENT, event, 1, this); }
void onKeyDownEvent(jint keyCode, jint playerId) { JNIEnv *env = g_getJNIEnv(); ghid_KeyEvent *event = (ghid_KeyEvent*)malloc(sizeof(ghid_KeyEvent)); event->keyCode = (int)keyCode; event->playerId = (int)playerId; gevent_EnqueueEvent(gid_, callback_s, GHID_KEY_DOWN_EVENT, event, 1, this); }
void onAdError(const char *ad, const char *error) { gads_AdErrorEvent *event = (gads_AdErrorEvent*)gevent_CreateEventStruct2( sizeof(gads_AdErrorEvent), offsetof(gads_AdErrorEvent, ad), ad, offsetof(gads_AdErrorEvent, error), error); gevent_EnqueueEvent(gid_, callback_s, GADS_AD_ERROR_EVENT, event, 1, this); }
void keyChar(const char *keychar) { ginput_KeyEvent *event = newKeyEvent(0,0); if (strlen(keychar)<(sizeof(event->charCode))) { strcpy(event->charCode,keychar); gevent_EnqueueEvent(gid_, callback_s, GINPUT_KEY_CHAR_EVENT, event, 0, this); } deleteKeyEvent(event); }
void onRestoreTransactionsResponse(jint responseCode) { JNIEnv *env = g_getJNIEnv(); ggooglebilling_RestoreTransactionsCompleteEvent *event = (ggooglebilling_RestoreTransactionsCompleteEvent*)malloc(sizeof(ggooglebilling_RestoreTransactionsCompleteEvent)); event->responseCode = responseCode; gevent_EnqueueEvent(gid_, callback_s, GGOOGLEBILLING_RESTORE_TRANSACTIONS_COMPLETE_EVENT, event, 1, this); }
void keyUp(int keyCode) { keyCode = convertKeyCode(keyCode); if (keyCode == 0) return; ginput_KeyEvent *event = newKeyEvent(keyCode); gevent_EnqueueEvent(gid_, callback_s, GINPUT_KEY_UP_EVENT, event, 0, this); deleteKeyEvent(event); }
void onLeftTrigger(jdouble strength, jint playerId) { JNIEnv *env = g_getJNIEnv(); ghid_TriggerEvent *event = (ghid_TriggerEvent*)malloc(sizeof(ghid_TriggerEvent)); event->strength = (double)strength; event->playerId = (int)playerId; gevent_EnqueueEvent(gid_, callback_s, GHID_LEFT_TRIGGER_EVENT, event, 1, this); }
void GHID::onConnected(struct Gamepad_device * device) { int playerId = device->deviceID+1; GController *c = new GController(this, playerId, device->description, device->numButtons, device->vendorID, device->productID); players.insert(std::pair<int, GController*>(playerId,c)); ghid_DeviceEvent *event = (ghid_DeviceEvent*)malloc(sizeof(ghid_DeviceEvent)); event->playerId = playerId; gevent_EnqueueEvent(gid_, callback_s, GHID_CONNECTED_EVENT, event, 1, this); }
void HTTPManager::finished(QNetworkReply *reply) { reply->deleteLater(); if (map_.find(reply) == map_.end()) return; if (reply->error() != QNetworkReply::NoError // a web page that returns 403/404 can still have content && reply->error() != QNetworkReply::ContentOperationNotPermittedError && reply->error() != QNetworkReply::ContentNotFoundError && reply->error() != QNetworkReply::UnknownContentError) { NetworkReply reply2 = map_[reply]; ghttp_ErrorEvent *event = (ghttp_ErrorEvent*)malloc(sizeof(ghttp_ErrorEvent)); gevent_EnqueueEvent(reply2.id, reply2.callback, GHTTP_ERROR_EVENT, event, 1, reply2.udata); } else { QByteArray bytes = reply->readAll(); NetworkReply reply2 = map_[reply]; ghttp_ResponseEvent *event = (ghttp_ResponseEvent*)malloc(sizeof(ghttp_ResponseEvent) + bytes.size()); event->data = (char*)event + sizeof(ghttp_ResponseEvent); memcpy(event->data, bytes.constData(), bytes.size()); event->size = bytes.size(); QVariant httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); if (httpStatusCode.isValid()) event->httpStatusCode = httpStatusCode.toInt(); else event->httpStatusCode = -1; gevent_EnqueueEvent(reply2.id, reply2.callback, GHTTP_RESPONSE_EVENT, event, 1, reply2.udata); } map_.erase(reply); }
void ghttp_errorCallback(JNIEnv *env, jlong id) { if (map_.find(id) == map_.end()) return; CallbackElement &element = map_[id]; ghttp_ErrorEvent *event = (ghttp_ErrorEvent*)malloc(sizeof(ghttp_ErrorEvent)); gevent_EnqueueEvent(id, callback_s, GHTTP_ERROR_EVENT, event, 1, (void *)id); }
void callback(int buttonIndex, const char *buttonText) { size_t size = sizeof(gui_AlertDialogCompleteEvent) + strlen(buttonText) + 1; gui_AlertDialogCompleteEvent *event = (gui_AlertDialogCompleteEvent*)malloc(size); event->gid = gid_; event->buttonIndex = buttonIndex; event->buttonText = (char*)event + sizeof(gui_AlertDialogCompleteEvent); strcpy((char*)event->buttonText, buttonText); gevent_EnqueueEvent(gid_, callback_, GUI_ALERT_DIALOG_COMPLETE_EVENT, event, 1, udata_); }
void GHID::onRightJoystick(float x, float y, double angle, double strength, int playerId) { ghid_JoystickEvent *event = (ghid_JoystickEvent*)malloc(sizeof(ghid_JoystickEvent)); event->x = x; event->y = y; event->angle = angle; event->playerId = playerId; event->strength = strength; gevent_EnqueueEvent(gid_, callback_s, GHID_RIGHT_JOYSTICK_EVENT, event, 1, this); }
void onAdFailed(const char *ad, const char *error, const char *type) { gads_AdFailedEvent *event = (gads_AdFailedEvent*)gevent_CreateEventStruct3( sizeof(gads_AdFailedEvent), offsetof(gads_AdFailedEvent, ad), ad, offsetof(gads_AdFailedEvent, type), type, offsetof(gads_AdFailedEvent, error), error); gevent_EnqueueEvent(gid_, callback_s, GADS_AD_FAILED_EVENT, event, 1, this); }
void ghttp_progressCallback(JNIEnv *env, jlong id, jint bytesLoaded, jint bytesTotal) { if (map_.find(id) == map_.end()) return; CallbackElement &element = map_[id]; ghttp_ProgressEvent *event = (ghttp_ProgressEvent*)malloc(sizeof(ghttp_ProgressEvent)); event->bytesLoaded = bytesLoaded; event->bytesTotal = bytesTotal; gevent_EnqueueEvent(id, element.callback, GHTTP_PROGRESS_EVENT, event, 1, element.udata); }
void onMediaReceived(jstring jpath) { JNIEnv *env = g_getJNIEnv(); const char *path = env->GetStringUTFChars(jpath, NULL); gmedia_ReceivedEvent *event = (gmedia_ReceivedEvent*)gevent_CreateEventStruct1( sizeof(gmedia_ReceivedEvent), offsetof(gmedia_ReceivedEvent, path), path); env->ReleaseStringUTFChars(jpath, path); gevent_EnqueueEvent(gid_, callback_s, GMEDIA_RECEIVED_EVENT, event, 1, this); }
void GHID::onDisconnected(struct Gamepad_device * device) { int playerId = device->deviceID+1; std::map<int, GController*>::iterator it = players.find(playerId); if (it != players.end()) { delete it->second; players.erase(it); } ghid_DeviceEvent *event = (ghid_DeviceEvent*)malloc(sizeof(ghid_DeviceEvent)); event->playerId = playerId; gevent_EnqueueEvent(gid_, callback_s, GHID_DISCONNECTED_EVENT, event, 1, this); }
int keyUp(int realCode, int repeatCount) { int keyCode = convertKeyCode(realCode); if (repeatCount == 0) { ginput_KeyEvent *event = newKeyEvent(keyCode, realCode); gevent_EnqueueEvent(gid_, callback_s, GINPUT_KEY_UP_EVENT, event, 0, this); deleteKeyEvent(event); } return 1; }
void onPushRegistrationError(jstring jerrorId) { JNIEnv *env = g_getJNIEnv(); const char *errorId = env->GetStringUTFChars(jerrorId, NULL); gnotification_RegisterPushErrorEvent *event = (gnotification_RegisterPushErrorEvent*)gevent_CreateEventStruct1( sizeof(gnotification_RegisterPushErrorEvent), offsetof(gnotification_RegisterPushErrorEvent, errorId), errorId); env->ReleaseStringUTFChars(jerrorId, errorId); gevent_EnqueueEvent(gid_, callback_s, NOTIFICATION_PUSH_REGISTER_ERROR_EVENT, event, 1, this); }
void onLeftJoystick(jfloat x, jfloat y, jdouble angle, jdouble strength, jint playerId) { JNIEnv *env = g_getJNIEnv(); ghid_JoystickEvent *event = (ghid_JoystickEvent*)malloc(sizeof(ghid_JoystickEvent)); event->x = (float)x; event->y = (float)y; event->angle = angle; event->playerId = (int)playerId; event->strength = (double)strength; gevent_EnqueueEvent(gid_, callback_s, GHID_LEFT_JOYSTICK_EVENT, event, 1, this); }
void mouseUp(int x, int y, int button) { ginput_MouseEvent *mouseEvent = newMouseEvent(x, y, button); ginput_TouchEvent *touchEvent = NULL; if (isMouseToTouchEnabled_) { touchEvent = newTouchEvent(1); touchEvent->touch.x = x; touchEvent->touch.y = y; touchEvent->touch.id = 0; touchEvent->allTouches[0].x = x; touchEvent->allTouches[0].y = y; touchEvent->allTouches[0].id = 0; } if (mouseTouchOrder_ == 0) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); if (touchEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_END_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); } } else { if (touchEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_END_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); } gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); } }