diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-09-15 02:54:46 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-09-15 04:19:24 +0300 |
commit | fa5e367a09f3a32376706798c27f46e403900d3a (patch) | |
tree | 5ec02ab657e32c6239442c2a0f07ecdec2887ec2 /src/input/joystick.cpp | |
parent | 49ccccb2603278260e02bb43fb38251589ab4bd1 (diff) | |
download | manaverse-fa5e367a09f3a32376706798c27f46e403900d3a.tar.gz manaverse-fa5e367a09f3a32376706798c27f46e403900d3a.tar.bz2 manaverse-fa5e367a09f3a32376706798c27f46e403900d3a.tar.xz manaverse-fa5e367a09f3a32376706798c27f46e403900d3a.zip |
Dump more info about current joystick (SDL2).
Diffstat (limited to 'src/input/joystick.cpp')
-rw-r--r-- | src/input/joystick.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/input/joystick.cpp b/src/input/joystick.cpp index 10ed33924..dce9d1922 100644 --- a/src/input/joystick.cpp +++ b/src/input/joystick.cpp @@ -110,6 +110,60 @@ bool Joystick::open() mButtonsNumber = SDL_JoystickNumButtons(mJoystick); logger->log("Joystick: %i ", mNumber); +#ifdef USE_SDL2 + logger->log("Name: %s", SDL_JoystickName(mJoystick)); + SDL_JoystickGUID guid = SDL_JoystickGetGUID(mJoystick); + std::string guidStr; + for (int f = 0; f < 16; f ++) + guidStr.append(strprintf("%02x", CAST_U32(guid.data[f]))); + logger->log("Guid: %s", guidStr.c_str()); + logger->log("Device id: %u:%u.%u", + CAST_U32(SDL_JoystickGetVendor(mJoystick)), + CAST_U32(SDL_JoystickGetProduct(mJoystick)), + CAST_U32(SDL_JoystickGetProductVersion(mJoystick))); + SDL_JoystickType type = SDL_JoystickGetType(mJoystick); + std::string typeStr; + switch (type) + { + default: + case SDL_JOYSTICK_TYPE_UNKNOWN: + typeStr = "unknown"; + break; + case SDL_JOYSTICK_TYPE_GAMECONTROLLER: + typeStr = "game controller"; + break; + case SDL_JOYSTICK_TYPE_WHEEL: + typeStr = "wheel"; + break; + case SDL_JOYSTICK_TYPE_ARCADE_STICK: + typeStr = "arcade stick"; + break; + case SDL_JOYSTICK_TYPE_FLIGHT_STICK: + typeStr = "flight stick"; + break; + case SDL_JOYSTICK_TYPE_DANCE_PAD: + typeStr = "dance pad"; + break; + case SDL_JOYSTICK_TYPE_GUITAR: + typeStr = "guitar"; + break; + case SDL_JOYSTICK_TYPE_DRUM_KIT: + typeStr = "drum kit"; + break; + case SDL_JOYSTICK_TYPE_ARCADE_PAD: + typeStr = "arcade pad"; + break; + case SDL_JOYSTICK_TYPE_THROTTLE: + typeStr = "throttle"; + break; + } + logger->log("Type: " + typeStr); + // probably need aslo dump SDL_JoystickCurrentPowerLevel +#else // USE_SDL2 + + logger->log("Name: %s", SDL_JoystickName(mNumber)); +#endif // USE_SDL2 + logger->log("Axes: %i ", SDL_JoystickNumAxes(mJoystick)); logger->log("Balls: %i", SDL_JoystickNumBalls(mJoystick)); logger->log("Hats: %i", SDL_JoystickNumHats(mJoystick)); |