1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +02:00

Setting for haptic feedback

This commit is contained in:
Michael 2023-07-08 18:47:38 +02:00 committed by GitHub
parent c786583ce8
commit ff51b8f46b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 5 deletions

View File

@ -74,6 +74,8 @@
"vcmi.systemOptions.longTouchMenu.entry" : "%d milliseconds",
"vcmi.systemOptions.framerateButton.hover" : "Show FPS",
"vcmi.systemOptions.framerateButton.help" : "{Show FPS}\n\nToggle the visibility of the Frames Per Second counter in the corner of the game window",
"vcmi.systemOptions.hapticFeedbackButton.hover" : "Haptic feedback",
"vcmi.systemOptions.hapticFeedbackButton.help" : "{Haptic feedback}\n\nToggle the haptic feedback on touch inputs",
"vcmi.adventureOptions.infoBarPick.hover" : "Show Messages in Info Panel",
"vcmi.adventureOptions.infoBarPick.help" : "{Show Messages in Info Panel}\n\nWhenever possible, game messages from visiting map objects will be shown in the info panel, instead of popping up in a separate window.",

View File

@ -74,6 +74,8 @@
"vcmi.systemOptions.longTouchMenu.entry" : "%d Millisekunden",
"vcmi.systemOptions.framerateButton.hover" : "FPS anzeigen",
"vcmi.systemOptions.framerateButton.help" : "{FPS anzeigen}\n\n Schaltet die Sichtbarkeit des Zählers für die Bilder pro Sekunde in der Ecke des Spielfensters um.",
"vcmi.systemOptions.hapticFeedbackButton.hover" : "Haptisches Feedback",
"vcmi.systemOptions.hapticFeedbackButton.help" : "{Haptisches Feedback}\n\nHaptisches Feedback bei Touch-Eingaben.",
"vcmi.adventureOptions.infoBarPick.hover" : "Meldungen im Infobereich anzeigen",
"vcmi.adventureOptions.infoBarPick.help" : "{Meldungen im Infobereich anzeigen}\n\nWann immer möglich, werden Spielnachrichten von besuchten Kartenobjekten in der Infoleiste angezeigt, anstatt als Popup-Fenster zu erscheinen",

View File

@ -39,6 +39,7 @@ InputSourceTouch::InputSourceTouch()
params.useRelativeMode = settings["general"]["userRelativePointer"].Bool();
params.relativeModeSpeedFactor = settings["general"]["relativePointerSpeedMultiplier"].Float();
params.longTouchTimeMilliseconds = settings["general"]["longTouchTimeMilliseconds"].Float();
params.hapticFeedback = settings["general"]["hapticFeedback"].Bool();
if (params.useRelativeMode)
state = TouchState::RELATIVE_MODE;
@ -298,11 +299,13 @@ void InputSourceTouch::emitPinchEvent(const SDL_TouchFingerEvent & tfinger)
}
void InputSourceTouch::hapticFeedback() {
if(hapticFeedback)
#if defined(VCMI_ANDROID)
CAndroidVMHelper vmHelper;
vmHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "hapticFeedback");
CAndroidVMHelper vmHelper;
vmHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "hapticFeedback");
#endif
#if defined(VCMI_IOS)
iOS_utils::hapticFeedback();
iOS_utils::hapticFeedback();
#endif
}
}

View File

@ -79,6 +79,8 @@ struct TouchInputParameters
uint32_t pinchSensitivityThreshold = 10;
bool useRelativeMode = false;
bool hapticFeedback = false;
};
/// Class that handles touchscreen input from SDL events

View File

@ -153,6 +153,10 @@ GeneralOptionsTab::GeneralOptionsTab()
{
setBoolSetting("video", "showfps", value);
});
addCallback("hapticFeedbackChanged", [](bool value)
{
setBoolSetting("general", "hapticFeedback", value);
});
//moved from "other" tab that is disabled for now to avoid excessible tabs with barely any content
addCallback("availableCreaturesAsDwellingChanged", [=](int value)
@ -190,6 +194,9 @@ GeneralOptionsTab::GeneralOptionsTab()
std::shared_ptr<CToggleButton> framerateCheckbox = widget<CToggleButton>("framerateCheckbox");
framerateCheckbox->setSelected(settings["video"]["showfps"].Bool());
std::shared_ptr<CToggleButton> hapticFeedbackCheckbox = widget<CToggleButton>("hapticFeedbackCheckbox");
hapticFeedbackCheckbox->setSelected(settings["general"]["hapticFeedback"].Bool());
std::shared_ptr<CSlider> musicSlider = widget<CSlider>("musicSlider");
musicSlider->scrollTo(CCS->musich->getVolume());

View File

@ -33,7 +33,8 @@
"extraDump",
"userRelativePointer",
"relativePointerSpeedMultiplier",
"longTouchTimeMilliseconds"
"longTouchTimeMilliseconds",
"hapticFeedback"
],
"properties" : {
"playerName" : {
@ -101,6 +102,10 @@
"longTouchTimeMilliseconds" : {
"type" : "number",
"default" : 1000
},
"hapticFeedback" : {
"type" : "boolean",
"default" : false
}
}
},

View File

@ -57,6 +57,10 @@
"name": "longTouchLabel",
"text": "vcmi.systemOptions.longTouchButton.hover",
"created" : "touchscreen"
},
{
"text": "vcmi.systemOptions.hapticFeedbackButton.hover",
"created" : "touchscreen"
}
]
},
@ -76,7 +80,7 @@
"name": "scalingButton",
"type": "buttonGear",
"help": "vcmi.systemOptions.scalingButton",
"callback": "setGameScaling",
"callback": "setGameScaling"
},
{
"name": "fullscreenBorderlessCheckbox",
@ -106,6 +110,12 @@
"help": "vcmi.systemOptions.longTouchButton",
"callback": "setLongTouchDuration",
"created" : "touchscreen"
},
{
"name": "hapticFeedbackCheckbox",
"help": "vcmi.systemOptions.hapticFeedbackButton",
"callback": "hapticFeedbackChanged",
"created" : "touchscreen"
}
]
},