The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
USB Gamepad Not Found By SDL2 In Win 8.1 VM?
JeZ-l-Lee


Joined: 20 Sep 2009
Posts: 572
Location: Long Island, New York, United States, Earth
USB Gamepad Not Found By SDL2 In Win 8.1 VM?

Hi,

I am having problems with my USB gamepad not being found by SDL2
in a Microsoft Windows 8.1 Pro 64Bit guest VMWare Player virtual machine
under a Kubuntu 14.04 L.T.S. 64Bit host.

The USB gamepad is plugged into a USB 2.0 on my desktop
and Win 8.1 Control Panel correctly shows the gamepad connected and working
but my SDL2 video game does not find the USB gamepad?

How would I fix the above problem?
Thanks!

theGiallo


Joined: 03 Nov 2014
Posts: 11
Location: Genova, IT
Could you post the code with which you detect the pads? I bet you are using SDL_GameController and it does not have the mapping. If so try to SDL_JoystickOpen
JeZ-l-Lee


Joined: 20 Sep 2009
Posts: 572
Location: Long Island, New York, United States, Earth
theGiallo wrote:
Could you post the code with which you detect the pads? I bet you are using SDL_GameController and it does not have the mapping. If so try to SDL_JoystickOpen


Code:
//-------------------------------------------------------------------------------------------------
Input::Input(void)
{
    DEBUG = false;

    EXIT_Game = false;

    DelayAllUserInput = 0;

    KeyOnKeyboardPressedByUser = -1;

    MouseButtonPressed[0] = false;
    MouseButtonPressed[1] = false;

    JoystickDeviceOne = NULL;
    JoystickDeviceTwo = NULL;
    JoystickDeviceThree = NULL;

    if (SDL_NumJoysticks() == 0)
    {
        printf("No USB joysticks are plugged in.\n");
    }
    else
    {
        if (SDL_NumJoysticks()>0)
        {
            JoystickDeviceOne = SDL_JoystickOpen(0);
            NumberOfJoyButtons[0] = SDL_JoystickNumButtons(JoystickDeviceOne);
            NumberOfJoyAxises[0] = SDL_JoystickNumAxes(JoystickDeviceOne);
            printf("SDL2 Joystick 0 initialized.\n");
        }

        if (SDL_NumJoysticks()>1)
        {
            JoystickDeviceTwo = SDL_JoystickOpen(1);
            NumberOfJoyButtons[1] = SDL_JoystickNumButtons(JoystickDeviceTwo);
            NumberOfJoyAxises[1] = SDL_JoystickNumAxes(JoystickDeviceTwo);
            printf("SDL2 Joystick 1 initialized.\n");
        }

        if (SDL_NumJoysticks()>2)
        {
            JoystickDeviceThree = SDL_JoystickOpen(2);
            NumberOfJoyButtons[2] = SDL_JoystickNumButtons(JoystickDeviceThree);
            NumberOfJoyAxises[2] = SDL_JoystickNumAxes(JoystickDeviceThree);
            printf("SDL2 Joystick 2 initialized.\n");
        }
    }

    for (int joy = 0; joy < 3; joy++)
    {
        JoyUP[joy] = Axis1;
        JoyDOWN[joy] = Axis1;
        JoyLEFT[joy] = Axis0;
        JoyRIGHT[joy] = Axis0;
        JoyButton1[joy] = Button0;
        JoyButton2[joy] = Button1;
    }

    JoystickSetupProcess = JoySetupNotStarted;

    for (int index = 0; index < 5; index++)
    {
        JoystickDirectionHorizonal[index] = CENTER;
        JoystickDirectionVertical[index] = CENTER;
        JoystickButtonOne[index] = OFF;
        JoystickButtonTwo[index] = OFF;
        JoystickButton1Pressed[index] = false;
        JoystickButton2Pressed[index] = false;
    }

    KeyboardSetupProcess = KeyboardSetupNotStarted;
    UserDefinedKeyButtonOne = -1;
    UserDefinedKeyButtonTwo = -1;
    UserDefinedKeyUP = -1;
    UserDefinedKeyRIGHT = -1;
    UserDefinedKeyDOWN = -1;
    UserDefinedKeyLEFT = -1;
    UserDefinedKeyPause = -1;

    DelayAllUserInput = -1;
}

//-------------------------------------------------------------------------------------------------
theGiallo


Joined: 03 Nov 2014
Posts: 11
Location: Genova, IT
Oh! I've lost my bet! Razz

And in which part of the code it enters? What returns SDL_NumJoysticks()?

What compiler did you use? Maybe try the new Visual Studio Community, that's free even for commercial use for single devs.