本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}