コード例 #1
0
ファイル: sqUnixEvent.c プロジェクト: mohamedfarag/RoarVM
static sqInt getButtonState(void)
{
  /* red button honours the modifiers:
   *	red+ctrl    = yellow button
   *	red+command = blue button
   */
  int buttons= buttonState;
  int modifiers= modifierState;
  if ((buttons == RedButtonBit) && modifiers)
    {
      int yellow= swapBtn ? BlueButtonBit   : YellowButtonBit;
      int blue=   swapBtn ? YellowButtonBit : BlueButtonBit;
      switch (modifiers)
	{
	case CtrlKeyBit:    buttons= yellow; modifiers &= ~CtrlKeyBit;    break;
	case CommandKeyBit: buttons= blue;   modifiers &= ~CommandKeyBit; break;
	}
    }
#if DEBUG_MOUSE_EVENTS
  printf("BUTTONS");
  printModifiers(modifiers);
  printButtons(buttons);
  printf("\n");
#endif
  return buttons | (modifiers << 3);
}
コード例 #2
0
ファイル: board.c プロジェクト: AWRyder/contiki
void boardPrintStringDescription(void)
{
  int8u i = 0;

  while (boardList[i] != NULL) {
    if ((boardDescription == boardList[i]) || (boardDescription == NULL)) {
      BoardResourcesType *ptr = boardList[i];
      printf ("*************************************\r\n");
      printf ("Board name = %s\r\n", ptr->name);
      printf ("*************************************\r\n");
      printLeds(ptr->leds);
      printButtons(ptr->buttons);
      if (ptr->mems) {
	printf ("MEMS = %s\r\n", ptr->mems->name);
      }
      if (ptr->temperatureSensor) {
	printf ("Temp sensor = %s, port:%s, pin:%d, adcFix:%s\r\n",
		ptr->temperatureSensor->name,
		PORT_NAME(ptr->temperatureSensor->gpioPort),
		ptr->temperatureSensor->gpioPin,
		ptr->temperatureSensor->adcFix ? "Yes" : "No"
		);
      }
      printf ("EEProm:%s\r\n", ptr->EEProm ? "Yes" : "No");
      printf ("PC i/f:%s\r\n", ptr->FTDInotSTM32 ? "FTDI" : "STM32F");
      printf ("Power Amplifier:%s\r\n", ptr->PowerAmplifier ? "Yes" : "No");
    }
    i++;
  }
  return NULL;
}
コード例 #3
0
ファイル: sqUnixEvent.c プロジェクト: mohamedfarag/RoarVM
static void recordDragEvent(int dragType, int numFiles)
{
  int state= getButtonState();
  sqDragDropFilesEvent *evt= allocateDragEvent();
  evt->dragType= dragType;
  evt->x= mousePosition.x;
  evt->y= mousePosition.y;
  evt->modifiers= (state >> 3);
  evt->numFiles= numFiles;
  evt->windowIndex= 0;
  signalInputEvent();
#if DEBUG_EVENTS
  printf("EVENT: drag (%d,%d)", mousePosition.x, mousePosition.y);
  printModifiers(state >> 3);
  printButtons(state & 7);
  printf("\n");
#endif
}
コード例 #4
0
ファイル: sqUnixEvent.c プロジェクト: mohamedfarag/RoarVM
static void recordMouseEvent(void)
{
  int state= getButtonState();
  sqMouseEvent *evt= allocateMouseEvent();
  evt->x= mousePosition.x;
  evt->y= mousePosition.y;
  evt->buttons= (state & 0x7);
  evt->modifiers= (state >> 3);
  evt->nrClicks=
    evt->windowIndex= 0;
  signalInputEvent();
#if DEBUG_MOUSE_EVENTS
  printf("EVENT: mouse (%d,%d)", mousePosition.x, mousePosition.y);
  printModifiers(state >> 3);
  printButtons(state & 7);
  printf("\n");
#endif
}
コード例 #5
0
ファイル: DeviceTest.cpp プロジェクト: jrevote/3DA-Vrui
int main(int argc,char* argv[])
	{
	/* Parse command line: */
	char* serverName=0;
	int trackerIndex=0;
	int printMode=0;
	bool printButtonStates=false;
	bool printNewlines=false;
	for(int i=1;i<argc;++i)
		{
		if(argv[i][0]=='-')
			{
			if(strcasecmp(argv[i],"-t")==0||strcasecmp(argv[i],"--trackerIndex")==0)
				{
				++i;
				trackerIndex=atoi(argv[i]);
				}
			else if(strcasecmp(argv[i],"-alltrackers")==0)
				trackerIndex=-1;
			else if(strcasecmp(argv[i],"-p")==0)
				printMode=0;
			else if(strcasecmp(argv[i],"-o")==0)
				printMode=1;
			else if(strcasecmp(argv[i],"-f")==0)
				printMode=2;
			else if(strcasecmp(argv[i],"-v")==0)
				printMode=3;
			else if(strcasecmp(argv[i],"-b")==0)
				printButtonStates=true;
			else if(strcasecmp(argv[i],"-n")==0)
				printNewlines=true;
			}
		else
			serverName=argv[i];
		}
	
	if(serverName==0)
		{
		std::cerr<<"Usage: "<<argv[0]<<" [(-t | --trackerIndex) <trackerIndex>] [-p | -o | -f | -v] [-b] <serverName:serverPort>"<<std::endl;
		return 1;
		}
	
	/* Initialize device client: */
	Vrui::VRDeviceClient* deviceClient=0;
	try
		{
		/* Split the server name into hostname:port: */
		char* colonPtr=0;
		for(char* cPtr=serverName;*cPtr!='\0';++cPtr)
			if(*cPtr==':')
				colonPtr=cPtr;
		int portNumber=0;
		if(colonPtr!=0)
			{
			portNumber=atoi(colonPtr+1);
			*colonPtr='\0';
			}
		deviceClient=new Vrui::VRDeviceClient(serverName,portNumber);
		}
	catch(std::runtime_error error)
		{
		std::cerr<<"Caught exception "<<error.what()<<" while initializing VR device client"<<std::endl;
		return 1;
		}
	
	/* Print output header line: */
	switch(printMode)
		{
		case 0:
			std::cout<<"  Pos X    Pos Y    Pos Z   "<<std::endl;
			break;
		
		case 1:
			std::cout<<"  Pos X    Pos Y    Pos Z      Axis X   Axis Y   Axis Z    Angle  "<<std::endl;
			break;
		
		case 2:
			std::cout<<" Pos X  Pos Y  Pos Z     XA X   XA Y   XA Z     YA X   YA Y   YA Z     ZA X   ZA Y   ZA Z  "<<std::endl;
			break;
		}
	
	/* Run main loop: */
	deviceClient->activate();
	deviceClient->startStream();
	bool loop=true;
	Misc::Timer t;
	int numPackets=0;
	while(loop)
		{
		/* Print new device state: */
		if(!printNewlines)
			std::cout<<"\r";
		deviceClient->lockState();
		const Vrui::VRDeviceState& state=deviceClient->getState();
		switch(printMode)
			{
			case 0:
				if(trackerIndex<0)
					{
					printTrackerPos(state,0);
					for(int i=1;i<state.getNumTrackers();++i)
						{
						std::cout<<" ";
						printTrackerPos(state,i);
						}
					}
				else
					printTrackerPos(state,trackerIndex);
				break;
			
			case 1:
				printTrackerPosOrient(state,trackerIndex);
				break;
			
			case 2:
				printTrackerFrame(state,trackerIndex);
				break;
			
			case 3:
				printValuators(state);
				break;
			}
		if(printButtonStates)
			{
			std::cout<<" ";
			printButtons(state);
			}
		deviceClient->unlockState();
		if(printNewlines)
			std::cout<<std::endl;
		else
			std::cout<<std::flush;
		
		/* Check for a key press event: */
		fd_set readFdSet;
		FD_ZERO(&readFdSet);
		FD_SET(fileno(stdin),&readFdSet);
		struct timeval timeout;
		timeout.tv_sec=0;
		timeout.tv_usec=0;
		bool dataWaiting=select(fileno(stdin)+1,&readFdSet,0,0,&timeout)>=0&&FD_ISSET(fileno(stdin),&readFdSet);
		if(dataWaiting)
			loop=false;
		
		if(loop)
			{
			/* Wait for next packet: */
			deviceClient->getPacket();
			++numPackets;
			}
		}
	std::cout<<std::endl;
	t.elapse();
	std::cout<<"Received "<<numPackets<<" device data packets in "<<t.getTime()*1000.0<<" ms ("<<double(numPackets)/t.getTime()<<" packets/s)"<<std::endl;
	deviceClient->stopStream();
	deviceClient->deactivate();
	
	/* Clean up and terminate: */
	delete deviceClient;
	return 0;
	}