bool SimUIForm::FingerHandler::OnPenEvent(Event *pevt, bool fScrollOnly) { #if 0 switch (pevt->eType) { case penDownEvent: IPhone::Log("penDownEvent x=%d y=%d", pevt->x, pevt->y); break; case penDownEvent2: IPhone::Log("penDownEvent2 x=%d y=%d", pevt->x, pevt->y); break; case penUpEvent: IPhone::Log("penUpEvent x=%d y=%d", pevt->x, pevt->y); break; case penUpEvent2: IPhone::Log("penUpEvent2 x=%d y=%d", pevt->x, pevt->y); break; case penMoveEvent: IPhone::Log("penMoveEvent x=%d y=%d", pevt->x, pevt->y); break; case penMoveEvent2: IPhone::Log("penMoveEvent2 x=%d y=%d", pevt->x, pevt->y); break; case penHoldEvent: IPhone::Log("penHoldEvent x=%d y=%d", pevt->x, pevt->y); break; } #endif switch (pevt->eType) { case penDownEvent: OnPenDown(pevt, fScrollOnly); break; case penDownEvent2: OnPenDown2(pevt, fScrollOnly); break; case penUpEvent: OnPenUp(pevt, fScrollOnly); break; case penUpEvent2: OnPenUp2(pevt, fScrollOnly); break; case penMoveEvent: OnPenMove(pevt); break; case penMoveEvent2: OnPenMove2(pevt); break; case penHoldEvent: OnPenHold(pevt); break; default: return false; } return true; }
Boolean CCXEGLView::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch(pEvent->eType) { case EVENT_WinInit: CfgRegisterScreenSwitchNotify(GetWindowHwndId(), 0); bHandled = TRUE; break; case EVENT_WinPaint: if (CfgGetScreenStatus()) { // draw CCDirector::sharedDirector()->mainLoop(); } bHandled = TRUE; break; case EVENT_PenDown: bHandled = OnPenDown(pEvent, 0); break; case EVENT_PenMove: bHandled = OnPenMove(pEvent); break; case EVENT_PenUp: bHandled = OnPenUp(pEvent, 0); break; case EVENT_MultiTouchDown: bHandled = OnPenDown(pEvent, pEvent->lParam3); break; case EVENT_MultiTouchUp: bHandled = OnPenUp(pEvent, pEvent->lParam3); break; case EVENT_KeyCommand: { if (pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG) { bHandled = CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeBackClicked); } else if (pEvent->sParam1 == SYS_KEY_SOFTKEY_LEFT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_LEFT_LONG) { bHandled = CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeMenuClicked); } } break; case MESSAGE_SENSORS_DATA: { TG3SensorsDataType data; if (Sys_GetMessageBody((MESSAGE_t *)pEvent, &data, sizeof(TG3SensorsDataType)) == sizeof(TG3SensorsDataType) && TG3_SENSOR_TYPE_ACCELEROMETER == data.sensorMask) { // convert the data to iphone format UIAcceleration AccValue; AccValue.x = -(data.acceleration.x / TG3_GRAVITY_EARTH); AccValue.y = -(data.acceleration.y / TG3_GRAVITY_EARTH); AccValue.z = -(data.acceleration.z / TG3_GRAVITY_EARTH); AccValue.timestamp = (double) TimGetTicks() / 100; // call delegates' didAccelerate function UIAccelerometer::sharedAccelerometer()->didAccelerate(&AccValue); bHandled = TRUE; } } break; case EVENT_WinClose: CfgUnRegisterScreenSwitchNotify(GetWindowHwndId(), 0); // Stop the application since the main form has been closed pApp->SendStopEvent(); break; case EVENT_ScreenSwitchNotify: { bool bInBack = CCXApplication::sharedApplication()->isInBackground(); // if the app have be in background,don't handle this message CCX_BREAK_IF(bInBack); if (! pEvent->sParam1) // turn off screen { // CCDirector::sharedDirector()->pause(); CCXApplication::sharedApplication()->applicationDidEnterBackground(); CCXApplication::sharedApplication()->StopMainLoop(); } else { // CCDirector::sharedDirector()->resume(); CCXApplication::sharedApplication()->applicationWillEnterForeground(); CCXApplication::sharedApplication()->StartMainLoop(); } break; } } // { // char szType[32]; // sprintf(szType, "%d", pEvent->eType); // const char * pszType = szType; // switch (pEvent->eType) // { // case EVENT_ScreenSwitchNotify: // pszType = "EVENT_ScreenSwitchNotify"; // break; // // case EVENT_GlesUpdateNotify: // pszType = "EVENT_GlesUpdateNotify"; // break; // // case EVENT_WinPaint: // pszType = "EVENT_GlesUpdateNotify"; // break; // } // if (pszType) // { // char szMsg[256]; // sprintf(szMsg, "%d: %s: %d \r\n", TimGetTicks(), pszType, pEvent->sParam1); // #if defined (_TRANZDA_VM_) // #define LOG_FILE_NAME "d:/Work7/NEWPLUS/TDA_DATA/UserData/mesagelog.txt" // #else // #define LOG_FILE_NAME "/NEWPLUS/TDA_DATA/UserData/mesagelog.txt" // #endif // FILE * pf = fopen(LOG_FILE_NAME, "a+"); // fwrite(szMsg, 1, strlen(szMsg), pf); // fclose(pf); // } // } if (! bHandled) { return TWindow::EventHandler(pApp, pEvent); } return bHandled; }
void SimUIForm::FingerHandler::OnPenUp(Event *pevt, bool fScrollOnly) { m_x1 = pevt->x; m_y1 = pevt->y; m_ff &= ~kfPhFinger1Down; // The form manager sometimes posts these when modes need to be // gracefully broken out of when a new form shows during capture. if (pevt->dw == 1) { m_ff &= ~(kfPhFinger1Down | kfPhFinger2Down); EnterNone(); return; } bool fTarget = false; switch (m_state) { case FHS_DRAG: // Try to detect a quick targetting jab and don't scroll the map if (IsQuickUp(pevt)) { fTarget = !CheckDragged(pevt, MEDIUM_DRAG); } else { fTarget = !CheckDragged(pevt, SMALL_DRAG); } if (fTarget) { break; } // fall through default: // Update the position, since there may be a new position OnPenMove(pevt); } if (m_state == FHS_NONE) { return; } if (m_state == FHS_SELECT) { if (m_ff & kfPhFinger2Down) { UpdateSelect(pevt); } else { EnterNone(); } return; } if (m_state == FHS_DRAG) { if (gpfrmPlace != NULL && gpfrmPlace->IsBusy()) { if (!CheckDragged(pevt, LARGE_DRAG)) { gpfrmPlace->UpdatePosition(pevt); } EnterNone(); return; } if (fTarget && !fScrollOnly) { m_psui->MoveOrAttackOrSelect(NULL, m_wxTarget, m_wyTarget, kfMasMove); } EnterNone(); return; } // Select or attack hilighted gob. if (m_state == FHS_HILIGHT) { if (m_gidHilight == kgidNull) { EnterNone(); return; } // EnterNone before showing the menu since that is modal Gob *pgobT = ggobm.GetGob(m_gidHilight); bool fShowUnitMenu = m_fShowUnitMenu; EnterNone(); if (pgobT == NULL || (pgobT->GetFlags() & kfGobUnit) == 0) { return; } // Structures always get their menu shown when selected this way. if (pgobT->GetFlags() & kfGobStructure) { fShowUnitMenu = true; } // If showing the unit menu, make sure the command is selection. // When a miner targets a friendly processor, it isn't selection for // example. if (fShowUnitMenu && !m_psui->IsSelectionCommand(pgobT)) { fShowUnitMenu = false; } // Select or attack m_psui->MoveOrAttackOrSelect(pgobT, m_wxTarget, m_wyTarget, kfMasSelect | kfMasAttack); // Show the menu last since it is modal if (fShowUnitMenu) { m_psui->ShowUnitMenu(pgobT); } return; } // What is this state? Assert(); EnterNone(); }