mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-03 08:15:37 +00:00
Print joystick haptic capabilities to log
This commit is contained in:
parent
879e084383
commit
4832d8007b
@ -41,6 +41,10 @@
|
|||||||
// Determines the maximum motion amount before allowing movement
|
// Determines the maximum motion amount before allowing movement
|
||||||
#define MOUSE_EMULATION_DEADZONE 2
|
#define MOUSE_EMULATION_DEADZONE 2
|
||||||
|
|
||||||
|
// Haptic capabilities (in addition to those from SDL_HapticQuery())
|
||||||
|
#define ML_HAPTIC_GC_RUMBLE (1U << 16)
|
||||||
|
#define ML_HAPTIC_SIMPLE_RUMBLE (1U << 17)
|
||||||
|
|
||||||
const int SdlInputHandler::k_ButtonMap[] = {
|
const int SdlInputHandler::k_ButtonMap[] = {
|
||||||
A_FLAG, B_FLAG, X_FLAG, Y_FLAG,
|
A_FLAG, B_FLAG, X_FLAG, Y_FLAG,
|
||||||
BACK_FLAG, SPECIAL_FLAG, PLAY_FLAG,
|
BACK_FLAG, SPECIAL_FLAG, PLAY_FLAG,
|
||||||
@ -911,6 +915,7 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
|
|||||||
SDL_GameController* controller;
|
SDL_GameController* controller;
|
||||||
const char* mapping;
|
const char* mapping;
|
||||||
char guidStr[33];
|
char guidStr[33];
|
||||||
|
uint32_t hapticCaps;
|
||||||
|
|
||||||
controller = SDL_GameControllerOpen(event->which);
|
controller = SDL_GameControllerOpen(event->which);
|
||||||
if (controller == NULL) {
|
if (controller == NULL) {
|
||||||
@ -954,11 +959,20 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
|
|||||||
state->controller = controller;
|
state->controller = controller;
|
||||||
state->jsId = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(state->controller));
|
state->jsId = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(state->controller));
|
||||||
|
|
||||||
#if !SDL_VERSION_ATLEAST(2, 0, 9)
|
#if SDL_VERSION_ATLEAST(2, 0, 9)
|
||||||
|
// Perform a no-op rumble to see if haptics are supported
|
||||||
|
hapticCaps = SDL_GameControllerRumble(controller, 0, 0, 0) == 0 ?
|
||||||
|
ML_HAPTIC_GC_RUMBLE : 0;
|
||||||
|
#else
|
||||||
state->haptic = SDL_HapticOpenFromJoystick(SDL_GameControllerGetJoystick(state->controller));
|
state->haptic = SDL_HapticOpenFromJoystick(SDL_GameControllerGetJoystick(state->controller));
|
||||||
state->hapticEffectId = -1;
|
state->hapticEffectId = -1;
|
||||||
state->hapticMethod = GAMEPAD_HAPTIC_METHOD_NONE;
|
state->hapticMethod = GAMEPAD_HAPTIC_METHOD_NONE;
|
||||||
if (state->haptic != nullptr) {
|
if (state->haptic != nullptr) {
|
||||||
|
// Query for supported haptic effects
|
||||||
|
hapticCaps = SDL_HapticQuery(state->haptic);
|
||||||
|
hapticCaps |= SDL_HapticRumbleSupported(state->haptic) ?
|
||||||
|
ML_HAPTIC_SIMPLE_RUMBLE : 0;
|
||||||
|
|
||||||
if ((SDL_HapticQuery(state->haptic) & SDL_HAPTIC_LEFTRIGHT) == 0) {
|
if ((SDL_HapticQuery(state->haptic) & SDL_HAPTIC_LEFTRIGHT) == 0) {
|
||||||
if (SDL_HapticRumbleSupported(state->haptic)) {
|
if (SDL_HapticRumbleSupported(state->haptic)) {
|
||||||
if (SDL_HapticRumbleInit(state->haptic) == 0) {
|
if (SDL_HapticRumbleInit(state->haptic) == 0) {
|
||||||
@ -973,6 +987,9 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
|
|||||||
state->hapticMethod = GAMEPAD_HAPTIC_METHOD_LEFTRIGHT;
|
state->hapticMethod = GAMEPAD_HAPTIC_METHOD_LEFTRIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
hapticCaps = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(SDL_GameControllerGetJoystick(state->controller)),
|
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(SDL_GameControllerGetJoystick(state->controller)),
|
||||||
@ -980,10 +997,11 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
|
|||||||
mapping = SDL_GameControllerMapping(state->controller);
|
mapping = SDL_GameControllerMapping(state->controller);
|
||||||
name = SDL_GameControllerName(state->controller);
|
name = SDL_GameControllerName(state->controller);
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Gamepad %d (player %d) is: %s (%s -> %s)",
|
"Gamepad %d (player %d) is: %s (haptic capabilities: 0x%x) (mapping: %s -> %s)",
|
||||||
i,
|
i,
|
||||||
state->index,
|
state->index,
|
||||||
name != nullptr ? name : "<null>",
|
name != nullptr ? name : "<null>",
|
||||||
|
hapticCaps,
|
||||||
guidStr,
|
guidStr,
|
||||||
mapping != nullptr ? mapping : "<null>");
|
mapping != nullptr ? mapping : "<null>");
|
||||||
if (mapping != nullptr) {
|
if (mapping != nullptr) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user