JD2022-TU1/main/extern/UbiServices/custom/tests/ggp/platformTestHelper.h

59 lines
2.2 KiB
C++

////////////////////////////////////////////////////////////////////////////////
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Harbour //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "tests/config.h"
#if defined(US_TARGET_GGP)
#include "tests/ggp/vulkanTestHelper.h"
#include <ggp/ggp.h>
#include <thread>
struct UMP_Context;
class PlatformTestHelper final
{
public:
static PlatformTestHelper& getInstance();
// Initialize(): Initialize the application.
void init();
// uninit(): Clean up application resources.
void uninit();
//HandleStreamStateChanged(): Handle stream state changed event.
static void handleStreamStateChanged(const ggp::StreamStateChangedEvent& event);
static void handleMouseInput(const ggp::MouseInputEvent& event);
static void handleKeyboardInput(const ggp::KeyboardInputEvent& event);
static void handleGamepadInput(const ggp::GamepadInputEvent& event);
static void handleGamepadHotplug(const ggp::GamepadHotplugEvent& event);
private:
static std::unique_ptr<PlatformTestHelper> s_instance;
PlatformTestHelper();
void runGameLoop();
void instanceHandleStreamStateChanged(const ggp::StreamStateChangedEvent& event);
bool m_hasJotunInitSucceeded;
// Ggp Client Handling
// Note : It seems the event queue shall not be released to late because of issues with first party mutexes
// So we use a pointer to control when it should be deleted, otherwise it is a member of a static instance,
// which will be released at the very end of the program (and cause an abort).
std::unique_ptr<ggp::EventQueue> m_event_queue;
uint32_t m_stream_state_changed_handler_id = 0;
bool m_stream_started = false;
uint32_t m_mouse_input_handler_id = 0;
uint32_t m_keyboard_input_handler_id = 0;
uint32_t m_gamepad_input_handler_id = 0;
uint32_t m_gamepad_hotplug_handler_id = 0;
// Vulkan Object
VulkanTestHelper m_vulkan;
// Application State
std::atomic<bool> m_quit{ false };
std::unique_ptr<std::thread> m_gameLoopThread;
};
#endif // defined(US_TARGET_GGP)