mirror of
https://github.com/minetest/irrlicht.git
synced 2024-12-25 15:42:25 +01:00
Merging r6173 through r6179 from trunk to ogl-es branch
- Adding optional support for touch input in X11 git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6180 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
1e6fe54cf5
commit
a9f7c2abc9
@ -9,6 +9,7 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point)
|
|||||||
|
|
||||||
--------------------------
|
--------------------------
|
||||||
Changes in 1.9 (not yet released)
|
Changes in 1.9 (not yet released)
|
||||||
|
- Add optional multitouch support to X11 (but disabled in IrrCompileConfig by default). Thanks @TheBrokenRail for a patch proposal based on example code from esjeon (patch #322).
|
||||||
- Slightly changed close window handling on X11 (optimized and avoids problems on some shells). Thanks @TheBrokenRail for a patch (was part of patch #322).
|
- Slightly changed close window handling on X11 (optimized and avoids problems on some shells). Thanks @TheBrokenRail for a patch (was part of patch #322).
|
||||||
- Add getActiveColor functions to IGUIStaticText and IGUIButton (get currently used color).
|
- Add getActiveColor functions to IGUIStaticText and IGUIButton (get currently used color).
|
||||||
- Add IGUIEnvironment::addToDeletionQueue to allow save removal of gui elements while iterating over them (like the same named function in ISceneManager).
|
- Add IGUIEnvironment::addToDeletionQueue to allow save removal of gui elements while iterating over them (like the same named function in ISceneManager).
|
||||||
|
@ -353,6 +353,22 @@ struct SEvent
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Any kind of touch event.
|
||||||
|
struct STouchInput
|
||||||
|
{
|
||||||
|
// Touch ID.
|
||||||
|
size_t ID;
|
||||||
|
|
||||||
|
// X position of simple touch.
|
||||||
|
s32 X;
|
||||||
|
|
||||||
|
// Y position of simple touch.
|
||||||
|
s32 Y;
|
||||||
|
|
||||||
|
//! Type of touch event.
|
||||||
|
ETOUCH_INPUT_EVENT Event;
|
||||||
|
};
|
||||||
|
|
||||||
//! Any kind of mouse event.
|
//! Any kind of mouse event.
|
||||||
struct SMouseInput
|
struct SMouseInput
|
||||||
{
|
{
|
||||||
@ -432,7 +448,6 @@ struct SEvent
|
|||||||
//! Any kind of accelerometer event.
|
//! Any kind of accelerometer event.
|
||||||
struct SAccelerometerEvent
|
struct SAccelerometerEvent
|
||||||
{
|
{
|
||||||
|
|
||||||
// X acceleration.
|
// X acceleration.
|
||||||
f64 X;
|
f64 X;
|
||||||
|
|
||||||
@ -446,7 +461,6 @@ struct SEvent
|
|||||||
//! Any kind of gyroscope event.
|
//! Any kind of gyroscope event.
|
||||||
struct SGyroscopeEvent
|
struct SGyroscopeEvent
|
||||||
{
|
{
|
||||||
|
|
||||||
// X rotation.
|
// X rotation.
|
||||||
f64 X;
|
f64 X;
|
||||||
|
|
||||||
@ -460,7 +474,6 @@ struct SEvent
|
|||||||
//! Any kind of device motion event.
|
//! Any kind of device motion event.
|
||||||
struct SDeviceMotionEvent
|
struct SDeviceMotionEvent
|
||||||
{
|
{
|
||||||
|
|
||||||
// X angle - roll.
|
// X angle - roll.
|
||||||
f64 X;
|
f64 X;
|
||||||
|
|
||||||
|
@ -317,18 +317,22 @@ define out. */
|
|||||||
#undef _IRR_COMPILE_WITH_X11_
|
#undef _IRR_COMPILE_WITH_X11_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! On some Linux systems the XF86 vidmode extension or X11 RandR are missing. Use these flags
|
//! On some Linux systems the XF86 vidmode extension, X11 RandR, or XInput2 are missing.
|
||||||
//! to remove the dependencies such that Irrlicht will compile on those systems, too.
|
//! Use these defines to add/remove support for those dependencies as needed.
|
||||||
//! If you don't need colored cursors you can also disable the Xcursor extension
|
//! XInput2 (library called Xi) is currently only used to support touch-input.
|
||||||
#if defined(_IRR_LINUX_PLATFORM_) && defined(_IRR_COMPILE_WITH_X11_)
|
#if defined(_IRR_LINUX_PLATFORM_) && defined(_IRR_COMPILE_WITH_X11_)
|
||||||
#define _IRR_LINUX_X11_VIDMODE_
|
#define _IRR_LINUX_X11_VIDMODE_
|
||||||
//#define _IRR_LINUX_X11_RANDR_
|
//#define _IRR_LINUX_X11_RANDR_
|
||||||
|
//#define _IRR_LINUX_X11_XINPUT2_
|
||||||
#ifdef NO_IRR_LINUX_X11_VIDMODE_
|
#ifdef NO_IRR_LINUX_X11_VIDMODE_
|
||||||
#undef _IRR_LINUX_X11_VIDMODE_
|
#undef _IRR_LINUX_X11_VIDMODE_
|
||||||
#endif
|
#endif
|
||||||
#ifdef NO_IRR_LINUX_X11_RANDR_
|
#ifdef NO_IRR_LINUX_X11_RANDR_
|
||||||
#undef _IRR_LINUX_X11_RANDR_
|
#undef _IRR_LINUX_X11_RANDR_
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef NO_IRR_LINUX_X11_XINPUT2_
|
||||||
|
#undef _IRR_LINUX_X11_XINPUT2_
|
||||||
|
#endif
|
||||||
|
|
||||||
//! X11 has by default only monochrome cursors, but using the Xcursor library we can also get color cursor support.
|
//! X11 has by default only monochrome cursors, but using the Xcursor library we can also get color cursor support.
|
||||||
//! If you have the need for custom color cursors on X11 then enable this and make sure you also link
|
//! If you have the need for custom color cursors on X11 then enable this and make sure you also link
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
|
#if defined(_IRR_LINUX_X11_XINPUT2_)
|
||||||
|
#include <X11/extensions/XInput2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_IRR_COMPILE_WITH_OGLES1_) || defined(_IRR_COMPILE_WITH_OGLES2_)
|
#if defined(_IRR_COMPILE_WITH_OGLES1_) || defined(_IRR_COMPILE_WITH_OGLES2_)
|
||||||
#include "CEGLManager.h"
|
#include "CEGLManager.h"
|
||||||
#endif
|
#endif
|
||||||
@ -91,6 +95,10 @@ namespace
|
|||||||
Atom X_ATOM_NETWM_STATE;
|
Atom X_ATOM_NETWM_STATE;
|
||||||
|
|
||||||
Atom X_ATOM_WM_DELETE_WINDOW;
|
Atom X_ATOM_WM_DELETE_WINDOW;
|
||||||
|
|
||||||
|
#if defined(_IRR_LINUX_X11_XINPUT2_)
|
||||||
|
int XI_EXTENSIONS_OPCODE;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
@ -568,6 +576,8 @@ bool CIrrDeviceLinux::createWindow()
|
|||||||
if (WMCheck != None)
|
if (WMCheck != None)
|
||||||
HasNetWM = true;
|
HasNetWM = true;
|
||||||
|
|
||||||
|
initXInput2();
|
||||||
|
|
||||||
#endif // #ifdef _IRR_COMPILE_WITH_X11_
|
#endif // #ifdef _IRR_COMPILE_WITH_X11_
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1103,6 +1113,28 @@ bool CIrrDeviceLinux::run()
|
|||||||
XFlush (XDisplay);
|
XFlush (XDisplay);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#if defined(_IRR_LINUX_X11_XINPUT2_)
|
||||||
|
case GenericEvent:
|
||||||
|
{
|
||||||
|
XGenericEventCookie *cookie = &event.xcookie;
|
||||||
|
if (XGetEventData(XDisplay, cookie) && cookie->extension == XI_EXTENSIONS_OPCODE && XI_EXTENSIONS_OPCODE
|
||||||
|
&& (cookie->evtype == XI_TouchUpdate || cookie->evtype == XI_TouchBegin || cookie->evtype == XI_TouchEnd))
|
||||||
|
{
|
||||||
|
XIDeviceEvent *de = (XIDeviceEvent *) cookie->data;
|
||||||
|
|
||||||
|
irrevent.EventType = EET_TOUCH_INPUT_EVENT;
|
||||||
|
|
||||||
|
irrevent.TouchInput.Event = cookie->evtype == XI_TouchUpdate ? ETIE_MOVED : (cookie->evtype == XI_TouchBegin ? ETIE_PRESSED_DOWN : ETIE_LEFT_UP);
|
||||||
|
|
||||||
|
irrevent.TouchInput.ID = de->detail;
|
||||||
|
irrevent.TouchInput.X = de->event_x;
|
||||||
|
irrevent.TouchInput.Y = de->event_y;
|
||||||
|
|
||||||
|
postEventFromUser(irrevent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1988,6 +2020,62 @@ void CIrrDeviceLinux::initXAtoms()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CIrrDeviceLinux::initXInput2()
|
||||||
|
{
|
||||||
|
#if defined(_IRR_LINUX_X11_XINPUT2_)
|
||||||
|
int ev=0;
|
||||||
|
int err=0;
|
||||||
|
if (!XQueryExtension(XDisplay, "XInputExtension", &XI_EXTENSIONS_OPCODE, &ev, &err))
|
||||||
|
{
|
||||||
|
os::Printer::log("X Input extension not available.", ELL_WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int major = 2;
|
||||||
|
int minor = 3;
|
||||||
|
int rc = XIQueryVersion(XDisplay, &major, &minor);
|
||||||
|
if ( rc != Success )
|
||||||
|
{
|
||||||
|
os::Printer::log("No XI2 support.", ELL_WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cnt = 0;
|
||||||
|
XIDeviceInfo *di = XIQueryDevice(XDisplay, XIAllDevices, &cnt);
|
||||||
|
if ( di )
|
||||||
|
{
|
||||||
|
for (int i = 0; i < cnt; ++i)
|
||||||
|
{
|
||||||
|
bool hasTouchClass = false;
|
||||||
|
XIDeviceInfo *dev = &di[i];
|
||||||
|
for (int j = 0; j < dev->num_classes; ++j)
|
||||||
|
{
|
||||||
|
if (dev->classes[j]->type == XITouchClass)
|
||||||
|
{
|
||||||
|
hasTouchClass = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( hasTouchClass )
|
||||||
|
{
|
||||||
|
XIEventMask eventMask;
|
||||||
|
unsigned char mask[XIMaskLen(XI_TouchEnd)];
|
||||||
|
memset(mask, 0, sizeof(mask));
|
||||||
|
eventMask.deviceid = dev->deviceid;
|
||||||
|
eventMask.mask_len = sizeof(mask);
|
||||||
|
eventMask.mask = mask;
|
||||||
|
XISetMask(eventMask.mask, XI_TouchBegin);
|
||||||
|
XISetMask(eventMask.mask, XI_TouchUpdate);
|
||||||
|
XISetMask(eventMask.mask, XI_TouchEnd);
|
||||||
|
|
||||||
|
XISelectEvents(XDisplay, XWindow, &eventMask, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XIFreeDeviceInfo(di);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef _IRR_COMPILE_WITH_X11_
|
#ifdef _IRR_COMPILE_WITH_X11_
|
||||||
|
|
||||||
|
@ -146,6 +146,8 @@ namespace irr
|
|||||||
|
|
||||||
void initXAtoms();
|
void initXAtoms();
|
||||||
|
|
||||||
|
void initXInput2();
|
||||||
|
|
||||||
bool switchToFullscreen(bool reset=false);
|
bool switchToFullscreen(bool reset=false);
|
||||||
|
|
||||||
#ifdef _IRR_COMPILE_WITH_X11_
|
#ifdef _IRR_COMPILE_WITH_X11_
|
||||||
|
Loading…
Reference in New Issue
Block a user