Move the screen and touchscreen events horizontally for screen keyboard
This commit is contained in:
parent
18dc77c8f9
commit
d5246e5291
@ -1,73 +1,73 @@
|
||||
package org.supertuxkart.stk_dbg;
|
||||
|
||||
import android.app.NativeActivity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.view.View;
|
||||
|
||||
public class SuperTuxKartActivity extends NativeActivity
|
||||
{
|
||||
private native void saveFromJavaChars(String chars);
|
||||
private native void saveKeyboardHeight(int height);
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle instance)
|
||||
{
|
||||
super.onCreate(instance);
|
||||
System.loadLibrary("main");
|
||||
final View root = getWindow().getDecorView().findViewById(
|
||||
android.R.id.content);
|
||||
root.getViewTreeObserver().addOnGlobalLayoutListener(new
|
||||
OnGlobalLayoutListener()
|
||||
{
|
||||
@Override
|
||||
public void onGlobalLayout()
|
||||
{
|
||||
Rect r = new Rect();
|
||||
root.getWindowVisibleDisplayFrame(r);
|
||||
int screen_height = root.getRootView().getHeight();
|
||||
int keyboard_height = screen_height - (r.bottom);
|
||||
saveKeyboardHeight(keyboard_height);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event)
|
||||
{
|
||||
// ACTION_MULTIPLE deprecated in API level Q, it says if the key code
|
||||
// is KEYCODE_UNKNOWN, then this is a sequence of characters as
|
||||
// returned by getCharacters()
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN &&
|
||||
event.getAction() == KeyEvent.ACTION_MULTIPLE)
|
||||
{
|
||||
String chars = event.getCharacters();
|
||||
if (chars != null)
|
||||
{
|
||||
saveFromJavaChars(chars);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
public void showKeyboard()
|
||||
{
|
||||
InputMethodManager imm = (InputMethodManager)
|
||||
getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(getWindow().getDecorView(),
|
||||
InputMethodManager.SHOW_FORCED);
|
||||
}
|
||||
|
||||
public void hideKeyboard()
|
||||
{
|
||||
InputMethodManager imm = (InputMethodManager)
|
||||
getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(
|
||||
getWindow().getDecorView().getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
package org.supertuxkart.stk_dbg;
|
||||
|
||||
import android.app.NativeActivity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.view.View;
|
||||
|
||||
public class SuperTuxKartActivity extends NativeActivity
|
||||
{
|
||||
private native void saveFromJavaChars(String chars);
|
||||
private native void saveKeyboardHeight(int height);
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle instance)
|
||||
{
|
||||
super.onCreate(instance);
|
||||
System.loadLibrary("main");
|
||||
final View root = getWindow().getDecorView().findViewById(
|
||||
android.R.id.content);
|
||||
root.getViewTreeObserver().addOnGlobalLayoutListener(new
|
||||
OnGlobalLayoutListener()
|
||||
{
|
||||
@Override
|
||||
public void onGlobalLayout()
|
||||
{
|
||||
Rect r = new Rect();
|
||||
root.getWindowVisibleDisplayFrame(r);
|
||||
int screen_height = root.getRootView().getHeight();
|
||||
int keyboard_height = screen_height - (r.bottom);
|
||||
saveKeyboardHeight(keyboard_height);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event)
|
||||
{
|
||||
// ACTION_MULTIPLE deprecated in API level Q, it says if the key code
|
||||
// is KEYCODE_UNKNOWN, then this is a sequence of characters as
|
||||
// returned by getCharacters()
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN &&
|
||||
event.getAction() == KeyEvent.ACTION_MULTIPLE)
|
||||
{
|
||||
String chars = event.getCharacters();
|
||||
if (chars != null)
|
||||
{
|
||||
saveFromJavaChars(chars);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
public void showKeyboard()
|
||||
{
|
||||
InputMethodManager imm = (InputMethodManager)
|
||||
getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(getWindow().getDecorView(),
|
||||
InputMethodManager.SHOW_FORCED);
|
||||
}
|
||||
|
||||
public void hideKeyboard()
|
||||
{
|
||||
InputMethodManager imm = (InputMethodManager)
|
||||
getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(
|
||||
getWindow().getDecorView().getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ namespace irr
|
||||
*/
|
||||
class IrrlichtDevice : public virtual IReferenceCounted
|
||||
{
|
||||
protected:
|
||||
typedef s32 (*HeightFunc)(const IrrlichtDevice*);
|
||||
public:
|
||||
|
||||
//! Runs the device.
|
||||
@ -287,6 +289,13 @@ namespace irr
|
||||
used. */
|
||||
virtual E_DEVICE_TYPE getType() const = 0;
|
||||
|
||||
/** Onscreen keyboard addition, to determine how much to move vertically. */
|
||||
virtual u32 getScreenHeight() const { return 0; }
|
||||
virtual u32 getOnScreenKeyboardHeight() const { return 0; }
|
||||
virtual s32 getMovedHeight() const { return 0; }
|
||||
virtual void toggleOnScreenKeyboard(bool show) { }
|
||||
virtual void registerGetMovedHeightFunction(HeightFunc) { }
|
||||
|
||||
//! Check if a driver type is supported by the engine.
|
||||
/** Even if true is returned the driver may not be available
|
||||
for a configuration requested when creating the device. */
|
||||
|
@ -59,7 +59,7 @@ namespace irr
|
||||
namespace video
|
||||
{
|
||||
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
video::SExposedVideoData& data, io::IFileSystem* io);
|
||||
video::SExposedVideoData& data, io::IFileSystem* io, IrrlichtDevice* device);
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +102,10 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CIrrDeviceAndroid");
|
||||
#endif
|
||||
|
||||
m_screen_height = 0;
|
||||
m_moved_height = 0;
|
||||
m_moved_height_func = NULL;
|
||||
|
||||
createKeyMap();
|
||||
|
||||
CursorControl = new CCursorControl();
|
||||
@ -223,6 +226,13 @@ void CIrrDeviceAndroid::printConfig()
|
||||
os::Printer::log(" ui_mode_night:", core::stringc(ui_mode_night).c_str(), ELL_DEBUG);
|
||||
}
|
||||
|
||||
u32 CIrrDeviceAndroid::getOnScreenKeyboardHeight() const
|
||||
{
|
||||
if (g_keyboard_height > 0)
|
||||
return g_keyboard_height;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CIrrDeviceAndroid::createVideoModeList()
|
||||
{
|
||||
if (VideoModeList.getVideoModeCount() > 0)
|
||||
@ -238,6 +248,7 @@ void CIrrDeviceAndroid::createVideoModeList()
|
||||
{
|
||||
CreationParams.WindowSize.Width = width;
|
||||
CreationParams.WindowSize.Height = height;
|
||||
m_screen_height = height;
|
||||
}
|
||||
|
||||
core::dimension2d<u32> size = core::dimension2d<u32>(
|
||||
@ -255,7 +266,7 @@ void CIrrDeviceAndroid::createDriver()
|
||||
{
|
||||
case video::EDT_OGLES2:
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
VideoDriver = video::createOGLES2Driver(CreationParams, ExposedVideoData, FileSystem);
|
||||
VideoDriver = video::createOGLES2Driver(CreationParams, ExposedVideoData, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("No OpenGL ES 2.0 support compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
@ -280,6 +291,8 @@ bool CIrrDeviceAndroid::run()
|
||||
|
||||
while (!Close)
|
||||
{
|
||||
if (m_moved_height_func != NULL)
|
||||
m_moved_height = m_moved_height_func(this);
|
||||
if (!g_from_java_chars.empty())
|
||||
{
|
||||
std::vector<wchar_t> utf32;
|
||||
@ -609,6 +622,7 @@ s32 CIrrDeviceAndroid::handleTouch(AInputEvent* androidEvent)
|
||||
|
||||
bool touchReceived = true;
|
||||
bool simulate_mouse = false;
|
||||
int adjusted_height = getMovedHeight();
|
||||
core::position2d<s32> mouse_pos = core::position2d<s32>(0, 0);
|
||||
|
||||
switch (eventAction & AMOTION_EVENT_ACTION_MASK)
|
||||
@ -662,7 +676,7 @@ s32 CIrrDeviceAndroid::handleTouch(AInputEvent* androidEvent)
|
||||
|
||||
event_data.event = event.TouchInput.Event;
|
||||
event_data.x = event.TouchInput.X;
|
||||
event_data.y = event.TouchInput.Y;
|
||||
event_data.y = event.TouchInput.Y + adjusted_height;
|
||||
|
||||
postEventFromUser(event);
|
||||
|
||||
@ -712,7 +726,7 @@ s32 CIrrDeviceAndroid::handleTouch(AInputEvent* androidEvent)
|
||||
irr::EMBSM_LEFT : 0;
|
||||
irrevent.EventType = EET_MOUSE_INPUT_EVENT;
|
||||
irrevent.MouseInput.X = mouse_pos.X;
|
||||
irrevent.MouseInput.Y = mouse_pos.Y;
|
||||
irrevent.MouseInput.Y = mouse_pos.Y + adjusted_height;
|
||||
|
||||
postEventFromUser(irrevent);
|
||||
}
|
||||
@ -1384,8 +1398,11 @@ void CIrrDeviceAndroid::hideNavBar(ANativeActivity* activity)
|
||||
}
|
||||
}
|
||||
|
||||
void CIrrDeviceAndroid::showKeyboard(bool show)
|
||||
void CIrrDeviceAndroid::toggleOnScreenKeyboard(bool show)
|
||||
{
|
||||
if (!Android)
|
||||
return;
|
||||
|
||||
bool was_detached = false;
|
||||
JNIEnv* env = NULL;
|
||||
|
||||
|
@ -74,9 +74,16 @@ namespace irr
|
||||
virtual bool isGyroscopeActive();
|
||||
virtual bool isGyroscopeAvailable();
|
||||
virtual void setTextInputEnabled(bool enabled) {TextInputEnabled = enabled;}
|
||||
virtual void showKeyboard(bool show);
|
||||
virtual void toggleOnScreenKeyboard(bool show);
|
||||
virtual bool supportsTouchDevice() { return HasTouchDevice; }
|
||||
|
||||
virtual u32 getScreenHeight() const { return m_screen_height; }
|
||||
virtual u32 getOnScreenKeyboardHeight() const;
|
||||
virtual s32 getMovedHeight() const { return m_moved_height; }
|
||||
virtual void registerGetMovedHeightFunction(HeightFunc height_function)
|
||||
{
|
||||
m_moved_height_func = height_function;
|
||||
}
|
||||
|
||||
class CCursorControl : public gui::ICursorControl
|
||||
{
|
||||
public:
|
||||
@ -120,6 +127,9 @@ namespace irr
|
||||
ANativeActivity* activity);
|
||||
|
||||
private:
|
||||
s32 m_moved_height;
|
||||
u32 m_screen_height;
|
||||
HeightFunc m_moved_height_func;
|
||||
android_app* Android;
|
||||
ASensorManager* SensorManager;
|
||||
ASensorEventQueue* SensorEventQueue;
|
||||
|
@ -75,7 +75,7 @@ namespace irr
|
||||
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io, CIrrDeviceLinux* device);
|
||||
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
video::SExposedVideoData& data, io::IFileSystem* io);
|
||||
video::SExposedVideoData& data, io::IFileSystem* io, IrrlichtDevice* device);
|
||||
}
|
||||
} // end namespace irr
|
||||
|
||||
@ -1324,7 +1324,7 @@ void CIrrDeviceLinux::createDriver()
|
||||
video::SExposedVideoData data;
|
||||
data.OpenGLLinux.X11Window = window;
|
||||
data.OpenGLLinux.X11Display = display;
|
||||
VideoDriver = video::createOGLES2Driver(CreationParams, data, FileSystem);
|
||||
VideoDriver = video::createOGLES2Driver(CreationParams, data, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("No OpenGL ES 2.0 support compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
namespace irr
|
||||
{
|
||||
class IrrlichtDevice;
|
||||
namespace io
|
||||
{
|
||||
class IWriteFile;
|
||||
@ -384,6 +385,7 @@ namespace video
|
||||
virtual void drawMeshBufferNormals(const scene::IMeshBuffer* mb, f32 length=10.f, SColor color=0xffffffff);
|
||||
|
||||
protected:
|
||||
IrrlichtDevice* m_device;
|
||||
struct SHWBufferLink
|
||||
{
|
||||
SHWBufferLink(const scene::IMeshBuffer *_MeshBuffer)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "CContextEGL.h"
|
||||
#include "CImage.h"
|
||||
#include "os.h"
|
||||
#include "IrrlichtDevice.h"
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
@ -28,6 +29,10 @@
|
||||
#include <GLES2/gl2.h>
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
#include "CIrrDeviceWayland.h"
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
@ -39,6 +44,8 @@ namespace video
|
||||
const SExposedVideoData& data, io::IFileSystem* io
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
, CIrrDeviceIPhone* device
|
||||
#else
|
||||
, IrrlichtDevice* device
|
||||
#endif
|
||||
)
|
||||
: CNullDriver(io, params.WindowSize), COGLES2ExtensionHandler(),
|
||||
@ -135,6 +142,7 @@ namespace video
|
||||
|
||||
genericDriverInit(WindowSize, params.Stencilbuffer);
|
||||
#endif
|
||||
m_device = device;
|
||||
}
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
@ -150,6 +158,7 @@ namespace video
|
||||
EglContext = device->getEGLContext();
|
||||
EglContextExternal = true;
|
||||
genericDriverInit(params.WindowSize, params.Stencilbuffer);
|
||||
m_device = device;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1382,8 +1391,9 @@ namespace video
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y,
|
||||
clipRect->getWidth(), clipRect->getHeight());
|
||||
glScissor(clipRect->UpperLeftCorner.X,
|
||||
(s32)renderTargetSize.Height - clipRect->LowerRightCorner.Y + m_device->getMovedHeight(),
|
||||
clipRect->getWidth(), clipRect->getHeight());
|
||||
}
|
||||
|
||||
u16 indices[] = {0, 1, 2, 3};
|
||||
@ -1423,8 +1433,9 @@ namespace video
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y,
|
||||
clipRect->getWidth(), clipRect->getHeight());
|
||||
glScissor(clipRect->UpperLeftCorner.X,
|
||||
(s32)renderTargetSize.Height - clipRect->LowerRightCorner.Y + m_device->getMovedHeight(),
|
||||
clipRect->getWidth(), clipRect->getHeight());
|
||||
}
|
||||
|
||||
const core::dimension2du& ss = texture->getSize();
|
||||
@ -2900,10 +2911,10 @@ namespace video
|
||||
|
||||
#if !defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_) && (defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_SDL_DEVICE_) || defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_))
|
||||
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
video::SExposedVideoData& data, io::IFileSystem* io)
|
||||
video::SExposedVideoData& data, io::IFileSystem* io, IrrlichtDevice* device)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
return new COGLES2Driver(params, data, io);
|
||||
return new COGLES2Driver(params, data, io, device);
|
||||
#else
|
||||
return 0;
|
||||
#endif // _IRR_COMPILE_WITH_OGLES2_
|
||||
|
@ -62,7 +62,7 @@ namespace video
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_SDL_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
COGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
const SExposedVideoData& data,
|
||||
io::IFileSystem* io);
|
||||
io::IFileSystem* io, IrrlichtDevice* device);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
|
@ -17,6 +17,7 @@ extern bool GLContextDebugBit;
|
||||
#include "COpenGLNormalMapRenderer.h"
|
||||
#include "COpenGLParallaxMapRenderer.h"
|
||||
#include "os.h"
|
||||
#include "IrrlichtDevice.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#include <SDL/SDL.h>
|
||||
@ -31,6 +32,14 @@ extern bool GLContextDebugBit;
|
||||
#include "CContextEGL.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
#include "CIrrDeviceWin32.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
#include "CIrrDeviceLinux.h"
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
@ -54,6 +63,7 @@ COpenGLDriver::COpenGLDriver(const irr::SIrrlichtCreationParameters& params,
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COpenGLDriver");
|
||||
#endif
|
||||
m_device = device;
|
||||
}
|
||||
|
||||
|
||||
@ -589,6 +599,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
#endif
|
||||
|
||||
genericDriverInit();
|
||||
m_device = device;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -610,6 +621,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COpenGLDriver");
|
||||
#endif
|
||||
m_device = device;
|
||||
}
|
||||
|
||||
|
||||
@ -699,6 +711,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COpenGLDriver");
|
||||
#endif
|
||||
m_device = device;
|
||||
}
|
||||
|
||||
|
||||
@ -746,6 +759,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
#endif
|
||||
|
||||
genericDriverInit();
|
||||
m_device = device;
|
||||
}
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
@ -2387,7 +2401,8 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture, const core::rect
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height-clipRect->LowerRightCorner.Y,
|
||||
glScissor(clipRect->UpperLeftCorner.X,
|
||||
(s32)renderTargetSize.Height-clipRect->LowerRightCorner.Y+m_device->getMovedHeight(),
|
||||
clipRect->getWidth(), clipRect->getHeight());
|
||||
}
|
||||
|
||||
@ -2444,8 +2459,9 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture,
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height-clipRect->LowerRightCorner.Y,
|
||||
clipRect->getWidth(),clipRect->getHeight());
|
||||
glScissor(clipRect->UpperLeftCorner.X,
|
||||
(s32)renderTargetSize.Height-clipRect->LowerRightCorner.Y+m_device->getMovedHeight(),
|
||||
clipRect->getWidth(), clipRect->getHeight());
|
||||
}
|
||||
|
||||
const core::dimension2d<u32>& ss = texture->getSize();
|
||||
|
@ -309,7 +309,8 @@ void draw2DImage(const video::ITexture* texture,
|
||||
const core::dimension2d<u32>& render_target_size =
|
||||
irr_driver->getActualScreenSize();
|
||||
glScissor(clip_rect->UpperLeftCorner.X,
|
||||
render_target_size.Height - clip_rect->LowerRightCorner.Y,
|
||||
(s32)render_target_size.Height - clip_rect->LowerRightCorner.Y +
|
||||
irr_driver->getDevice()->getMovedHeight(),
|
||||
clip_rect->getWidth(), clip_rect->getHeight());
|
||||
}
|
||||
|
||||
@ -384,7 +385,8 @@ void draw2DImage(const video::ITexture* texture,
|
||||
const core::dimension2d<u32>& render_target_size =
|
||||
irr_driver->getActualScreenSize();
|
||||
glScissor(clip_rect->UpperLeftCorner.X,
|
||||
render_target_size.Height - clip_rect->LowerRightCorner.Y,
|
||||
(s32)render_target_size.Height - clip_rect->LowerRightCorner.Y +
|
||||
irr_driver->getDevice()->getMovedHeight(),
|
||||
clip_rect->getWidth(), clip_rect->getHeight());
|
||||
}
|
||||
|
||||
@ -494,8 +496,9 @@ void draw2DImage(const video::ITexture* texture,
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
const core::dimension2d<u32>& render_target_size =
|
||||
irr_driver->getActualScreenSize();
|
||||
glScissor(clip_rect->UpperLeftCorner.X,
|
||||
render_target_size.Height - clip_rect->LowerRightCorner.Y,
|
||||
glScissor(clip_rect->UpperLeftCorner.X,
|
||||
(s32)render_target_size.Height - clip_rect->LowerRightCorner.Y +
|
||||
irr_driver->getDevice()->getMovedHeight(),
|
||||
clip_rect->getWidth(), clip_rect->getHeight());
|
||||
}
|
||||
if (colors)
|
||||
@ -571,7 +574,8 @@ void draw2DImage(const video::ITexture* texture,
|
||||
const core::dimension2d<u32>& render_target_size =
|
||||
irr_driver->getActualScreenSize();
|
||||
glScissor(clip_rect->UpperLeftCorner.X,
|
||||
render_target_size.Height - clip_rect->LowerRightCorner.Y,
|
||||
(s32)render_target_size.Height - clip_rect->LowerRightCorner.Y +
|
||||
irr_driver->getDevice()->getMovedHeight(),
|
||||
clip_rect->getWidth(), clip_rect->getHeight());
|
||||
}
|
||||
if (colors)
|
||||
@ -680,7 +684,8 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
|
||||
const core::dimension2d<u32>& render_target_size =
|
||||
irr_driver->getActualScreenSize();
|
||||
glScissor(clip->UpperLeftCorner.X,
|
||||
render_target_size.Height - clip->LowerRightCorner.Y,
|
||||
(s32)render_target_size.Height - clip->LowerRightCorner.Y +
|
||||
irr_driver->getDevice()->getMovedHeight(),
|
||||
clip->getWidth(), clip->getHeight());
|
||||
}
|
||||
|
||||
|
@ -92,10 +92,15 @@ void FixedPipelineRenderer::render(float dt, bool is_loading)
|
||||
} // for i<getNumKarts
|
||||
|
||||
// Either render the gui, or the global elements of the race gui.
|
||||
glViewport(0, irr_driver->getDevice()->getMovedHeight(),
|
||||
irr_driver->getActualScreenSize().Width,
|
||||
irr_driver->getActualScreenSize().Height);
|
||||
GUIEngine::render(dt, is_loading);
|
||||
|
||||
if (irr_driver->getRenderNetworkDebug() && !is_loading)
|
||||
irr_driver->renderNetworkDebug();
|
||||
glViewport(0, 0, irr_driver->getActualScreenSize().Width,
|
||||
irr_driver->getActualScreenSize().Height);
|
||||
|
||||
// Render the profiler
|
||||
if(UserConfigParams::m_profiler_enabled)
|
||||
|
@ -736,6 +736,39 @@ void IrrDriver::initDevice()
|
||||
m_device->getCursorControl()->setVisible(true);
|
||||
#endif
|
||||
m_pointer_shown = true;
|
||||
|
||||
#ifdef ANDROID
|
||||
if (ProfileWorld::isNoGraphics())
|
||||
return;
|
||||
|
||||
m_device->registerGetMovedHeightFunction([]
|
||||
(const IrrlichtDevice* device)->int
|
||||
{
|
||||
int screen_keyboard_height =
|
||||
device->getOnScreenKeyboardHeight();
|
||||
int screen_height = device->getScreenHeight();
|
||||
if (screen_keyboard_height == 0 || screen_height == 0)
|
||||
return 0;
|
||||
|
||||
GUIEngine::Widget* w = GUIEngine::getFocusForPlayer(0);
|
||||
if (!w)
|
||||
return 0;
|
||||
|
||||
core::rect<s32> pos =
|
||||
w->getIrrlichtElement()->getAbsolutePosition();
|
||||
// Add 10% margin
|
||||
int element_height = (int)device->getScreenHeight() -
|
||||
pos.LowerRightCorner.Y - int(screen_height * 0.01f);
|
||||
if (element_height > screen_keyboard_height)
|
||||
return 0;
|
||||
else if (element_height < 0)
|
||||
{
|
||||
// For buttons near the edge of the bottom of screen
|
||||
return screen_keyboard_height;
|
||||
}
|
||||
return screen_keyboard_height - element_height;
|
||||
});
|
||||
#endif
|
||||
} // initDevice
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1899,6 +1932,7 @@ void IrrDriver::update(float dt, bool is_loading)
|
||||
#endif
|
||||
World *world = World::getWorld();
|
||||
|
||||
int moved_height = irr_driver->getDevice()->getMovedHeight();
|
||||
if (world)
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
@ -1907,7 +1941,11 @@ void IrrDriver::update(float dt, bool is_loading)
|
||||
GUIEngine::Screen* current_screen = GUIEngine::getCurrentScreen();
|
||||
if (current_screen != NULL && current_screen->needs3D())
|
||||
{
|
||||
glViewport(0, moved_height, irr_driver->getActualScreenSize().Width,
|
||||
irr_driver->getActualScreenSize().Height);
|
||||
GUIEngine::render(dt, is_loading);
|
||||
glViewport(0, 0, irr_driver->getActualScreenSize().Width,
|
||||
irr_driver->getActualScreenSize().Height);
|
||||
}
|
||||
|
||||
if (!is_loading && Physics::getInstance())
|
||||
@ -1922,15 +1960,21 @@ void IrrDriver::update(float dt, bool is_loading)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
m_video_driver->beginScene(/*backBuffer clear*/ true, /*zBuffer*/ true,
|
||||
video::SColor(255,100,101,140));
|
||||
|
||||
glViewport(0, moved_height, irr_driver->getActualScreenSize().Width,
|
||||
irr_driver->getActualScreenSize().Height);
|
||||
GUIEngine::render(dt, is_loading);
|
||||
if (m_render_nw_debug && !is_loading)
|
||||
{
|
||||
renderNetworkDebug();
|
||||
}
|
||||
glViewport(0, 0, irr_driver->getActualScreenSize().Width,
|
||||
irr_driver->getActualScreenSize().Height);
|
||||
m_video_driver->endScene();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (m_request_screenshot) doScreenShot();
|
||||
|
@ -802,9 +802,15 @@ void ShaderBasedRenderer::render(float dt, bool is_loading)
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_GUI));
|
||||
PROFILER_PUSH_CPU_MARKER("GUIEngine", 0x75, 0x75, 0x75);
|
||||
// Either render the gui, or the global elements of the race gui.
|
||||
glViewport(0, irr_driver->getDevice()->getMovedHeight(),
|
||||
irr_driver->getActualScreenSize().Width,
|
||||
irr_driver->getActualScreenSize().Height);
|
||||
GUIEngine::render(dt, is_loading);
|
||||
|
||||
if (irr_driver->getRenderNetworkDebug() && !is_loading)
|
||||
irr_driver->renderNetworkDebug();
|
||||
glViewport(0, 0, irr_driver->getActualScreenSize().Width,
|
||||
irr_driver->getActualScreenSize().Height);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,7 @@ CGUIEditBox::~CGUIEditBox()
|
||||
irr_driver->getDevice());
|
||||
dl->setTextInputEnabled(false);
|
||||
}
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(false);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -610,13 +611,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
|
||||
else
|
||||
{
|
||||
#ifdef ANDROID
|
||||
if (irr_driver->getDevice()->getType() == irr::EIDT_ANDROID &&
|
||||
UserConfigParams::m_screen_keyboard == 3)
|
||||
{
|
||||
CIrrDeviceAndroid* dl = dynamic_cast<CIrrDeviceAndroid*>(
|
||||
irr_driver->getDevice());
|
||||
dl->showKeyboard(false);
|
||||
}
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(false);
|
||||
#endif
|
||||
sendGuiEvent( EGET_EDITBOX_ENTER );
|
||||
}
|
||||
@ -1315,12 +1310,7 @@ bool CGUIEditBox::processMouse(const SEvent& event)
|
||||
#ifdef ANDROID
|
||||
else if (UserConfigParams::m_screen_keyboard == 3)
|
||||
{
|
||||
if (irr_driver->getDevice()->getType() == irr::EIDT_ANDROID)
|
||||
{
|
||||
CIrrDeviceAndroid* dl = dynamic_cast<CIrrDeviceAndroid*>(
|
||||
irr_driver->getDevice());
|
||||
dl->showKeyboard(true);
|
||||
}
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(true);
|
||||
}
|
||||
#endif
|
||||
// move cursor
|
||||
|
Loading…
Reference in New Issue
Block a user