コード例 #1
0
ファイル: SdlContext.cpp プロジェクト: r-lyeh-forks/AGE
void SdlContext::_addJoystick(Input &inputs, int joyIdx)
{
    SDL_Joystick *current = SDL_JoystickOpen(joyIdx);

    if (current)
    {
        SDL_JoystickID sdlJoyId = SDL_JoystickInstanceID(current);

        if (sdlJoyId != -1)
        {
            uint32_t currentId = 0;

            while (currentId != AGE_JOYSTICK_MAX_NUMBER &&
                    _joysticks[currentId].id != -1)
                ++currentId;
            assert(currentId != AGE_JOYSTICK_MAX_NUMBER && "AGE cannot handle more than 6 joysticks.");
            _joysticks[currentId].id = sdlJoyId;
            _joysticks[currentId].handler = current;
            inputs.addJoystick(SDL_JoystickName(current), currentId);
        }
    }
}