AkMotionSinkScePadHelpers.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*******************************************************************************
  2. The content of this file includes portions of the AUDIOKINETIC Wwise Technology
  3. released in source code form as part of the SDK installer package.
  4. Commercial License Usage
  5. Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
  6. may use this file in accordance with the end user license agreement provided
  7. with the software or, alternatively, in accordance with the terms contained in a
  8. written agreement between you and Audiokinetic Inc.
  9. Apache License Usage
  10. Alternatively, this file may be used under the Apache License, Version 2.0 (the
  11. "Apache License"); you may not use this file except in compliance with the
  12. Apache License. You may obtain a copy of the Apache License at
  13. http://www.apache.org/licenses/LICENSE-2.0.
  14. Unless required by applicable law or agreed to in writing, software distributed
  15. under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  16. OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
  17. the specific language governing permissions and limitations under the License.
  18. Copyright (c) 2023 Audiokinetic Inc.
  19. *******************************************************************************/
  20. /// \file
  21. #pragma once
  22. #include <AK/SoundEngine/Common/AkTypes.h>
  23. #include <pad.h>
  24. // Do a bitwise-OR with the deviceID, when adding the output, to utilize the scePad Haptics ("Advanced") functionality
  25. // If unset, the device will use scePad Rumble ("Compatible") functionality
  26. #define AKMOTION_SCEPAD_HAPTICS_MODE 0x80000000
  27. namespace AK
  28. {
  29. typedef int(*_akmotionPadGetHandle)(int userId, int type, int index);
  30. typedef int(*_akmotionPadGetContainerIdInformation)(int handle, void* pInfo);
  31. typedef int(*_akmotionPadGetControllerType)(int handle, void* pControllerType);
  32. typedef int(*_akmotionPadSetVibrationMode)(int handle, ScePadVibrationMode mode);
  33. typedef int(*_akmotionPadSetVibration)(int handle, const void* pParam);
  34. }
  35. // Helper functions to facilitate "loose" linkage with scePad library.
  36. // If AkMotion is statically linked into your program, call AKMOTION_STATIC_LINK_SCEPAD_FUNCTIONS anywhere (even pre-init)
  37. // If AkMotion is dynamically linked into your program, call AKMOTION_DYNAMIC_LINK_SCEPAD_FUNCTIONS after Init.bnk has been loaded
  38. #define AKMOTIONSINK_STATIC_LINK_SCEPAD_FUNCTIONS \
  39. struct _AkMotionInitializeScePadFunctionsHelper \
  40. { \
  41. _AkMotionInitializeScePadFunctionsHelper() \
  42. { \
  43. AkMotionInitializeScePadFunctions(\
  44. (AK::_akmotionPadGetHandle)scePadGetHandle, \
  45. (AK::_akmotionPadGetContainerIdInformation)scePadGetContainerIdInformation, \
  46. (AK::_akmotionPadGetControllerType)scePadGetControllerType, \
  47. (AK::_akmotionPadSetVibrationMode)scePadSetVibrationMode, \
  48. (AK::_akmotionPadSetVibration)scePadSetVibration); \
  49. } \
  50. } AkMotionInitializeScePadFunctionsHelper;
  51. #define AKMOTIONSINK_DYNAMIC_LINK_SCEPAD_FUNCTIONS \
  52. { \
  53. HMODULE _akmotion_Hmod; \
  54. if (GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "AkMotion", &_akmotion_Hmod)) \
  55. { \
  56. typedef int(*_akmotionPadInitFunc)( \
  57. AK::_akmotionPadGetHandle in_pPadGetHandle, \
  58. AK::_akmotionPadGetContainerIdInformation in_pPadGetContainerIdInformation, \
  59. AK::_akmotionPadGetControllerType in_pPadGetControllerType, \
  60. AK::_akmotionPadSetVibrationMode in_pPadSetVibrationMode, \
  61. AK::_akmotionPadSetVibration in_pPadSetVibration); \
  62. _akmotionPadInitFunc _akmotion_pInitFn = reinterpret_cast<_akmotionPadInitFunc>( reinterpret_cast<void*>( \
  63. GetProcAddress(_akmotion_Hmod, "AkMotionInitializeScePadFunctions") \
  64. )); \
  65. _akmotion_pInitFn( \
  66. (AK::_akmotionPadGetHandle)scePadGetHandle, \
  67. (AK::_akmotionPadGetContainerIdInformation)scePadGetContainerIdInformation, \
  68. (AK::_akmotionPadGetControllerType)scePadGetControllerType, \
  69. (AK::_akmotionPadSetVibrationMode)scePadSetVibrationMode, \
  70. (AK::_akmotionPadSetVibration)scePadSetVibration); \
  71. } \
  72. } \
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif
  76. AK_DLLEXPORT void AkMotionInitializeScePadFunctions(
  77. AK::_akmotionPadGetHandle in_pPadGetHandle,
  78. AK::_akmotionPadGetContainerIdInformation in_pPadGetContainerIdInformation,
  79. AK::_akmotionPadGetControllerType in_pPadGetControllerType,
  80. AK::_akmotionPadSetVibrationMode in_pPadSetVibrationMode,
  81. AK::_akmotionPadSetVibration in_pPadSetVibration);
  82. #ifdef __cplusplus
  83. }
  84. #endif