mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 14:53:52 +00:00
XInput support
This commit is contained in:
@@ -4,12 +4,16 @@
|
||||
#include "GpFontHandlerFactory.h"
|
||||
#include "GpDisplayDriverFactory.h"
|
||||
#include "GpDisplayDriverProperties.h"
|
||||
#include "GpInputDriverFactory.h"
|
||||
#include "GpInputDriverProperties.h"
|
||||
#include "GpGlobalConfig.h"
|
||||
#include "GpAppEnvironment.h"
|
||||
#include "IGpAudioDriver.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "IGpInputDriver.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -32,8 +36,6 @@ int GpMain::Run()
|
||||
GpDisplayDriverProperties ddProps;
|
||||
memset(&ddProps, 0, sizeof(ddProps));
|
||||
|
||||
ddProps.m_type = EGpDisplayDriverType_D3D11;
|
||||
|
||||
ddProps.m_frameTimeLockNumerator = 1;
|
||||
ddProps.m_frameTimeLockDenominator = 60;
|
||||
|
||||
@@ -58,10 +60,28 @@ int GpMain::Run()
|
||||
|
||||
// The sample rate used in all of Glider PRO's sound is 0x56ee8ba3
|
||||
// This appears to be the "standard" Mac sample rate, probably rounded from 244800/11.
|
||||
adProps.m_type = EGpAudioDriverType_XAudio2;
|
||||
adProps.m_type = g_gpGlobalConfig.m_audioDriverType;
|
||||
adProps.m_sampleRate = (244800 * 2 + 11) / (11 * 2);
|
||||
adProps.m_debug = true;
|
||||
|
||||
IGpInputDriver **inputDrivers = static_cast<IGpInputDriver**>(malloc(sizeof(IGpInputDriver*) * g_gpGlobalConfig.m_numInputDrivers));
|
||||
|
||||
size_t numCreatedInputDrivers = 0;
|
||||
if (inputDrivers)
|
||||
{
|
||||
for (size_t i = 0; i < g_gpGlobalConfig.m_numInputDrivers; i++)
|
||||
{
|
||||
GpInputDriverProperties inputProps;
|
||||
memset(&inputProps, 0, sizeof(inputProps));
|
||||
|
||||
inputProps.m_type = g_gpGlobalConfig.m_inputDriverTypes[i];
|
||||
inputProps.m_eventQueue = eventQueue;
|
||||
|
||||
if (IGpInputDriver *driver = GpInputDriverFactory::CreateInputDriver(inputProps))
|
||||
inputDrivers[numCreatedInputDrivers++] = driver;
|
||||
}
|
||||
}
|
||||
|
||||
IGpDisplayDriver *displayDriver = GpDisplayDriverFactory::CreateDisplayDriver(ddProps);
|
||||
IGpAudioDriver *audioDriver = GpAudioDriverFactory::CreateAudioDriver(adProps);
|
||||
PortabilityLayer::HostFontHandler *fontHandler = GpFontHandlerFactory::Create();
|
||||
@@ -70,11 +90,23 @@ int GpMain::Run()
|
||||
|
||||
appEnvironment->SetDisplayDriver(displayDriver);
|
||||
appEnvironment->SetAudioDriver(audioDriver);
|
||||
appEnvironment->SetInputDrivers(inputDrivers, numCreatedInputDrivers);
|
||||
appEnvironment->SetFontHandler(fontHandler);
|
||||
appEnvironment->SetVOSEventQueue(eventQueue);
|
||||
|
||||
// Start the display loop
|
||||
displayDriver->Run();
|
||||
|
||||
// Clean up
|
||||
if (inputDrivers)
|
||||
{
|
||||
for (size_t i = 0; i < numCreatedInputDrivers; i++)
|
||||
inputDrivers[i]->Shutdown();
|
||||
|
||||
free(inputDrivers);
|
||||
}
|
||||
|
||||
// GP TODO: Cleanup
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user