Ejemplo n.º 1
0
void PhysicsComponent::OnConnected() {
  static std::string BDATpos("position");
  static std::string BDATorient("orientation");
  static std::string BDATvelocity("velocity");
      
  if(!m_ownerBus->GetOwnerData(BDATorient, true, &m_pOwnerOrientation)
      || !m_ownerBus->GetOwnerData(BDATpos, true, &m_pOwnerPosition)
      || !m_ownerBus->GetOwnerData(BDATvelocity, true, &m_pOwnerVelocity)) {
    assert(false);
    SelfDestruct();
  }

  static std::string BDATpushVelocity("pushVelocity"); //already don't remember what BDAT stands for
  if(!m_ownerBus->GetOwnerData(BDATpushVelocity, true, &m_pOwnerPushVelocity)) {
    m_pOwnerPushVelocity = NULL; // this is ok
  }
  static std::string BDATcollideFlag("collidingLastFrame"); // bumblefuck data asinine tag?
  if(!m_ownerBus->GetOwnerData(BDATcollideFlag, true, &m_pOwnerCollidingLastFrame)) {
    m_pOwnerCollidingLastFrame = NULL;
  }

  RegisterSignal(std::string("Step"), this, &PhysicsComponent::OnStepSignal);
  // This is a bad sign... Should we do a typeid system?
  RegisterSignal(std::string("DestroyPhysics"), (Component*)this, &Component::SelfDestruct);
  RegisterSignal(std::string("AddImpulse"), this, &PhysicsComponent::OnImpulse);
  RegisterSignal(std::string("inputJump"), this, &PhysicsComponent::OnJump);
}
int KmaInit(void) {
	int ret = 0;
	char kmaDeviceName[1024] = {0,};

	memset(traceFuncArray, 0, sizeof(traceFuncArray));

	snprintf(kmaDeviceName, 1024, "%s/%s", KMA_DEVICE_DIR, KMA_DEVICE_NAME);

	fdKMA = open(kmaDeviceName, O_RDWR);
	if(fdKMA < 0) {
		printf("file [%s] open error : %d\n", kmaDeviceName, errno);
		return -1;
	}

	ret = pthread_spin_init(&traceFuncArrayLock, PTHREAD_PROCESS_PRIVATE);
	if(ret) {
		printf("pthread_spin_init error");

		close(fdKMA);
		return ret;
	}

	ret = RegisterSignal();
	if(ret) {
		printf("RegisterSignal error\n");

		close(fdKMA);
		pthread_spin_destroy(&traceFuncArrayLock);
		return ret;
	}

	return 0;
}
Ejemplo n.º 3
0
void GuiInputRouterComponent::OnConnected() {
  RegisterSignal(std::string("inputControlsMenu"), this, &GuiInputRouterComponent::OnControlsMenu);
  RegisterSignal(std::string("inputMainMenu"), this, &GuiInputRouterComponent::OnReset);
  RegisterSignal(std::string("inputPadUp"), this,         &GuiInputRouterComponent::OnPadUp);
  RegisterSignal(std::string("inputPadUp_Release"), this, &GuiInputRouterComponent::OnPadUp_Release);
  RegisterSignal(std::string("inputPadDown"), this,         &GuiInputRouterComponent::OnPadDown);
  RegisterSignal(std::string("inputPadDown_Release"), this, &GuiInputRouterComponent::OnPadDown_Release);
  RegisterSignal(std::string("inputPadLeft"), this,         &GuiInputRouterComponent::OnPadLeft);
  RegisterSignal(std::string("inputPadLeft_Release"), this, &GuiInputRouterComponent::OnPadLeft_Release);
  RegisterSignal(std::string("inputPadRight"), this,          &GuiInputRouterComponent::OnPadRight);
  RegisterSignal(std::string("inputPadRight_Release"), this,  &GuiInputRouterComponent::OnPadRight_Release);
  RegisterSignal(std::string("inputButton0"), this,          &GuiInputRouterComponent::OnButton0);
  RegisterSignal(std::string("inputButton0_Release"), this,  &GuiInputRouterComponent::OnButton0_Release);
  RegisterSignal(std::string("inputButton1"), this,          &GuiInputRouterComponent::OnButton1);
  RegisterSignal(std::string("inputButton1_Release"), this,  &GuiInputRouterComponent::OnButton1_Release);
  RegisterSignal(std::string("Step"), this, &GuiInputRouterComponent::OnStep);

  // really would like to get lambdas to work
  //  void GuiInputRouterComponent::OnPadDown(float frameTime) {
  //  SetNavTypeFromSignal(std::string("inputPadDown"), 1.0f);
  //}
  //static std::function<void(float)> padDown =
  ////static auto padDown = 
  //[this]() -> void {
  //  SetNavTypeFromSignal(std::string("inputPadDown"), 1.0f); };
  //RegisterSignal(std::string("inputPadDown"), this,
  //  padDown);
  //RegisterSignal(std::string("inputPadDown"), this,
  //  [](float frameTime) { SetNavTypeFromSignal(std::string("inputPadDown"), 1.0f); });
}
Ejemplo n.º 4
0
/*****************************************************************************
**
** FUNCTION NAME: main
**
** FUNCTION INPUTS:
**          
**
** FUNCTION DESCRIPTION
**         The program is convert the file which is the rip leave the audio file.    
**
** FUNCTION OUTPUTS:
**          
** HISTORY:
**
**           2008-6-30       HChen  Created.
**
*****************************************************************************
*/
int main(int argc, char *argv[])
{
    int nCurrConvertNum = 0;
    int nTotalTrackNum = 0;
    int nCodePercent = 0;
    int nPreNumPending = 0;
    int nNumPending = 0;
    DATA_CHANGED_STATUS eDataChange = DATA_UNKNOWN;

    RegisterSignal();
    LowItsPriority("Convert", "+19");
    Initialize();
	zripUpgare();	

    for(;;)
    {
        /*get the first record from db*/
        ZLock(&(ConvertTask.TaskItemLock));

        nNumPending = GetFirstTaskItemFromDB(&(ConvertTask.CurEncodeItem));
        ConvertTask.nItemCount = nNumPending;

        ZUnlock(&(ConvertTask.TaskItemLock));

        /*report update. why use at there(in order to handle the last record)*/
        HandleUpdatePendingTask();

        /*if no record, then exit*/
        if(nNumPending == 0)
        {
            ZLockClose(&(ConvertTask.TaskItemLock));
            ZDBClose(ConvertTask.ptrDBHandle);
            ZUtilStopThread(&(ConvertTask.ConverThread));
            ZFREE(gObjID);
            FreeConvertTask();
            exit(0);
        } 

        /*if the first's objid of the db not equal the converting objid, then kill the convert thread.*/ 
        /*in other word, the record of the db was deleted by other programm.*/ 
        if((ConvertTask.eThreadStatus == THREAD_RUNNING)
            &&(ConvertTask.eItemStatus == ITEM_ENCODING)
            &&(gObjID != NULL)&&(ConvertTask.CurEncodeItem.objID != NULL) 
            &&(strcmp(gObjID, ConvertTask.CurEncodeItem.objID)))
        {
            KillConvertProcess();
            CleanTheDirtyTrack(ConvertTask.DiscAudioSrcPath, 1);/*clear all track, include the src track*/
            goto Out;
        }
        else
        {
            /*the acctracknum and the numpending overlap one node, so minus 1*/
            /*calculate the convert percent*/

            if(ConvertTask.nAccTrackNum == 0 || nNumPending == 0)
            {
                nTotalTrackNum = ConvertTask.nAccTrackNum + nNumPending;
            }
            else
            {
                nTotalTrackNum = ConvertTask.nAccTrackNum + nNumPending - 1;
            }
            nCurrConvertNum = ConvertTask.nAccTrackNum;
            nCodePercent = (nCurrConvertNum*100)/nTotalTrackNum;

            /*Judge the data change.*/

            if(nPreNumPending != nNumPending)
            {
                nPreNumPending = nNumPending;
                eDataChange = DATA_CHANGED;
            }

            if((ConvertTask.PreObjID != NULL) && (gObjID != NULL))
            {
                if(strcmp(ConvertTask.PreObjID, gObjID))
                {
                    ZFREE(ConvertTask.PreObjID);
                    ConvertTask.PreObjID = strdup(gObjID);
                    eDataChange = DATA_CHANGED;
                }
            }

           /*Data changed, then report progress and update.*/

            if(eDataChange == DATA_CHANGED)
            {
                eDataChange = DATA_UNKNOWN;
                ReportConvertProgress(nTotalTrackNum, nCurrConvertNum, nCodePercent, gObjID);
            }
        }
        Out:
           sleep(3);
    }
   return 0;
}