Пример #1
0
int PERLinuxJoyHandleEvents(void)
{
   struct js_event evt;

   if (hJOY == -1) return -1;

   while (read(hJOY, &evt, sizeof(struct js_event)) > 0)
   {
      if (evt.value != 0)
      {
         PerKeyDown(PACKEVENT(evt));
      }
      else
      {
         PerKeyUp(PACKEVENT(evt));
         PerKeyUp(0x10000 | PACKEVENT(evt));
      }
   }

   // execute yabause
   if ( YabauseExec() != 0 )
   {
      return -1;
   }
   
   // return success
   return 0;
}
Пример #2
0
int PERDXHandleEvents(void)
{
   PollKeys();

   if (YabauseExec() != 0)
      return -1;

   return 0;
}
Пример #3
0
void
Java_org_yabause_android_YabauseRunnable_deinit( JNIEnv* env )
{
    int slot = GetSaveSlot();
    if (slot != -1)
    {
        const char * dirpath = GetSavesPath();
        SetOSDToggle(0);
        DisableAutoFrameSkip();
        g_swapped = 0;
        while(! g_swapped)
            YabauseExec();
        YabSaveStateSlot(dirpath, slot);
    }

    YabauseDeInit();
}
Пример #4
0
void
Java_org_yabause_android_YabauseRunnable_exec( JNIEnv* env )
{
    YabauseExec();
}
Пример #5
0
int PERSDLJoyHandleEvents(void) {
	int joyId;
	int i;
	int j;
	SDL_Joystick* joy;
	Sint16 cur;
	Uint8 buttonState;
	Uint8 newHatState;
	Uint8 oldHatState;
	int hatValue;
	
	// update joysticks states
	SDL_JoystickUpdate();
	
	// check each joysticks
	for ( joyId = 0; joyId < SDL_PERCORE_JOYSTICKS_INITIALIZED; joyId++ )
	{
		joy = SDL_PERCORE_JOYSTICKS[ joyId ].mJoystick;
		
		if ( !joy )
		{
			continue;
		}
		
		// check axis
		for ( i = 0; i < SDL_JoystickNumAxes( joy ); i++ )
		{
			cur = SDL_JoystickGetAxis( joy, i );

			PerAxisValue((joyId << 18) | SDL_MEDIUM_AXIS_VALUE | i, (u8)(((int)cur+32768) >> 8));
			
			if ( cur < -SDL_MEDIUM_AXIS_VALUE )
			{
				PerKeyUp( (joyId << 18) | SDL_MAX_AXIS_VALUE | i );
				PerKeyDown( (joyId << 18) | SDL_MIN_AXIS_VALUE | i );
			}
			else if ( cur > SDL_MEDIUM_AXIS_VALUE )
			{
				PerKeyUp( (joyId << 18) | SDL_MIN_AXIS_VALUE | i );
				PerKeyDown( (joyId << 18) | SDL_MAX_AXIS_VALUE | i );
			}
			else
			{
				PerKeyUp( (joyId << 18) | SDL_MIN_AXIS_VALUE | i );
				PerKeyUp( (joyId << 18) | SDL_MAX_AXIS_VALUE | i );
			}
		}
		
		// check buttons
		for ( i = 0; i < SDL_JoystickNumButtons( joy ); i++ )
		{
			buttonState = SDL_JoystickGetButton( joy, i );
			
			if ( buttonState == SDL_BUTTON_PRESSED )
			{
				PerKeyDown( (joyId << 18) | (i +1) );
			}
			else if ( buttonState == SDL_BUTTON_RELEASED )
			{
				PerKeyUp( (joyId << 18) | (i +1) );
			}
		}

		// check hats
		for ( i = 0; i < SDL_JoystickNumHats( joy ); i++ )
		{
			newHatState = SDL_JoystickGetHat( joy, i );
			oldHatState = SDL_PERCORE_JOYSTICKS[ joyId ].mHatStatus[ i ];

			for ( j = 0 ; j < SDL_HAT_VALUES_NUM; j++ )
			{
				hatValue = SDL_HAT_VALUES[ j ];
				if ( oldHatState & hatValue && ~newHatState & hatValue )
				{
					PerKeyUp( (joyId << 18) | SDL_HAT_VALUE | (hatValue << 4) | i );
				}
			}
			for ( j = 0 ; j < SDL_HAT_VALUES_NUM; j++ )
			{
				hatValue = SDL_HAT_VALUES[ j ];
				if ( ~oldHatState & hatValue && newHatState & hatValue )
				{
					PerKeyDown( (joyId << 18) | SDL_HAT_VALUE | (hatValue << 4) | i);
				}
			}

			SDL_PERCORE_JOYSTICKS[ joyId ].mHatStatus[ i ] = newHatState;
		}
	}
	
	// execute yabause
	if ( YabauseExec() != 0 )
	{
		return -1;
	}
	
	// return success
	return 0;
}
Пример #6
0
int PERDCHandleEvents(void)	{
    maple_device_t *dev;

    dev = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
    if(dev != NULL) {
        cont_state_t *state = (cont_state_t *) maple_dev_status(dev);

        if(state != NULL)   {
            if(state->buttons & CONT_DPAD_UP)
                *pad1->padbits &= 0xEF;
            else
                *pad1->padbits |= 0x10;

            if(state->buttons & CONT_DPAD_DOWN)
                *pad1->padbits &= 0xDF;
            else
                *pad1->padbits |= 0x20;

            if(state->buttons & CONT_DPAD_RIGHT)
                *pad1->padbits &= 0x7F;
            else
                *pad1->padbits |= 0x80;

            if(state->buttons & CONT_DPAD_LEFT)
                *pad1->padbits &= 0xBF;
            else
                *pad1->padbits |= 0x40;

            if(state->buttons & CONT_START)
                *pad1->padbits &= 0xF7;
            else
                *pad1->padbits |= 0x08;

            if(state->buttons & CONT_A)
                *pad1->padbits &= 0xFB;
            else
                *pad1->padbits |= 0x04;

            if(state->buttons & CONT_B)
                *pad1->padbits &= 0xFE;
            else
                *pad1->padbits |= 0x01;

            if(state->buttons & CONT_X)
                *(pad1->padbits + 1) &= 0xBF;
            else
                *(pad1->padbits + 1) |= 0x40;

            if(state->buttons & CONT_Y)
                *(pad1->padbits + 1) &= 0xDF;
            else
                *(pad1->padbits + 1) |= 0x20;

            if(state->rtrig > 20)
                *(pad1->padbits + 1) &= 0x7F;
            else
                *(pad1->padbits + 1) |= 0x80;

            if(state->ltrig > 20)
                *(pad1->padbits + 1) &= 0xF7;
            else
                *(pad1->padbits + 1) |= 0x08;

            if(state->joyx > 20)
                *pad1->padbits &= 0xFD;
            else
                *pad1->padbits |= 0x02;

            if(state->joyy > 20)
                *(pad1->padbits + 1) &= 0xEF;
            else
                *(pad1->padbits + 1) |= 0x10;

        }
    }

    YabauseExec();

	return 0;
}
Пример #7
0
static int PERLIBRETROHandleEvents(void)
{
   unsigned i = 0;

   for(i = 0; i < players; i++)
   {
      int analog_left_x = 0;
      int analog_left_y = 0;

      switch(pad_type[i])
      {
         case RETRO_DEVICE_ANALOG:
            analog_left_x = input_state_cb(i, RETRO_DEVICE_ANALOG,
                  RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X);

            PerAxisValue((i << 8) + PERANALOG_AXIS1, (u8)((analog_left_x + 0x8000) >> 8));

            analog_left_y = input_state_cb(i, RETRO_DEVICE_ANALOG,
                  RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y);

            PerAxisValue((i << 8) + PERANALOG_AXIS2, (u8)((analog_left_y + 0x8000) >> 8));
         case RETRO_DEVICE_JOYPAD:

            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP))
               PerKeyDown((i << 8) + PERPAD_UP);
            else
               PerKeyUp((i << 8) + PERPAD_UP);
            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN))
               PerKeyDown((i << 8) + PERPAD_DOWN);
            else
               PerKeyUp((i << 8) + PERPAD_DOWN);
            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT))
               PerKeyDown((i << 8) + PERPAD_LEFT);
            else
               PerKeyUp((i << 8) + PERPAD_LEFT);
            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT))
               PerKeyDown((i << 8) + PERPAD_RIGHT);
            else
               PerKeyUp((i << 8) + PERPAD_RIGHT);

            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y))
               PerKeyDown((i << 8) + PERPAD_X);
            else
               PerKeyUp((i << 8) + PERPAD_X);

            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B))
               PerKeyDown((i << 8) + PERPAD_A);
            else
               PerKeyUp((i << 8) + PERPAD_A);

            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A))
               PerKeyDown((i << 8) + PERPAD_B);
            else
               PerKeyUp((i << 8) + PERPAD_B);

            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X))
               PerKeyDown((i << 8) + PERPAD_Y);
            else
               PerKeyUp((i << 8) + PERPAD_Y);

            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L))
               PerKeyDown((i << 8) + PERPAD_C);
            else
               PerKeyUp((i << 8) + PERPAD_C);

            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R))
               PerKeyDown((i << 8) + PERPAD_Z);
            else
               PerKeyUp((i << 8) + PERPAD_Z);

            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START))
               PerKeyDown((i << 8) + PERPAD_START);
            else
               PerKeyUp((i << 8) + PERPAD_START);

            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2))
               PerKeyDown((i << 8) + PERPAD_LEFT_TRIGGER);
            else
               PerKeyUp((i << 8) + PERPAD_LEFT_TRIGGER);

            if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2))
               PerKeyDown((i << 8) + PERPAD_RIGHT_TRIGGER);
            else
               PerKeyUp((i << 8) + PERPAD_RIGHT_TRIGGER);
            break;

         default:
            break;
      }
   }

   if ( YabauseExec() != 0 )
      return -1;
   return 0;
}