Fix gamepads not working, enable on Android

This commit is contained in:
elasota
2021-10-22 22:01:33 -04:00
parent 9ba15c6d78
commit 545798600e
7 changed files with 17 additions and 18 deletions

View File

@@ -26,6 +26,7 @@ GpAndroidGlobals g_gpAndroidGlobals;
IGpDisplayDriver *GpDriver_CreateDisplayDriver_SDL_GL2(const GpDisplayDriverProperties &properties); IGpDisplayDriver *GpDriver_CreateDisplayDriver_SDL_GL2(const GpDisplayDriverProperties &properties);
IGpAudioDriver *GpDriver_CreateAudioDriver_SDL(const GpAudioDriverProperties &properties); IGpAudioDriver *GpDriver_CreateAudioDriver_SDL(const GpAudioDriverProperties &properties);
IGpInputDriver *GpDriver_CreateInputDriver_SDL2_Gamepad(const GpInputDriverProperties &properties);
class GpLogDriver_Android final : public IGpLogDriver class GpLogDriver_Android final : public IGpLogDriver
{ {
@@ -75,7 +76,7 @@ int main(int argc, char* argv[])
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_INFO); 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; return -1;
SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight"); 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_fontHandlerType = EGpFontHandlerType_None;
g_gpGlobalConfig.m_inputDriverTypes = nullptr; EGpInputDriverType inputDrivers[] =
g_gpGlobalConfig.m_numInputDrivers = 0; {
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_osGlobals = &g_gpAndroidGlobals;
g_gpGlobalConfig.m_logger = GpLogDriver_Android::GetInstance(); 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); GpDisplayDriverFactory::RegisterDisplayDriverFactory(EGpDisplayDriverType_SDL_GL2, GpDriver_CreateDisplayDriver_SDL_GL2);
GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL); GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL);
GpInputDriverFactory::RegisterInputDriverFactory(EGpInputDriverType_SDL2_Gamepad, GpDriver_CreateInputDriver_SDL2_Gamepad);
int returnCode = GpMain::Run(); int returnCode = GpMain::Run();
@@ -118,8 +125,3 @@ int main(int argc, char* argv[])
return returnCode; return returnCode;
} }
IGpInputDriverSDLGamepad *IGpInputDriverSDLGamepad::GetInstance()
{
return nullptr;
}

View File

@@ -20,6 +20,7 @@ LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
GpAudioDriver_SDL2.cpp \ GpAudioDriver_SDL2.cpp \
GpDisplayDriver_SDL_GL2.cpp \ GpDisplayDriver_SDL_GL2.cpp \
GpInputDriver_SDL_Gamepad.cpp \
ShaderCode/CopyQuadP.cpp \ ShaderCode/CopyQuadP.cpp \
ShaderCode/DrawQuadPaletteP.cpp \ ShaderCode/DrawQuadPaletteP.cpp \
ShaderCode/DrawQuad32P.cpp \ ShaderCode/DrawQuad32P.cpp \

View File

@@ -177,8 +177,6 @@ void GpInputDriverSDLGamepad::HandleDeviceRemoved(SDL_JoystickID joystickID)
{ {
m_playerButtonDown[playerNum][button] = false; m_playerButtonDown[playerNum][button] = false;
GpVOSEvent evt; GpVOSEvent evt;
evt.m_eventType = GpVOSEventTypes::kKeyboardInput; evt.m_eventType = GpVOSEventTypes::kKeyboardInput;
evt.m_event.m_keyboardInputEvent.m_eventType = GpKeyboardInputEventTypes::kUp; evt.m_event.m_keyboardInputEvent.m_eventType = GpKeyboardInputEventTypes::kUp;

View File

@@ -88,10 +88,3 @@ void GpAppEnvironment::InitializeApplicationState()
drivers->SetDriver<GpDriverIDs::kFont>(m_fontHandler); drivers->SetDriver<GpDriverIDs::kFont>(m_fontHandler);
drivers->SetDriver<GpDriverIDs::kEventQueue>(m_vosEventQueue); 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();
}

View File

@@ -41,7 +41,6 @@ public:
private: private:
static void StaticAppThreadFunc(void *context); static void StaticAppThreadFunc(void *context);
void InitializeApplicationState(); void InitializeApplicationState();
void SynchronizeState();
IGpDisplayDriver *m_displayDriver; IGpDisplayDriver *m_displayDriver;
IGpAudioDriver *m_audioDriver; IGpAudioDriver *m_audioDriver;

View File

@@ -5,6 +5,7 @@
#include "PLDrivers.h" #include "PLDrivers.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "IGpInputDriver.h"
namespace PortabilityLayer namespace PortabilityLayer
@@ -13,5 +14,9 @@ namespace PortabilityLayer
{ {
PLDrivers::GetDisplayDriver()->ServeTicks(ticks); PLDrivers::GetDisplayDriver()->ServeTicks(ticks);
DisplayDeviceManager::GetInstance()->IncrementTickCount(ticks); DisplayDeviceManager::GetInstance()->IncrementTickCount(ticks);
const size_t numInputDrivers = PLDrivers::GetNumInputDrivers();
for (size_t i = 0; i < numInputDrivers; i++)
PLDrivers::GetInputDriver(i)->ProcessInput();
} }
} }

View File

@@ -4,6 +4,7 @@
#include "BitmapImage.cpp" #include "BitmapImage.cpp"
#include "ByteSwap.cpp" #include "ByteSwap.cpp"
#include "CFileStream.cpp" #include "CFileStream.cpp"
#include "CompositeRenderedFont.cpp"
#include "DeflateCodec.cpp" #include "DeflateCodec.cpp"
#include "DialogManager.cpp" #include "DialogManager.cpp"
#include "DisplayDeviceManager.cpp" #include "DisplayDeviceManager.cpp"