mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Fix gamepads not working, enable on Android
This commit is contained in:
@@ -26,6 +26,7 @@ GpAndroidGlobals g_gpAndroidGlobals;
|
||||
|
||||
IGpDisplayDriver *GpDriver_CreateDisplayDriver_SDL_GL2(const GpDisplayDriverProperties &properties);
|
||||
IGpAudioDriver *GpDriver_CreateAudioDriver_SDL(const GpAudioDriverProperties &properties);
|
||||
IGpInputDriver *GpDriver_CreateInputDriver_SDL2_Gamepad(const GpInputDriverProperties &properties);
|
||||
|
||||
class GpLogDriver_Android final : public IGpLogDriver
|
||||
{
|
||||
@@ -75,7 +76,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0)
|
||||
return -1;
|
||||
|
||||
SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight");
|
||||
@@ -94,8 +95,13 @@ int main(int argc, char* argv[])
|
||||
|
||||
g_gpGlobalConfig.m_fontHandlerType = EGpFontHandlerType_None;
|
||||
|
||||
g_gpGlobalConfig.m_inputDriverTypes = nullptr;
|
||||
g_gpGlobalConfig.m_numInputDrivers = 0;
|
||||
EGpInputDriverType inputDrivers[] =
|
||||
{
|
||||
EGpInputDriverType_SDL2_Gamepad
|
||||
};
|
||||
|
||||
g_gpGlobalConfig.m_inputDriverTypes = inputDrivers;
|
||||
g_gpGlobalConfig.m_numInputDrivers = sizeof(inputDrivers) / sizeof(inputDrivers[0]);
|
||||
|
||||
g_gpGlobalConfig.m_osGlobals = &g_gpAndroidGlobals;
|
||||
g_gpGlobalConfig.m_logger = GpLogDriver_Android::GetInstance();
|
||||
@@ -104,6 +110,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
GpDisplayDriverFactory::RegisterDisplayDriverFactory(EGpDisplayDriverType_SDL_GL2, GpDriver_CreateDisplayDriver_SDL_GL2);
|
||||
GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL);
|
||||
GpInputDriverFactory::RegisterInputDriverFactory(EGpInputDriverType_SDL2_Gamepad, GpDriver_CreateInputDriver_SDL2_Gamepad);
|
||||
|
||||
int returnCode = GpMain::Run();
|
||||
|
||||
@@ -118,8 +125,3 @@ int main(int argc, char* argv[])
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
IGpInputDriverSDLGamepad *IGpInputDriverSDLGamepad::GetInstance()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0
|
||||
LOCAL_SRC_FILES := \
|
||||
GpAudioDriver_SDL2.cpp \
|
||||
GpDisplayDriver_SDL_GL2.cpp \
|
||||
GpInputDriver_SDL_Gamepad.cpp \
|
||||
ShaderCode/CopyQuadP.cpp \
|
||||
ShaderCode/DrawQuadPaletteP.cpp \
|
||||
ShaderCode/DrawQuad32P.cpp \
|
||||
|
@@ -177,8 +177,6 @@ void GpInputDriverSDLGamepad::HandleDeviceRemoved(SDL_JoystickID joystickID)
|
||||
{
|
||||
m_playerButtonDown[playerNum][button] = false;
|
||||
|
||||
|
||||
|
||||
GpVOSEvent evt;
|
||||
evt.m_eventType = GpVOSEventTypes::kKeyboardInput;
|
||||
evt.m_event.m_keyboardInputEvent.m_eventType = GpKeyboardInputEventTypes::kUp;
|
||||
|
@@ -88,10 +88,3 @@ void GpAppEnvironment::InitializeApplicationState()
|
||||
drivers->SetDriver<GpDriverIDs::kFont>(m_fontHandler);
|
||||
drivers->SetDriver<GpDriverIDs::kEventQueue>(m_vosEventQueue);
|
||||
}
|
||||
|
||||
void GpAppEnvironment::SynchronizeState()
|
||||
{
|
||||
const size_t numInputDrivers = m_numInputDrivers;
|
||||
for (size_t i = 0; i < numInputDrivers; i++)
|
||||
m_inputDrivers[i]->ProcessInput();
|
||||
}
|
||||
|
@@ -41,7 +41,6 @@ public:
|
||||
private:
|
||||
static void StaticAppThreadFunc(void *context);
|
||||
void InitializeApplicationState();
|
||||
void SynchronizeState();
|
||||
|
||||
IGpDisplayDriver *m_displayDriver;
|
||||
IGpAudioDriver *m_audioDriver;
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "IGpInputDriver.h"
|
||||
|
||||
|
||||
namespace PortabilityLayer
|
||||
@@ -13,5 +14,9 @@ namespace PortabilityLayer
|
||||
{
|
||||
PLDrivers::GetDisplayDriver()->ServeTicks(ticks);
|
||||
DisplayDeviceManager::GetInstance()->IncrementTickCount(ticks);
|
||||
|
||||
const size_t numInputDrivers = PLDrivers::GetNumInputDrivers();
|
||||
for (size_t i = 0; i < numInputDrivers; i++)
|
||||
PLDrivers::GetInputDriver(i)->ProcessInput();
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include "BitmapImage.cpp"
|
||||
#include "ByteSwap.cpp"
|
||||
#include "CFileStream.cpp"
|
||||
#include "CompositeRenderedFont.cpp"
|
||||
#include "DeflateCodec.cpp"
|
||||
#include "DialogManager.cpp"
|
||||
#include "DisplayDeviceManager.cpp"
|
||||
|
Reference in New Issue
Block a user