当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_PrivateJoystickValid函数代码示例

本文整理汇总了C++中SDL_PrivateJoystickValid函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_PrivateJoystickValid函数的具体用法?C++ SDL_PrivateJoystickValid怎么用?C++ SDL_PrivateJoystickValid使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_PrivateJoystickValid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SDL_JoystickCurrentPowerLevel

/* return its power level */
SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick)
{
    if (!SDL_PrivateJoystickValid(joystick)) {
        return (SDL_JOYSTICK_POWER_UNKNOWN);
    }
    return joystick->epowerlevel;
}
开发者ID:inolen,项目名称:redream,代码行数:8,代码来源:SDL_joystick.c

示例2: SDL_JoystickGetBall

/*
 * Get the ball axis change since the last poll
 */
int
SDL_JoystickGetBall(SDL_Joystick * joystick, int ball, int *dx, int *dy)
{
    int retval;

    if (!SDL_PrivateJoystickValid(&joystick)) {
        return (-1);
    }

    retval = 0;
    if (ball < joystick->nballs) {
        if (dx) {
            *dx = joystick->balls[ball].dx;
        }
        if (dy) {
            *dy = joystick->balls[ball].dy;
        }
        joystick->balls[ball].dx = 0;
        joystick->balls[ball].dy = 0;
    } else {
        SDL_SetError("Joystick only has %d balls", joystick->nballs);
        retval = -1;
    }
    return (retval);
}
开发者ID:AlexOteiza,项目名称:n64ios,代码行数:28,代码来源:SDL_joystick.c

示例3: SDL_HapticOpenFromJoystick

/*
 * Opens a haptic device from a joystick.
 */
SDL_Haptic *
SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
{
    SDL_Haptic *haptic;
    SDL_Haptic *hapticlist;

    /* Make sure there is room. */
    if (SDL_NumHaptics() <= 0) {
        SDL_SetError("Haptic: There are %d haptic devices available",
                     SDL_NumHaptics());
        return NULL;
    }

    /* Must be a valid joystick */
    if (!SDL_PrivateJoystickValid(joystick)) {
        SDL_SetError("Haptic: Joystick isn't valid.");
        return NULL;
    }

    /* Joystick must be haptic */
    if (SDL_SYS_JoystickIsHaptic(joystick) <= 0) {
        SDL_SetError("Haptic: Joystick isn't a haptic device.");
        return NULL;
    }

    hapticlist = SDL_haptics;
    /* Check to see if joystick's haptic is already open */
    while ( hapticlist )
    {
        if (SDL_SYS_JoystickSameHaptic(hapticlist, joystick)) {
            haptic = hapticlist;
            ++haptic->ref_count;
            return haptic;
        }
        hapticlist = hapticlist->next;
    }

    /* Create the haptic device */
    haptic = (SDL_Haptic *) SDL_malloc((sizeof *haptic));
    if (haptic == NULL) {
        SDL_OutOfMemory();
        return NULL;
    }

    /* Initialize the haptic device */
    SDL_memset(haptic, 0, sizeof(SDL_Haptic));
    haptic->rumble_id = -1;
    if (SDL_SYS_HapticOpenFromJoystick(haptic, joystick) < 0) {
        SDL_free(haptic);
        return NULL;
    }

    /* Add haptic to list */
    ++haptic->ref_count;
    /* Link the haptic in the list */
    haptic->next = SDL_haptics;
    SDL_haptics = haptic;

    return haptic;
}
开发者ID:1414648814,项目名称:Torque3D,代码行数:63,代码来源:SDL_haptic.c

示例4: SDL_JoystickIndex

/*
 * Get the device index of an opened joystick.
 */
int
SDL_JoystickIndex(SDL_Joystick * joystick)
{
    if (!SDL_PrivateJoystickValid(&joystick)) {
        return (-1);
    }
    return (joystick->index);
}
开发者ID:AlexOteiza,项目名称:n64ios,代码行数:11,代码来源:SDL_joystick.c

示例5: SDL_JoystickNumBalls

/*
 * Get the number of trackballs on a joystick
 */
int
SDL_JoystickNumBalls(SDL_Joystick * joystick)
{
    if (!SDL_PrivateJoystickValid(joystick)) {
        return (-1);
    }
    return (joystick->nballs);
}
开发者ID:inolen,项目名称:redream,代码行数:11,代码来源:SDL_joystick.c

示例6: SDL_JoystickNumAxes

/*
 * Get the number of multi-dimensional axis controls on a joystick
 */
int
SDL_JoystickNumAxes(SDL_Joystick * joystick)
{
    if (!SDL_PrivateJoystickValid(&joystick)) {
        return (-1);
    }
    return (joystick->naxes);
}
开发者ID:AlexOteiza,项目名称:n64ios,代码行数:11,代码来源:SDL_joystick.c

示例7: SDL_JoystickNumHats

/*
 * Get the number of hats on a joystick
 */
int
SDL_JoystickNumHats(SDL_Joystick * joystick)
{
    if (!SDL_PrivateJoystickValid(&joystick)) {
        return (-1);
    }
    return (joystick->nhats);
}
开发者ID:AlexOteiza,项目名称:n64ios,代码行数:11,代码来源:SDL_joystick.c

示例8: SDL_JoystickNumButtons

/*
 * Get the number of buttons on a joystick
 */
int
SDL_JoystickNumButtons(SDL_Joystick * joystick)
{
    if (!SDL_PrivateJoystickValid(&joystick)) {
        return (-1);
    }
    return (joystick->nbuttons);
}
开发者ID:AlexOteiza,项目名称:n64ios,代码行数:11,代码来源:SDL_joystick.c

示例9: SDL_JoystickGetGUID

SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick)
{
    if (!SDL_PrivateJoystickValid(joystick)) {
        SDL_JoystickGUID emptyGUID;
        SDL_zero(emptyGUID);
        return emptyGUID;
    }
    return SDL_SYS_JoystickGetGUID(joystick);
}
开发者ID:inolen,项目名称:redream,代码行数:9,代码来源:SDL_joystick.c

示例10: SDL_JoystickGetAttached

/*
 * Return if the joystick in question is currently attached to the system,
 *  \return SDL_FALSE if not plugged in, SDL_TRUE if still present.
 */
SDL_bool
SDL_JoystickGetAttached(SDL_Joystick * joystick)
{
    if (!SDL_PrivateJoystickValid(joystick)) {
        return SDL_FALSE;
    }

    return SDL_SYS_JoystickAttached(joystick);
}
开发者ID:inolen,项目名称:redream,代码行数:13,代码来源:SDL_joystick.c

示例11: SDL_JoystickInstanceID

/*
 * Get the instance id for this opened joystick
 */
SDL_JoystickID
SDL_JoystickInstanceID(SDL_Joystick * joystick)
{
    if (!SDL_PrivateJoystickValid(joystick)) {
        return (-1);
    }

    return (joystick->instance_id);
}
开发者ID:inolen,项目名称:redream,代码行数:12,代码来源:SDL_joystick.c

示例12: SDL_JoystickName

/*
 * Get the friendly name of this joystick
 */
const char *
SDL_JoystickName(SDL_Joystick * joystick)
{
    if (!SDL_PrivateJoystickValid(joystick)) {
        return (NULL);
    }

    return (joystick->name);
}
开发者ID:inolen,项目名称:redream,代码行数:12,代码来源:SDL_joystick.c

示例13: SDL_HapticOpenFromJoystick

/*
 * Opens a haptic device from a joystick.
 */
SDL_Haptic *
SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
{
    int i;
    SDL_Haptic *haptic;

    /* Must be a valid joystick */
    #ifdef SDL_JOYSTICK_DISABLED
    /* if joystick support is disabled it can't be valid */
    return -1;
    #else
    if (!SDL_PrivateJoystickValid(joystick)) {
        SDL_SetError("Haptic: Joystick isn't valid.");
        return NULL;
    }
    #endif

    /* Joystick must be haptic */
    if (SDL_SYS_JoystickIsHaptic(joystick) <= 0) {
        SDL_SetError("Haptic: Joystick isn't a haptic device.");
        return NULL;
    }

    /* Check to see if joystick's haptic is already open */
    for (i = 0; SDL_haptics[i]; i++) {
        if (SDL_SYS_JoystickSameHaptic(SDL_haptics[i], joystick)) {
            haptic = SDL_haptics[i];
            ++haptic->ref_count;
            return haptic;
        }
    }

    /* Create the haptic device */
    haptic = (SDL_Haptic *) SDL_malloc((sizeof *haptic));
    if (haptic == NULL) {
        SDL_OutOfMemory();
        return NULL;
    }

    /* Initialize the haptic device */
    SDL_memset(haptic, 0, sizeof(SDL_Haptic));
    haptic->rumble_id = -1;
    if (SDL_SYS_HapticOpenFromJoystick(haptic, joystick) < 0) {
        SDL_free(haptic);
        return NULL;
    }

    /* Add haptic to list */
    ++haptic->ref_count;
    for (i = 0; SDL_haptics[i]; i++)
        /* Skip to next haptic */ ;
    SDL_haptics[i] = haptic;

    return haptic;
}
开发者ID:mozeal,项目名称:SDL2,代码行数:58,代码来源:SDL_haptic.c

示例14: SDL_JoystickClose

/*
 * Close a joystick previously opened with SDL_JoystickOpen()
 */
void
SDL_JoystickClose(SDL_Joystick * joystick)
{
    int i;

    if (!SDL_PrivateJoystickValid(&joystick)) {
        return;
    }

    /* First decrement ref count */
    if (--joystick->ref_count > 0) {
        return;
    }

    /* Lock the event queue - prevent joystick polling */
    SDL_Lock_EventThread();

    if (joystick == default_joystick) {
        default_joystick = NULL;
    }
    SDL_SYS_JoystickClose(joystick);

    /* Remove joystick from list */
    for (i = 0; SDL_joysticks[i]; ++i) {
        if (joystick == SDL_joysticks[i]) {
            SDL_memmove(&SDL_joysticks[i], &SDL_joysticks[i + 1],
                        (SDL_numjoysticks - i) * sizeof(joystick));
            break;
        }
    }

    /* Let the event thread keep running */
    SDL_Unlock_EventThread();

    /* Free the data associated with this joystick */
    if (joystick->axes) {
        SDL_free(joystick->axes);
    }
    if (joystick->hats) {
        SDL_free(joystick->hats);
    }
    if (joystick->balls) {
        SDL_free(joystick->balls);
    }
    if (joystick->buttons) {
        SDL_free(joystick->buttons);
    }
    SDL_free(joystick);
}
开发者ID:AlexOteiza,项目名称:n64ios,代码行数:52,代码来源:SDL_joystick.c

示例15: SDL_JoystickGetAxisInitialState

/*
 * Get the initial state of an axis control on a joystick
 */
SDL_bool
SDL_JoystickGetAxisInitialState(SDL_Joystick * joystick, int axis, Sint16 *state)
{
    if (!SDL_PrivateJoystickValid(joystick)) {
        return SDL_FALSE;
    }
    if (axis >= joystick->naxes) {
        SDL_SetError("Joystick only has %d axes", joystick->naxes);
        return SDL_FALSE;
    }
    if (state) {
        *state = joystick->axes[axis].initial_value;
    }
    return joystick->axes[axis].has_initial_value;
}
开发者ID:inolen,项目名称:redream,代码行数:18,代码来源:SDL_joystick.c


注:本文中的SDL_PrivateJoystickValid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。