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