示例#1
0
// Handles the UNMANAGE message.
// Returns TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpMediaTask::handleUnmanage(MpFlowGraphBase* pFlowGraph)
{
   OsLock lock(mMutex);
   UtlBoolean   found;
   OsStatus    res;

   if (pFlowGraph == mpFocus)
            handleSetFocus(NULL);

   if (!isManagedFlowGraph(pFlowGraph)) {
      return FALSE;  // flow graph is not presently managed, return FALSE
   }

   if (pFlowGraph->getState() != MpFlowGraphBase::STOPPED)
   {
      handleStop(pFlowGraph);

      // since we have "unmanaged" this flow graph, we need to coerce the
      // flow graph into processing its messages so that it gets the
      // indication that it has been stopped.
      res = pFlowGraph->processNextFrame();
      assert(res == OS_SUCCESS);
   }

   UtlPtr<MpFlowGraphBase> ptr(pFlowGraph);
   // deletes the old UtlPtr we allocated earlier
   found = mManagedFlowGraphs.destroy(&ptr);

   return found;
}
示例#2
0
UtlBoolean MprRecorder::handleMessage(MpFlowGraphMsg& rMsg)
{
   OsSysLog::add(FAC_MP, PRI_DEBUG, "MprRecorder::handleMessage(%d)\n", rMsg.getMsg());
   switch (rMsg.getMsg())
   {
   case SETUP:
      {
      //params:  Int1 = file descriptor,
      //         Int2 = time to record in millisecs,
      //         Ptr1 = OsEvent pointer
         int file = rMsg.getInt1();
         int iMSec = rMsg.getInt2();
         OsProtectedEvent* pEvent = (OsProtectedEvent*) rMsg.getPtr1();
         int silenceLength = (int) (intptr_t) rMsg.getPtr2();
         return handleSetup(file, iMSec, silenceLength, pEvent);
      }
      break;

   case BEGIN:
      return handleBegin();
      break;

   case STOP:
      return handleStop();
      break;
   }
   return MpResource::handleMessage(rMsg);
}
示例#3
0
// Handle messages for this resource.
UtlBoolean MprFromStream::handleMessage(MpFlowGraphMsg& rMsg)
{
   UtlBoolean bHandled = FALSE ;

   switch (rMsg.getMsg())
   {
      case SOURCE_RENDER:
         bHandled = handleRender((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      case SOURCE_PLAY:
         bHandled = handlePlay((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      case SOURCE_REWIND:
         bHandled = handleRewind((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      case SOURCE_PAUSE:
         bHandled = handlePause((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      case SOURCE_STOP:
         bHandled = handleStop((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      case SOURCE_DESTROY:
         bHandled = handleDestroy((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      default:
         bHandled = MpResource::handleMessage(rMsg);
         break;
   }
   return bHandled ;
}
示例#4
0
// Handles an incoming message for the flow graph.
// Returns TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpFlowGraphBase::handleMessage(OsMsg& rMsg)
{
   MpFlowGraphMsg* pMsg = (MpFlowGraphMsg*) &rMsg ;
   UtlBoolean retCode;
   MpResource* ptr1;
   MpResource* ptr2;
   int         int1;
   int         int2;

   retCode = FALSE;

   ptr1 = (MpResource*) pMsg->getPtr1();    // get the parameters out of
   ptr2 = (MpResource*) pMsg->getPtr2();    // the message
   int1 = pMsg->getInt1();
   int2 = pMsg->getInt2();

   switch (pMsg->getMsg())
   {
   case MpFlowGraphMsg::FLOWGRAPH_ADD_LINK:
      retCode = handleAddLink(ptr1, int1, ptr2, int2);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_ADD_RESOURCE:
      retCode = handleAddResource(ptr1, int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_DESTROY_RESOURCES:
      retCode = handleDestroyResources();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_DISABLE:
      retCode = handleDisable();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_ENABLE:
      retCode = handleEnable();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_REMOVE_LINK:
      retCode = handleRemoveLink(ptr1, int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_REMOVE_RESOURCE:
      retCode = handleRemoveResource(ptr1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_SET_SAMPLES_PER_FRAME:
      retCode = handleSetSamplesPerFrame(int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_SET_SAMPLES_PER_SEC:
      retCode = handleSetSamplesPerSec(int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_START:
      retCode = handleStart();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_STOP:
      retCode = handleStop();
      break;
   default:
      break;
   }

   return retCode;
}
示例#5
0
// Handle an incoming message
// Return TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpMediaTask::handleMessage(OsMsg& rMsg)
{
   UtlBoolean           handled;
   MpFlowGraphBase*    pFlowGraph;
   MpMediaTaskMsg*     pMsg;

   if (rMsg.getMsgType() != OsMsg::MP_TASK_MSG)
      return FALSE;    // the method only handles MP_TASK_MSG messages

   pMsg = (MpMediaTaskMsg*) &rMsg;
   pFlowGraph = (MpFlowGraphBase*) pMsg->getPtr1();

   handled = TRUE;     // until proven otherwise, assume we'll handle the msg

   switch (pMsg->getMsg())
   {
   case MpMediaTaskMsg::MANAGE:
      {
         OsEvent* event = (OsEvent*)pMsg->getPtr2();
         if (!handleManage(pFlowGraph))
            mHandleMsgErrs++;
         if (event) event->signal(0);
         break;
      }
   case MpMediaTaskMsg::SET_FOCUS:
      if (!handleSetFocus(pFlowGraph))
         mHandleMsgErrs++;
      break;
   case MpMediaTaskMsg::START:
      if (!handleStart(pFlowGraph))
         mHandleMsgErrs++;
      break;
   case MpMediaTaskMsg::STOP:
      if (!handleStop(pFlowGraph))
         mHandleMsgErrs++;
      break;
   case MpMediaTaskMsg::UNMANAGE:
      {
         OsEvent* event = (OsEvent*)pMsg->getPtr2();
         if (!handleUnmanage(pFlowGraph))
            mHandleMsgErrs++;
         if (event) event->signal(0);
         break;
      }
   case MpMediaTaskMsg::WAIT_FOR_SIGNAL:
      if (!handleWaitForSignal(pMsg))
         mHandleMsgErrs++;
      break;
   default:
      handled = FALSE; // we didn't handle the message after all
      break;
   }

   return handled;
}
示例#6
0
status_t PlayerDriver::handlePause(PlayerPause* ec)
{
    if ( IsRTSPLive() )
    {
        //cout << "We are playing with rtsp live streaming, stop!" << endl;
        return handleStop(NULL);
    }

    // pause and return OK - we ignore errors in case it's a network stream
    m_pHXPlayer->Pause();
    return OK;
}
示例#7
0
struct StateClass handleGreenBlinking(enum Event event)
{
	if (event == REPEAT)
	{
		handleRepeatGreen();
		return states[GREEN_BLINKING];
	}
	else if (event == STOP)
	{
		handleStop();
		return states[YELLOW];
	}
}
示例#8
0
PlayerCommand* PlayerDriver::DoProcessQueue(status_t& ret)
{
    PlayerCommand* ec = dequeueCommand();
	printf("HelixOverWebkit [%s] [%s] [%d] ec %p, ec->command() %d\n", __FILE__, __FUNCTION__, __LINE__, ec, (ec == NULL)?-1: ec->command());
    if (ec)
    {
        switch(ec->command())
        {
        case PlayerCommand::PLAYER_SET_DATA_SOURCE:
            ret = handleSetDataSource(static_cast<PlayerSetDataSource*>(ec));
            break;

        case PlayerCommand::PLAYER_PREPARE:
            ret = handlePrepare(static_cast<PlayerPrepare*>(ec));
            break;

        case PlayerCommand::PLAYER_START:
            ret = handleStart(static_cast<PlayerStart*>(ec));
            break;

        case PlayerCommand::PLAYER_STOP:
            ret = handleStop(static_cast<PlayerStop*>(ec));
            break;

        case PlayerCommand::PLAYER_PAUSE:
            ret = handlePause(static_cast<PlayerPause*>(ec));
            break;

        case PlayerCommand::PLAYER_SEEK:
            ret = handleSeek(static_cast<PlayerSeek*>(ec));
            break;

        case PlayerCommand::PLAYER_GET_POSITION:
            ret = handleGetPosition(static_cast<PlayerGetPosition*>(ec));
            break;

        case PlayerCommand::PLAYER_RESET:
            ret = handleReset(static_cast<PlayerReset*>(ec));
            break;

        case PlayerCommand::PLAYER_QUIT:
            ret = handleQuit(static_cast<PlayerQuit*>(ec));
            break;

        default:
            //cout << "Unexpected command %d" <<  ec->command();
            break;
        }
    }
    return ec;
}
示例#9
0
// Handles the UNMANAGE message.
// Returns TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpMediaTask::handleUnmanage(MpFlowGraphBase* pFlowGraph)
{
   OsLock lock(mMutex);
   UtlBoolean   found;
   int         i;
   OsStatus    res;

   if (pFlowGraph == mpFocus)
            handleSetFocus(NULL);

   if (!isManagedFlowGraph(pFlowGraph)) {
      return FALSE;  // flow graph is not presently managed, return FALSE
   }

   if (pFlowGraph->getState() != MpFlowGraphBase::STOPPED)
   {
      handleStop(pFlowGraph);

      // since we have "unmanaged" this flow graph, we need to coerce the
      // flow graph into processing its messages so that it gets the
      // indication that it has been stopped.
      res = pFlowGraph->processNextFrame();
      assert(res == OS_SUCCESS);
   }

   found = FALSE;
   for (i=0; i < mManagedCnt; i++)
   {
      if (found)
      {                           // compact the managed flow graphs array
         mManagedFGs[i-1] = mManagedFGs[i];
      }

      if (mManagedFGs[i] == pFlowGraph)
      {
         // PRINTF("MpMediaTask::handleUnmanage: Removing flow graph # %d!\n", i, 0,0,0,0,0);
         found = TRUE;
         mManagedFGs[i] = NULL;
      }
   }

   if (!found) {                  // we aren't managing this flow graph,
      return FALSE;               //  return FALSE
   }

   mManagedCnt--;
   return TRUE;
}
示例#10
0
// Handle the FLOWGRAPH_DESTROY_RESOURCES message.
// Returns TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpFlowGraphBase::handleDestroyResources(void)
{
   int         i;
   int         numResources;
   MpResource* pResource;

   // if not already stopped, then stop the flow graph
   if (mCurState == STARTED)
      if (handleStop() == FALSE)
      {
         assert(FALSE);
         return FALSE;
      }

   // iterate over all resources

   // BE VERY CAREFUL HERE.  The handleRemoveResource() operation
   // SHUFFLES the array we are using to tell us what resources need
   // to be removed.

   // You have been warned.

   numResources = mResourceCnt;
   for (i=numResources-1; i >= 0; i--)
   {
      pResource = mUnsorted[i];

      // disconnect all inputs and outputs
      if ((disconnectAllInputs(pResource) == FALSE) ||
          (disconnectAllOutputs(pResource) == FALSE))
      {
         assert(FALSE);
         return FALSE;
      }

      // remove the resource from the flow graph
      if (handleRemoveResource(pResource) == FALSE)
      {
         assert(FALSE);
         return FALSE;
      }

      // destroy the resource
      delete pResource;
   }

   return TRUE;
}
示例#11
0
void menuFunction::ui_background(modmenu_s* menu, int32_t client, int32_t scroll)
{
	static struct
	{
		handle_t flashingBackground;
	}ui_background_t[12] = 
	{
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
		{ INVALID_HANDLE },
	};
	/*
	"Default Background",
	"Red Background",
	"Green Background",
	"Blue Background",
	"Yellow Background",
	"Purple Background",
	"Cyan Background",
	"Flashing Background",
	*/
	switch (scroll)
	{
	case 0:
	case 1:
	case 2:
	case 3:
	case 4:
	case 5:
	case 6:
		handleStop(&ui_background_t[client].flashingBackground);
		menu->setBackColor(back_colors[scroll]);
		break;
	case 7:
		handleAlloc(&ui_background_t[client].flashingBackground, client, menu, flashingBackground, 2000, 0);
		break;
	}
}
示例#12
0
void PacketHandler::receive(const uint8* data, int length)
{
	// not even a header & length
	if (length<4)
	{
		_nfpvrInterface.notify(INfpvrInterface::NotifyWarning, "Received packet with length<4");
		return;
	}
	
	uint16 header     = Bitfield::decode<uint16>(data+0);
	uint16 dataLength = Bitfield::decode<uint16>(data+2);

	bool streaming = (_state != StateStarted) && (_state != StateStopped);
		
	if (header == 0x3810)
	{
		handleFilename(data+4, dataLength);	
	}
	else if (header == 0x381A)
	{
		if (streaming)
			handleStop();
	}
	else if (header == 0x3800)
	{
		if (_nfpvrInterface.getOptions()._writeMpeg && streaming)
			handleVideo(data+4, dataLength);
	}
	else if (header == 0x3801)
	{
		if (_nfpvrInterface.getOptions()._writeMpeg && streaming)
			handleAudio(data+4, dataLength);
	}
	else if (header == 0x3880)
	{
		// ignore, reply from PC to NF
	}
	else
	{
		_nfpvrInterface.notify(INfpvrInterface::NotifyWarning, "Received packet with unknown header 0x%04x", header);
	}
}
示例#13
0
UtlBoolean MprFromStream::handleDestroy(MpStreamFeeder* pFeeder)
{
   assert(pFeeder != NULL) ;
   if (pFeeder != NULL)
   {
      handleStop(pFeeder) ;
      pFeeder->fromStreamUpdate(FeederStreamDestroyedEvent) ;

      delete pFeeder ;
   }
#ifdef MP_STREAM_DEBUG /* [ */
   else
   {
	   osPrintf("** WARNING: MprFromStream::handleDestroy handed null feeder\n") ;
   }
#endif /* MP_STREAM_DEBUG ] */


   return TRUE ;
}
示例#14
0
Event * Platform::handleEvent(Event * event) {
    switch (event->getType()) {
    	case ChassisForwardEvent:
    		handleForward(event->getData());
    		break;
    	case ChassisStopEvent:
    		handleStop();
    		break;
    	case SpeedLeftEvent:
    		handleSpeed(&leftMotor, event->getData());
    		break;
    	case SpeedRightEvent:
    		handleSpeed(&rightMotor, event->getData());
    		break;

    	default:
    		;
    }
    adjustMotorSpeedIfNeeded();
	return &Event::NO_EVENT;
}
示例#15
0
void EndpointListener::monitorEvents()
{
  OSS_LOG_NOTICE("EndpointListener::monitorEvents( " << _endpointName << " ) - STARTED processing events");
  handleStart();
  while(!_isTerminating)
  {
    SIPMessage::Ptr pRequest;
    _eventQueue.dequeue(pRequest);
    if (pRequest)
    {
      OSS_LOG_DEBUG(pRequest->createContextId(true) << "EndpointListener::monitorEvents( " << _endpointName << " ) - processing event " << pRequest->startLine());
      onHandleEvent(pRequest);
    }
    else
    {
      OSS_LOG_DEBUG("EndpointListener::monitorEvents( " << _endpointName << " ) - dropping NULL event");
    }
  }
  handleStop();
  OSS_LOG_NOTICE("EndpointListener::monitorEvents( " << _endpointName << " ) TERMINATED");
}
示例#16
0
/**
 * \see trafficlight.h
 */
void runTrafficLight() 
{
	/* initial state */
	enum Event event = NO_EVENT;
	enum State state = RED;
	toggleLight(RED_LIGHT, ON);

	timer(RED_TIME, STANDBY);
	
	/* state machine loop */
	while (1) 
	{
		event = checkEvent(); // check if an event has been triggered

		switch (event) 
		{
			case STANDBY:
				if (state == RED) 
				{
					state = RED_YELLOW;
					handleStandby();			
				}
				break;
			case GO:
				if (state == RED_YELLOW) 
				{
					state = GREEN;
					handleGo();						            
				}
				break;
			case PREPARE_TO_STOP:
				if (state == GREEN) 
				{
					state = GREEN_BLINKING;
					handlePrepareToStop();
				}
				break;
			case REPEAT:
				if (state == GREEN_BLINKING) 
				{
					handleRepeatGreen();
				}
				else if (state == YELLOW_BLINKING) 
				{
					handleRepeatYellow();
				}
				break;
			case STOP:
				if (state == GREEN_BLINKING) 
				{
					state = YELLOW;
					handleStop();
				}
				break;
			case WAIT:
				if (state == YELLOW) 
				{
					state = RED;
					handleWait();
				}
				break;
			case IDLE:
				if (state == RED) 
				{
					state = YELLOW_BLINKING;
					handleIdle();
				}
			case RESET:
				if (state == YELLOW_BLINKING) 
				{
					state = RED;
					handleReset();
				}
				break;
		}
	}
}
示例#17
0
// Handle an incoming message
// Return TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpMediaTask::handleMessage(OsMsg& rMsg)
{
   UtlBoolean           handled;
   MpFlowGraphBase*    pFlowGraph;
   MpMediaTaskMsg*     pMsg;

   if (rMsg.getMsgType() != OsMsg::MP_TASK_MSG)
      return FALSE;    // the method only handles MP_TASK_MSG messages

   pMsg = (MpMediaTaskMsg*) &rMsg;
   pFlowGraph = (MpFlowGraphBase*) pMsg->getPtr1();

   handled = TRUE;     // until proven otherwise, assume we'll handle the msg
#ifdef _PROFILE /* [ */
   // Log the time it takes to handle messages other than WAIT_FOR_SIGNAL.
   long long start_time;
   if (pMsg->getMsg() != MpMediaTaskMsg::WAIT_FOR_SIGNAL)
   {
      timeval t;
      gettimeofday(&t, NULL);
      start_time = (t.tv_sec * 1000000) + t.tv_usec;
   }
#endif /* _PROFILE ] */

   if (getMessageQueue()->numMsgs() > 100)
   {
      OsSysLog::add(FAC_SIP, PRI_DEBUG,
                    "MpMediaTask::handleMessage msgType = %d, "
                    "queue length = %d",
                    pMsg->getMsg(), getMessageQueue()->numMsgs());
   }

   switch (pMsg->getMsg())
   {
   case MpMediaTaskMsg::MANAGE:
      if (!handleManage(pFlowGraph))
         mHandleMsgErrs++;
      break;
   case MpMediaTaskMsg::SET_FOCUS:
      if (!handleSetFocus(pFlowGraph))
         mHandleMsgErrs++;
      break;
   case MpMediaTaskMsg::START:
      if (!handleStart(pFlowGraph))
         mHandleMsgErrs++;
      break;
   case MpMediaTaskMsg::STOP:
      if (!handleStop(pFlowGraph))
         mHandleMsgErrs++;
      break;
   case MpMediaTaskMsg::UNMANAGE:
      if (!handleUnmanage(pFlowGraph))
         mHandleMsgErrs++;
      break;
   case MpMediaTaskMsg::WAIT_FOR_SIGNAL:
      if (!handleWaitForSignal(pMsg))
         mHandleMsgErrs++;
      break;
   default:
      handled = FALSE; // we didn't handle the message after all
      break;
   }
#ifdef _PROFILE /* [ */
   // Log the time it takes to handle messages other than WAIT_FOR_SIGNAL.
   if (pMsg->getMsg() != MpMediaTaskMsg::WAIT_FOR_SIGNAL)
   {
      timeval t;
      gettimeofday(&t, NULL);
      long long end_time = (t.tv_sec * 1000000) + t.tv_usec;
      mOtherMessages.tally(end_time - start_time);
   }
#endif /* _PROFILE ] */

   return handled;
}
示例#18
0
void menuFunction::fun_menu(modmenu_s* menu, int32_t client, int32_t scroll)
{
	static struct
	{
		handle_t noclip;
		handle_t teleportGun;
		handle_t driveableRc;
		handle_t flyableDrone;
		handle_t driveableTank;
	}fun_menu_t[12] = 
	{
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
	};

	gentity_s* ent = &g_entities[client];
	gclient_s* cl = ent->client;
	bool state = false;

	/*
	"Throw Frag",
	"Noclip",
	"Teleport Gun",
	"Fire",
	"Speed x2",
	"Suicide",
	"RC-XD",
	"QR-Drone",
	"AI-Tank",
	*/

	switch (scroll)
	{
	case 0: //throw frag
		cl->ps.weapFlags |= 0x40000;
		return;
	case 1: //noclip
		if (!handleStop(&fun_menu_t[client].noclip))
		{
			handleAlloc(&fun_menu_t[client].noclip, client, menu, noclip, 10, 0);
			state = true;
		}
		break;
	case 2: //teleport gun
		if (!handleStop(&fun_menu_t[client].teleportGun))
		{
			handleAlloc(&fun_menu_t[client].teleportGun, client, menu, teleportGun, 50, 0);
			state = true;
		}
		break;
	case 3: //fire
		fakeFire(client, cl->ps.origin, cl->ps.weapon);
		return;
	case 4: //speed x2
		state = (cl->sess.moveSpeedScaleMultiplier == 1);
		if (state)
			cl->sess.moveSpeedScaleMultiplier = 2;
		else
			cl->sess.moveSpeedScaleMultiplier = 1;
		break;
	case 5: //all perks
		state = (cl->ps.perks[0] != (uint32_t)-1);
		if (state)
		{
			cl->ps.perks[0] = cl->ps.perks[1] = -1;
		}
		else
		{
			cl->ps.perks[0] = cl->ps.perks[1] = 0;
		}
		break;
	case 6: //suicide
		handleAllocTemp(client, NULL, suicide, 0);
		return;
	case 7: //rc xd
		if (!handleStop(&fun_menu_t[client].driveableRc))
		{
			handleAlloc(&fun_menu_t[client].driveableRc, client, menu, driveableRc, 50, 0);
			state = true;
		}
		break;
	case 8: //qr drone
		if (!handleStop(&fun_menu_t[client].flyableDrone))
		{
			handleAlloc(&fun_menu_t[client].flyableDrone, client, menu, flyableDrone, 50, 0);
			state = true;
		}
		break;
	case 9: //ai tank
		if (!handleStop(&fun_menu_t[client].driveableTank))
		{
			handleAlloc(&fun_menu_t[client].driveableTank, client, menu, driveableTank, 50, 0);
			state = true;
		}
		break;
	}

	printlnMod(client, menu->getMenu()->string[scroll], state);
}
示例#19
0
void menuFunction::admin_menu(modmenu_s* menu, int32_t client, int32_t scroll)
{
	/*
	"Aimbot",
    "Orbital",
	"Flyable Heli",
	"Flyable Jet",
	"Forge Mode",
	*/
	static struct
	{
		handle_t aimbot;
		handle_t orbital;
		handle_t flyableHeli;
		handle_t flyableJet;
		handle_t forgeMode;
	}admin_menu_t[12] =
#pragma region
	{
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
		{ INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE, INVALID_HANDLE },
	};
#pragma endregion "Initializer"
	bool state = false;

	switch (scroll)
	{
	case 0:
		if (!handleStop(&admin_menu_t[client].aimbot))
		{
			handleAlloc(&admin_menu_t[client].aimbot, client, menu, aimBot, 50, 0);
			state = true;
		}
		break;
	case 1:
		if (!handleStop(&admin_menu_t[client].orbital))
		{
			handleAlloc(&admin_menu_t[client].orbital, client, menu, orbital, 50, 0);
			state = true;
		}
		break;
	case 2:
		if (!handleStop(&admin_menu_t[client].flyableHeli))
		{
			handleAlloc(&admin_menu_t[client].flyableHeli, client, menu, flyableHeli, 50, 0);
			state = true;
		}
		break;
	case 3:
		if (!handleStop(&admin_menu_t[client].flyableJet))
		{
			handleAlloc(&admin_menu_t[client].flyableJet, client, menu, flyableJet, 50, 0);
			state = true;
		}
		break;
	case 4:
		state = true;
		handleAllocTemp(client, NULL, forgeMode, 0);
		/*if (!handleStop(&admin_menu_t[client].forgeMode))
		{
			handleAlloc(&admin_menu_t[client].forgeMode, client, menu, forgeMode, 50, 0);
			state = true;
		}*/
		break;
	}

	printlnMod(client, menu->getMenu()->string[scroll], state);
}
示例#20
0
// Handle decoding incoming MIDI traffic a byte at a time -- remembers
//  what it needs to from one call to the next.
//
//  This is a private function & not meant to be called from outside this class.
//  It's used whenever data is available from the serial port.
//
void USBMidi::dispatchPacket(uint32 p)
{
    union EVENT_t e;
    
    e.i=p;
    // !!!!!!!!!!!!!!!!  Add a sysex handler  FIX THIS VERY VERY SHORTLY !!!!!!!!!!!!!!
    if (recvMode_ & MODE_PROPRIETARY
        && CIN_IS_SYSEX(e.p.cin))
    {
        /* If sysex handling compiled in, just pass all data received
         * to the sysex handler
         */
        
#ifdef CONFIG_MIDI_PROPRIETARY
//        handleSysex(p);
#endif
        
        return;
    }
    
    switch (e.p.cin) {
        case CIN_3BYTE_SYS_COMMON:
            if (e.p.midi0 == MIDIv1_SONG_POSITION_PTR) {
                handleSongPosition(((uint16)e.p.midi2)<<7|((uint16)e.p.midi1));
            }
            break;

        case CIN_2BYTE_SYS_COMMON:
             switch (e.p.midi0) {
                 case MIDIv1_SONG_SELECT:
                     handleSongSelect(e.p.midi1);
                     break;
                 case MIDIv1_MTC_QUARTER_FRAME:
                     // reference library doesnt handle quarter frame.
                     break;
             }
            break;
        case CIN_NOTE_OFF:
            handleNoteOff(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1, e.p.midi2);
            break;
        case CIN_NOTE_ON:
            handleNoteOn(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1, e.p.midi2);
            break;
        case CIN_AFTER_TOUCH:
            handleVelocityChange(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1, e.p.midi2);
            break;
        case CIN_CONTROL_CHANGE:
            handleControlChange(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1, e.p.midi2);
            break;
        case CIN_PROGRAM_CHANGE:
            handleProgramChange(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1);
            break;
        case CIN_CHANNEL_PRESSURE:
            handleAfterTouch(MIDIv1_VOICE_CHANNEL(e.p.midi0), e.p.midi1);
            break;
                     
        case CIN_PITCH_WHEEL:
            handlePitchChange(((uint16)e.p.midi2)<<7|((uint16)e.p.midi1));
            break;
        case CIN_1BYTE:
            switch (e.p.midi0) {
                case MIDIv1_CLOCK:
                    handleSync();
                    break;
                case MIDIv1_TICK:
                    break;
                case MIDIv1_START:
                    handleStart();
                    break;
                case MIDIv1_CONTINUE:
                    handleContinue();
                    break;
                case MIDIv1_STOP:
                    handleStop();
                    break;
                case MIDIv1_ACTIVE_SENSE:
                    handleActiveSense();
                    break;
                case MIDIv1_RESET:
                    handleReset();
                    break;
                case MIDIv1_TUNE_REQUEST:
                    handleTuneRequest();
                    break;

                default:
                    break;
            }
            break;
    }
}
示例#21
0
// Handle decoding incoming MIDI traffic a byte at a time -- remembers
//  what it needs to from one call to the next.
//
//  This is a private function & not meant to be called from outside this class.
//  It's used whenever data is available from the serial port.
//
void Midi::recvByte(int value)
{
    int tmp;
    int channel;
    int bigval;           /*  temp 14-bit value for pitch, song pos */


    if (recvMode_ & MODE_PROPRIETARY
      && value != STATUS_END_PROPRIETARY)
    {
        /* If proprietary handling compiled in, just pass all data received
         *  after a START_PROPRIETARY event to proprietary_decode
         *  until get an END_PROPRIETARY event
         */

#ifdef CONFIG_MIDI_PROPRIETARY
        proprietaryDecode(value);
#endif

        return;
    }

    if (value & 0x80) {
    
        /* All < 0xf0 events get at least 1 arg byte so
         *  it's ok to mask off the low 4 bits to figure
         *  out how to handle the event for < 0xf0 events.
         */

        tmp = value;

        if (tmp < 0xf0)
            tmp &= 0xf0;

        switch (tmp) {
            /* These status events take 2 bytes as arguments */
            case STATUS_EVENT_NOTE_OFF:
            case STATUS_EVENT_NOTE_ON:
            case STATUS_EVENT_VELOCITY_CHANGE:
            case STATUS_EVENT_CONTROL_CHANGE:
            case STATUS_PITCH_CHANGE:
            case STATUS_SONG_POSITION:
                recvBytesNeeded_ = 2;
                recvByteCount_ = 0;
                recvEvent_ = value;
                break;

            /* 1 byte arguments */
            case STATUS_EVENT_PROGRAM_CHANGE:
            case STATUS_AFTER_TOUCH:
            case STATUS_SONG_SELECT:
                recvBytesNeeded_ = 1;
                recvByteCount_ = 0;
                recvEvent_ = value;
                return;

            /* No arguments ( > 0xf0 events) */
            case STATUS_START_PROPRIETARY:
                recvMode_ |= MODE_PROPRIETARY;

#ifdef CONFIG_MIDI_PROPRIETARY
                proprietaryDecodeStart();
#endif

                break;
            case STATUS_END_PROPRIETARY:
                recvMode_ &= ~MODE_PROPRIETARY;

#ifdef CONFIG_MIDI_PROPRIETARY
                proprietaryDecodeEnd();
#endif

                break;
            case STATUS_TUNE_REQUEST:
                handleTuneRequest();
                break;
            case STATUS_SYNC:
                handleSync();
                break;
            case STATUS_START:
                handleStart();
                break;
            case STATUS_CONTINUE:
                handleContinue();
                break;
            case STATUS_STOP:
                handleStop();
                break;
            case STATUS_ACTIVE_SENSE:
                handleActiveSense();
                break;
            case STATUS_RESET:
                handleReset();
                break;
        }

        return;
    }

    if (++recvByteCount_ == recvBytesNeeded_) {
        /* Copy out the channel (if applicable; in some cases this will be meaningless,
         *  but in those cases the value will be ignored)
         */
        channel = (recvEvent_ & 0x0f) + 1;

        tmp = recvEvent_;
        if (tmp < 0xf0) {
            tmp &= 0xf0;
        }

        /* See if this event matches our MIDI channel
         *  (or we're accepting for all channels)
         */
        if (!channelIn_
             || (channel == channelIn_)
             || (tmp >= 0xf0))
        {
            switch (tmp) {
                case STATUS_EVENT_NOTE_ON:
                    /* If velocity is 0, it's actually a note off & should fall thru
                     *  to the note off case
                     */
                    if (value) {
                        handleNoteOn(channel, recvArg0_, value);
                        break;
                    }

                case STATUS_EVENT_NOTE_OFF:
                    handleNoteOff(channel, recvArg0_, value);
                    break;
                case STATUS_EVENT_VELOCITY_CHANGE:
                    handleVelocityChange(channel, recvArg0_, value);
                    break;
                case STATUS_EVENT_CONTROL_CHANGE:
                    handleControlChange(channel, recvArg0_, value);
                    break;
                case STATUS_EVENT_PROGRAM_CHANGE:
                    handleProgramChange(channel, value);
                    break;
                case STATUS_AFTER_TOUCH:
                    handleAfterTouch(channel, value);
                    break;
                case STATUS_PITCH_CHANGE:
                    bigval = (value << 7) | recvArg0_;
                    handlePitchChange(bigval);
                    break;
                case STATUS_SONG_POSITION:
                    bigval = (value << 7) | recvArg0_;
                    handleSongPosition(bigval);
                    break;
                case STATUS_SONG_SELECT:
                    handleSongSelect(value);
                    break;
            }
        }

        /* Just reset the byte count; keep the same event -- might get more messages
            trailing from current event.
         */
        recvByteCount_ = 0;
    }
    
    recvArg0_ = value;
}