mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-22 22:45:39 +00:00
Add text input on mobile
This commit is contained in:
@@ -151,6 +151,10 @@ unsigned int GpSystemServices_Win32::GetCPUCount() const
|
||||
return sysInfo.dwNumberOfProcessors;
|
||||
}
|
||||
|
||||
void GpSystemServices_Win32::SetTextInputEnabled(bool isEnabled)
|
||||
{
|
||||
}
|
||||
|
||||
void GpSystemServices_Win32::SetTouchscreenSimulation(bool isTouchscreenSimulation)
|
||||
{
|
||||
m_isTouchscreenSimulation = isTouchscreenSimulation;
|
||||
|
@@ -32,6 +32,8 @@ public:
|
||||
bool IsUsingMouseAsTouch() const override;
|
||||
bool IsTextInputObstructive() const override;
|
||||
unsigned int GetCPUCount() const override;
|
||||
void SetTextInputEnabled(bool isEnabled) override;
|
||||
bool IsTextInputEnabled() const override;
|
||||
|
||||
void SetTouchscreenSimulation(bool isTouchscreenSimulation);
|
||||
|
||||
|
@@ -166,6 +166,7 @@ void GpThreadEvent_Cpp11::Destroy()
|
||||
}
|
||||
|
||||
GpSystemServices_Android::GpSystemServices_Android()
|
||||
: m_textInputEnabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -269,6 +270,16 @@ unsigned int GpSystemServices_Android::GetCPUCount() const
|
||||
return SDL_GetCPUCount();
|
||||
}
|
||||
|
||||
void GpSystemServices_Android::SetTextInputEnabled(bool isEnabled)
|
||||
{
|
||||
m_textInputEnabled = isEnabled;
|
||||
}
|
||||
|
||||
bool GpSystemServices_Android::IsTextInputEnabled() const
|
||||
{
|
||||
return m_textInputEnabled;
|
||||
}
|
||||
|
||||
GpSystemServices_Android *GpSystemServices_Android::GetInstance()
|
||||
{
|
||||
return &ms_instance;
|
||||
|
@@ -20,9 +20,15 @@ public:
|
||||
bool IsUsingMouseAsTouch() const override;
|
||||
bool IsTextInputObstructive() const override;
|
||||
unsigned int GetCPUCount() const override;
|
||||
void SetTextInputEnabled(bool isEnabled) override;
|
||||
bool IsTextInputEnabled() const override;
|
||||
|
||||
void FlushTextInputEnabled();
|
||||
|
||||
static GpSystemServices_Android *GetInstance();
|
||||
|
||||
private:
|
||||
static GpSystemServices_Android ms_instance;
|
||||
|
||||
bool m_textInputEnabled;
|
||||
};
|
||||
|
@@ -912,6 +912,8 @@ private:
|
||||
|
||||
uint8_t m_paletteStorage[256 * 4 + GP_SYSTEM_MEMORY_ALIGNMENT];
|
||||
uint8_t *m_paletteData;
|
||||
|
||||
bool m_textInputEnabled;
|
||||
};
|
||||
|
||||
|
||||
@@ -1205,6 +1207,7 @@ GpDisplayDriver_SDL_GL2::GpDisplayDriver_SDL_GL2(const GpDisplayDriverProperties
|
||||
, m_contextLost(true)
|
||||
, m_lastSurface(nullptr)
|
||||
, m_firstSurface(nullptr)
|
||||
, m_textInputEnabled(false)
|
||||
{
|
||||
m_bgColor[0] = 0.f;
|
||||
m_bgColor[1] = 0.f;
|
||||
@@ -1915,7 +1918,6 @@ void GpDisplayDriver_SDL_GL2::Run()
|
||||
}
|
||||
|
||||
TranslateSDLMessage(&msg, m_properties.m_eventQueue, m_pixelScaleX, m_pixelScaleY, obstructiveTextInput);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1937,7 +1939,6 @@ void GpDisplayDriver_SDL_GL2::Run()
|
||||
int clientHeight = 0;
|
||||
SDL_GetWindowSize(m_window, &clientWidth, &clientHeight);
|
||||
|
||||
|
||||
unsigned int desiredWidth = clientWidth;
|
||||
unsigned int desiredHeight = clientHeight;
|
||||
if (desiredWidth != m_windowWidthPhysical || desiredHeight != m_windowHeightPhysical || m_isResolutionResetDesired)
|
||||
@@ -2011,6 +2012,16 @@ void GpDisplayDriver_SDL_GL2::Run()
|
||||
continue;
|
||||
}
|
||||
|
||||
bool wantTextInput = m_properties.m_systemServices->IsTextInputEnabled();
|
||||
if (wantTextInput != m_textInputEnabled)
|
||||
{
|
||||
m_textInputEnabled = wantTextInput;
|
||||
if (m_textInputEnabled)
|
||||
SDL_StartTextInput();
|
||||
else
|
||||
SDL_StopTextInput();
|
||||
}
|
||||
|
||||
GpDisplayDriverTickStatus_t tickStatus = PresentFrameAndSync();
|
||||
if (tickStatus == GpDisplayDriverTickStatuses::kFatalFault || tickStatus == GpDisplayDriverTickStatuses::kApplicationTerminated)
|
||||
{
|
||||
|
@@ -32,6 +32,8 @@ namespace PortabilityLayer
|
||||
virtual bool IsUsingMouseAsTouch() const = 0;
|
||||
virtual bool IsTextInputObstructive() const = 0;
|
||||
virtual unsigned int GetCPUCount() const = 0;
|
||||
virtual void SetTextInputEnabled(bool isEnabled) = 0;
|
||||
virtual bool IsTextInputEnabled() const = 0;
|
||||
|
||||
static void SetInstance(HostSystemServices *instance);
|
||||
static HostSystemServices *GetInstance();
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "FontFamily.h"
|
||||
#include "FontManager.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "InputManager.h"
|
||||
#include "MacRomanConversion.h"
|
||||
#include "MemoryManager.h"
|
||||
@@ -42,6 +43,9 @@ namespace PortabilityLayer
|
||||
|
||||
EditboxWidget::~EditboxWidget()
|
||||
{
|
||||
if (m_hasFocus)
|
||||
PortabilityLayer::HostSystemServices::GetInstance()->SetTextInputEnabled(false);
|
||||
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
|
||||
if (m_chars)
|
||||
@@ -155,10 +159,15 @@ namespace PortabilityLayer
|
||||
DrawSurface *surface = m_window->GetDrawSurface();
|
||||
DrawControl(surface);
|
||||
}
|
||||
|
||||
PortabilityLayer::HostSystemServices::GetInstance()->SetTextInputEnabled(true);
|
||||
}
|
||||
|
||||
void EditboxWidget::LoseFocus()
|
||||
{
|
||||
if (m_hasFocus)
|
||||
PortabilityLayer::HostSystemServices::GetInstance()->SetTextInputEnabled(false);
|
||||
|
||||
m_hasFocus = false;
|
||||
m_selStartChar = 0;
|
||||
m_selEndChar = 0;
|
||||
|
Reference in New Issue
Block a user