haptics_util.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_UTILITY_HAPTICS_UTIL_H_
  5. #define ASH_UTILITY_HAPTICS_UTIL_H_
  6. #include "ash/ash_export.h"
  7. namespace ui {
  8. class InputController;
  9. enum class HapticTouchpadEffect;
  10. enum class HapticTouchpadEffectStrength;
  11. } // namespace ui
  12. namespace ash {
  13. // Utility that provides methods to trigger haptic effects throughout Ash.
  14. // These call InputController functions that will play the effects if a haptic
  15. // touchpad is available.
  16. namespace haptics_util {
  17. // Sets test input controller for testing. When g_test_input_controller is not
  18. // nullptr, haptics_util::PlayHapticTouchpadEffect will call the test controller
  19. // instead of the real one from ozone.
  20. ASH_EXPORT void SetInputControllerForTesting(
  21. ui::InputController* input_controller);
  22. // Plays a touchpad haptic feedback effect according to the given `effect` type,
  23. // and the given `strength`. By default it uses ozone's input controller, unless
  24. // it was overridden by the above SetInputControllerForTesting().
  25. ASH_EXPORT void PlayHapticTouchpadEffect(
  26. ui::HapticTouchpadEffect effect,
  27. ui::HapticTouchpadEffectStrength strength);
  28. // Plays a `ToggleOn` or `ToggleOff` haptic effect based on the `on` bool value.
  29. ASH_EXPORT void PlayHapticToggleEffect(
  30. bool on,
  31. ui::HapticTouchpadEffectStrength strength);
  32. } // namespace haptics_util
  33. } // namespace ash
  34. #endif // ASH_UTILITY_HAPTICS_UTIL_H_