예제 #1
0
void display_menu(){

  //bool we use to keep from redrawing everything
  run_once=false;

  drawMenu();
	wait1Msec(250);
  //while we are not pressing enter
  while(nNxtButtonPressed!=3){
    //if we press the left button
    //and it has been .5 seconds since the last button press
    //and we have an upper menu to go to
    if(nNxtButtonPressed==2 && time1[T1] > 500 && selection > 0){
      time1[T1] = 0; //reset time 1 so that we don't repeat
      change_menu(-1); //decrease selection
    }else if(nNxtButtonPressed==1 && time1[T1] > 500 && selection < 7){ //same as above but with right button and making sure we have a menu item below us
      change_menu(1); //increase selection
      time1[T1] = 0; //reset time
    }
  }
  while(nNxtButtonPressed==3); //do not double read enters so hang while holding enter
  eraseDisplay(); //clear display
  switch(selection) //get delection and make decision
  {
    case 0: //go back
      current_function=previous_function;//go back to prev page
      ClearSounds(); //clear sound buffer. not neccesary probably
    break;
    case 1:
      current_function=0;//log
    break;
  }
  wait1Msec(250); // don't immediately move on wait .25 seconds
}
예제 #2
0
파일: menu.c 프로젝트: lkundrak/koules
void
keys_keys ()
{
  static int      lscan_code;
  int             scan_code;
  scan_code = GetKey ();
  if (!scan_code && lscan_code)
    {
      keys[player][keynum] = lscan_code;
      keynum++;
#ifdef SOUND
      if (ssound)
	play_sound (S_CREATOR2);
#endif
      if (keynum > (rotation[player] ? 2 : 3))
	{
	  player++;
	  keynum = 0;
	  if (player > lastplayer)
	    {
	      change_menu ();
	      gamemode = MENU;
	    }
	}
    }
  lscan_code = scan_code;
}
예제 #3
0
파일: menu.c 프로젝트: lkundrak/koules
void
cmenu2 (unsigned char *message, int size)
{
  printf ("entering change menu");
  change_menu ();
  gamemode = MENU;
}
예제 #4
0
파일: menu.c 프로젝트: lkundrak/koules
void
joy_keys ()
{
  int             status, tmp;
  static int      lastbutton, button;
  if (read (joystickdevice[joystick], &js_data, JS_RETURN) <= 0)
    {
      perror ("Joystick");
      joystickplayer[joystick] = -2;
      gamemode = MENU;
      change_menu ();
      return;
    }
  button = lastbutton;
  lastbutton = js_data.buttons + IsPressedEnter ();
  if (joypos == 0)
    {
      if ((button == 0x00 || lastbutton != 0x00))
	return;
      joypos++;

      for (tmp = 0; js_data.x > 0xff; tmp++, js_data.x = js_data.x >> 1);
      js_data.x = tmp;
      for (tmp = 0; js_data.y > 0xff; tmp++, js_data.y = js_data.y >> 1);
      js_data.y = tmp;

       
      status = ioctl (joystickdevice[joystick], JS_SET_CAL, &js_data);
      if (status == -1)
	{
	  perror ("Joystick");
	}
      return;
    }
  if ((button == 0x00 || lastbutton != 0x00))
    return;

  calibrated[joystick] = 1;
  center[joystick][0] = js_data.x;
  center[joystick][1] = js_data.y;
  gamemode = MENU;
  change_menu ();
}
예제 #5
0
파일: menu.c 프로젝트: lkundrak/koules
static void
calibrate_init ()
{
  int             status;
  long            tmpl;

  if (joystickdevice[joystick]<0)
    {
      printf("Joystick %c not found during initialization.", joystick+'A');
      joystickplayer[joystick] = -2;
      gamemode = MENU;
      change_menu ();
      return;
    }	
	
  status = ioctl (joystickdevice[joystick], JS_GET_TIMELIMIT, &tmpl);
  if (status == -1)
    {
      perror ("Joystick");
      joystickplayer[joystick] = -2;
      gamemode = MENU;
      change_menu ();
      return;
    }	

  tmpl = 10; /* 10miliseconds */
  status = ioctl (joystickdevice[joystick], JS_SET_TIMELIMIT, &tmpl);
  if (status == -1)
    {
      perror ("Joystick");
      joystickplayer[joystick] = -2;
      gamemode = MENU;
      change_menu ();
      return;
    }
}
예제 #6
0
파일: menu.c 프로젝트: lkundrak/koules
static void
control_change ()
{
  int             player;
  player = (selected - 1) / 2;
#ifdef NETSUPPORT
  if (client && !control[player])
    return;
#endif
#ifdef MOUSE
   if(mouseplayer<0) mouseplayer=-1;
   if(mouseplayer>=nrockets) mouseplayer=-1;
#endif
#ifdef JOYSTICK
   if(joystickplayer[0]<0) joystickplayer[0]=-1;
   if(joystickplayer[0]>=nrockets) joystickplayer[0]=-1;
   if(joystickplayer[1]<0) joystickplayer[1]=-1;
   if(joystickplayer[1]>=nrockets) joystickplayer[1]=-1;
#ifdef NETSUPPORT
  if(client && !control[joystickplayer[0]]) joystickplayer[0]=-1;
  if(client && !control[joystickplayer[1]]) joystickplayer[1]=-1;
  if (client && !control[player])
    return;
#endif
#endif
#ifdef MOUSE
#ifdef NETSUPPORT
  if(client && !control[mouseplayer]) mouseplayer=-1;
#endif
#endif

   if (rotation[player]==1)
      {
         rotation[player] = 0;
#ifdef MOUSE
	 if (mouseplayer == -1 && !nomouse) mouseplayer = player;
#ifdef JOYSTICK
         else goto maybejoystick; 
	   /* mouse couldn't be chosen, but let's offer joystick if available*/
#endif
      }
   else if (player == mouseplayer)
      {
         mouseplayer = -1;
#endif
#ifdef JOYSTICK
#ifdef MOUSE
maybejoystick:;
#endif
         if((joystickplayer[0] == -1)&&(joystickdevice[0]>=0))
            {
               joystickplayer[0]=player;
	       joystickmul[0]=JOYMUL1;
	    }
         else if((joystickplayer[1] == -1)&&(joystickdevice[1]>=0))
            {
   	       joystickplayer[1]=player;
	       joystickmul[1]=JOYMUL1;
	    }
      }
   else if(player==joystickplayer[0])
      {
         if(joystickmul[0]==JOYMUL1)joystickmul[0]=JOYMUL2;
	 else
	    {
	       joystickplayer[0]=-1;
	       if((joystickplayer[1] == -1)&&(joystickdevice[1]>=0))
	          {
		     joystickplayer[1]=player;
                     joystickmul[1]=JOYMUL1;
	          }
	    }
      }
   else if(player==joystickplayer[1])
      {
	 if(joystickmul[1]==JOYMUL1)joystickmul[1]=JOYMUL2;
	 else joystickplayer[1]=-1;
#endif
      }
   else if (rotation[player]==0)
      {
         rotation[player] = 1;
      }
   change_menu ();
}