示例#1
0
static __inline__
void HandleHat(SDL_Joystick *stick, Uint8 hat, int axis, int value)
{
	struct hwdata_hat *the_hat;
	const Uint8 position_map[3][3] = {
		{ SDL_HAT_LEFTUP, SDL_HAT_UP, SDL_HAT_RIGHTUP },
		{ SDL_HAT_LEFT, SDL_HAT_CENTERED, SDL_HAT_RIGHT },
		{ SDL_HAT_LEFTDOWN, SDL_HAT_DOWN, SDL_HAT_RIGHTDOWN }
	};
	SDL_logical_joydecl(SDL_Joystick *logicaljoy = NULL);
	SDL_logical_joydecl(struct joystick_logical_mapping* hats = NULL);

	if (stick->nhats <= hat) {
		return;  /* whoops, that shouldn't happen! */
	}

	the_hat = &stick->hwdata->hats[hat];
	if ( value < 0 ) {
		value = 0;
	} else
	if ( value == 0 ) {
		value = 1;
	} else
	if ( value > 0 ) {
		value = 2;
	}
	if ( value != the_hat->axis[axis] ) {
		the_hat->axis[axis] = value;

#ifndef NO_LOGICAL_JOYSTICKS
		/* if there's no map then this is just a regular joystick
		*/
		if (SDL_joylist[stick->index].map != NULL) {

			/* get the fake joystick that will receive the event
			*/
			hats = SDL_joylist[stick->index].map->hatmap+hat;
			logicaljoy = FindLogicalJoystick(stick, hats);
		}

		if (logicaljoy) {
			stick = logicaljoy;
			hat = hats->nthing;
		}
#endif /* USE_LOGICAL_JOYSTICKS */

		SDL_PrivateJoystickHat(stick, hat,
			position_map[the_hat->axis[1]][the_hat->axis[0]]);
	}
}
static __inline__
void HandleHat(STJoystick::STJoystickData* stick, unsigned char hat, int axis, int value)
{
	hwdata_hat *the_hat;
	const unsigned char position_map[3][3] = {
		{ ST_JOYSTICK_HAT_LEFTUP, ST_JOYSTICK_HAT_UP, ST_JOYSTICK_HAT_RIGHTUP },
		{ ST_JOYSTICK_HAT_LEFT, ST_JOYSTICK_HAT_CENTERED, ST_JOYSTICK_HAT_RIGHT },
		{ ST_JOYSTICK_HAT_LEFTDOWN, ST_JOYSTICK_HAT_DOWN, ST_JOYSTICK_HAT_RIGHTDOWN }
	};
	SDL_logical_joydecl(STJoystick::STJoystickData *logicaljoy = NULL);
	SDL_logical_joydecl(struct joystick_logical_mapping* hats = NULL);

	the_hat = &stick->hwdata->hats[hat];
	if ( value < 0 ) {
		value = 0;
	} else
	if ( value == 0 ) {
		value = 1;
	} else
	if ( value > 0 ) {
		value = 2;
	}
	if ( value != the_hat->axis[axis] ) {
		the_hat->axis[axis] = value;

#ifndef NO_LOGICAL_JOYSTICKS
		/* if there's no map then this is just a regular joystick
		*/
		if (SDL_joylist[stick->index].map != NULL) {

			/* get the fake joystick that will receive the event
			*/
			hats = SDL_joylist[stick->index].map->hatmap+hat;
			logicaljoy = FindLogicalJoystick(stick, hats);
		}

		if (logicaljoy) {
			stick = logicaljoy;
			hat = hats->nthing;
		}
#endif /* USE_LOGICAL_JOYSTICKS */

		stick->hats[hat] = position_map[the_hat->axis[1]][the_hat->axis[0]];
	}
}
static int LogicalJoystickButton(
   STJoystick::STJoystickData *joystick, unsigned char button, unsigned char state){
        struct joystick_logical_mapping* buttons;
        STJoystick::STJoystickData *logicaljoy = NULL;

        /* if there's no map then this is just a regular joystick
         */
        if (SDL_joylist[joystick->index].map == NULL)
           return 0;

        /* get the logical joystick that will receive the event
         */
        buttons = SDL_joylist[joystick->index].map->buttonmap+button;
        logicaljoy = FindLogicalJoystick(joystick, buttons);

        if (logicaljoy == NULL)
           return 1;

	logicaljoy->buttons[buttons->nthing] = state;

        return 1;
}
示例#4
0
static int LogicalJoystickButton(
   SDL_Joystick *joystick, Uint8 button, Uint8 state){
        struct joystick_logical_mapping* buttons;
        SDL_Joystick *logicaljoy = NULL;

        /* if there's no map then this is just a regular joystick
         */
        if (SDL_joylist[joystick->index].map == NULL)
           return 0;

        /* get the logical joystick that will receive the event
         */
        buttons = SDL_joylist[joystick->index].map->buttonmap+button;
        logicaljoy = FindLogicalJoystick(joystick, buttons);

        if (logicaljoy == NULL)
           return 1;

        SDL_PrivateJoystickButton(logicaljoy, buttons->nthing, state);

        return 1;
}
static int LogicalJoystickAxis(
	STJoystick::STJoystickData* joystick, unsigned char axis, short value)
{
        struct joystick_logical_mapping* axes;
        STJoystick::STJoystickData* logicaljoy = NULL;

        /* if there's no map then this is just a regular joystick
         */
        if (SDL_joylist[joystick->index].map == NULL)
           return 0;

        /* get the logical joystick that will receive the event
         */
        axes = SDL_joylist[joystick->index].map->axismap+axis;
        logicaljoy = FindLogicalJoystick(joystick, axes);

        if (logicaljoy == NULL)
           return 1;

	logicaljoy->axes[axes->nthing] = value;

        return 1;
}
示例#6
0
static int LogicalJoystickAxis(
	SDL_Joystick *joystick, Uint8 axis, Sint16 value)
{
        struct joystick_logical_mapping* axes;
        SDL_Joystick *logicaljoy = NULL;

        /* if there's no map then this is just a regular joystick
         */
        if (SDL_joylist[joystick->index].map == NULL)
           return 0;

        /* get the logical joystick that will receive the event
         */
        axes = SDL_joylist[joystick->index].map->axismap+axis;
        logicaljoy = FindLogicalJoystick(joystick, axes);

        if (logicaljoy == NULL)
           return 1;

        SDL_PrivateJoystickAxis(logicaljoy, axes->nthing, value);

        return 1;
}