-Adds touch event listener.
-Drawing of eyes by polygon instead of line.
struct wl_seat* m_wlSeat;
struct wl_pointer* m_wlPointer;
struct wl_keyboard* m_wlKeyboard;
+ struct wl_touch* m_wlTouch;
struct serverinfo* m_wlServerInfo;
uint32_t m_mask;
uint32_t m_connectionId;
struct wl_pointer_listener* m_wlPointerListener;
struct wl_keyboard_listener* m_wlKeyboardListener;
+ struct wl_touch_listener* m_wlTouchListener;
// methods
public:
virtual ~WLContext();
bool InitWLContext(const struct wl_pointer_listener* wlPointerListener = NULL,
- const struct wl_keyboard_listener* wlKeyboardListener = NULL);
+ const struct wl_keyboard_listener* wlKeyboardListener = NULL,
+ const struct wl_touch_listener* wlTouchListener = NULL);
struct wl_compositor* GetWLCompositor() const;
struct wl_display* GetWLDisplay() const;
struct wl_pointer* GetWLPointer() const;
struct wl_keyboard* GetWLKeyboard() const;
+ struct wl_touch* GetWLTouch() const;
struct wl_seat* GetWLSeat() const;
struct wl_pointer_listener* GetWLPointerListener() const;
struct wl_keyboard_listener* GetWLKeyboardListener() const;
+ struct wl_touch_listener* GetWLTouchListener() const;
uint32_t GetConnectionId() const;
void SetEventMask(uint32_t mask);
void SetConnectionId(uint32_t connectionId);
void SetWLPointer(struct wl_pointer* wlPointer);
void SetWLKeyboard(struct wl_keyboard* wlKeyboard);
+ void SetWLTouch(struct wl_touch* wlTouch);
static void DisplayHandleGlobal(struct wl_display* display,
uint32_t id,
inline struct wl_display* WLContext::GetWLDisplay() const { return m_wlDisplay; }
inline struct wl_pointer* WLContext::GetWLPointer() const { return m_wlPointer; }
inline struct wl_keyboard* WLContext::GetWLKeyboard() const { return m_wlKeyboard; }
+inline struct wl_touch* WLContext::GetWLTouch() const { return m_wlTouch; }
inline struct wl_seat* WLContext::GetWLSeat() const { return m_wlSeat; }
inline struct wl_pointer_listener* WLContext::GetWLPointerListener() const
{ return m_wlPointerListener; }
inline struct wl_keyboard_listener* WLContext::GetWLKeyboardListener() const
{ return m_wlKeyboardListener; }
+inline struct wl_touch_listener* WLContext::GetWLTouchListener() const
+ { return m_wlTouchListener; }
inline uint32_t WLContext::GetConnectionId() const { return m_connectionId; }
inline void WLContext::SetEventMask(uint32_t mask) { m_mask = mask; }
{ m_wlPointer = wlPointer; }
inline void WLContext::SetWLKeyboard(struct wl_keyboard* wlKeyboard)
{ m_wlKeyboard = wlKeyboard; }
+inline void WLContext::SetWLTouch(struct wl_touch* wlTouch)
+ { m_wlTouch = wlTouch; }
#endif
TPoint* m_eyeLiner;
int m_nPupilPoint;
TPoint* m_pupil;
+ int m_nWhiteEyePoint;
+ TPoint* m_whiteEye;
public:
WLEye();
const Transform& trans);
void GetEyeLinerGeom(int* nPoint, float** points);
+ void GetWhiteEyeGeom(int* nPoint, float** points);
void GetPupilGeom(int* nPoint, float** points);
+
+private:
+ void CreateWhiteEye(const float& centerX,
+ const float& centerY,
+ const float& diam,
+ const Transform& trans);
};
//////////////////////////////////////////////////////////////////////////////
void SetPointOfView(int mousePosX, int mousePosY);
void GetEyeLinerGeom(int n, int* nPoint, float** points);
+ void GetWhiteEyeGeom(int n, int* nPoint, float** points);
void GetPupilGeom(int n, int* nPoint, float** points);
private:
void KeyboardHandleModifiers(void*, struct wl_keyboard*, uint32_t, uint32_t,
uint32_t, uint32_t, uint32_t);
+// Touch event handler
+void TouchHandleDown(void*, struct wl_touch*, uint32_t, uint32_t, struct wl_surface*,
+ int32_t, wl_fixed_t, wl_fixed_t);
+void TouchHandleUp(void*, struct wl_touch*, uint32_t, uint32_t, int32_t);
+void TouchHandleMotion(void*, struct wl_touch*, uint32_t, int32_t, wl_fixed_t, wl_fixed_t);
+void TouchHandleFrame(void*, struct wl_touch*);
+void TouchHandleCancel(void*, struct wl_touch*);
+
bool DrawEyes(WLEGLSurface* surface, WLEyes* eyes);
void DrawFillPoly(const int nPoint, const float* points, const float color[4]);
void DrawPoly(const int nPoint, const float* points, const float color[4], int width);
-const struct wl_pointer_listener PointerListener
-{
- PointerHandleEnter,
- PointerHandleLeave,
- PointerHandleMotion,
- PointerHandleButton,
- PointerHandleAxis
-};
-
-const struct wl_keyboard_listener KeyboardListener
-{
- KeyboardHandleKeymap,
- KeyboardHandleEnter,
- KeyboardHandleLeave,
- KeyboardHandleKey,
- KeyboardHandleModifiers,
-};
+extern const struct wl_pointer_listener PointerListener;
+extern const struct wl_keyboard_listener KeyboardListener;
+extern const struct wl_touch_listener TouchListener;
#endif
, m_wlCompositor(NULL)
, m_wlSeat(NULL)
, m_wlPointer(NULL)
+, m_wlTouch(NULL)
, m_wlServerInfo(NULL)
, m_mask(0)
, m_connectionId(0)
, m_wlPointerListener(NULL)
+, m_wlKeyboardListener(NULL)
+, m_wlTouchListener(NULL)
{
}
wlKeyboard = NULL;
}
context->SetWLKeyboard(wlKeyboard);
+
+ struct wl_touch* wlTouch = context->GetWLTouch();
+ if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !wlTouch){
+ wlTouch = wl_seat_get_touch(wlSeat);
+ wl_touch_set_user_data(wlTouch, data);
+ wl_touch_add_listener(wlTouch, context->GetWLTouchListener(), data);
+ } else
+ if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && wlTouch){
+ wl_touch_destroy(wlTouch);
+ wlTouch = NULL;
+ }
+ context->SetWLTouch(wlTouch);
}
//////////////////////////////////////////////////////////////////////////////
bool
WLContext::InitWLContext(const struct wl_pointer_listener* wlPointerListener,
- const struct wl_keyboard_listener* wlKeyboardListener)
+ const struct wl_keyboard_listener* wlKeyboardListener,
+ const struct wl_touch_listener* wlTouchListener)
{
m_wlPointerListener = const_cast<wl_pointer_listener*>(wlPointerListener);
m_wlKeyboardListener = const_cast<wl_keyboard_listener*>(wlKeyboardListener);
+ m_wlTouchListener = const_cast<wl_touch_listener*>(wlTouchListener);
m_wlDisplay = wl_display_connect(NULL);
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
+ //EGL_SAMPLE_BUFFERS, 1,
+ //EGL_SAMPLES, 2,
EGL_NONE,
};
EGLint contextAttribs[] = {
, m_eyeLiner(NULL)
, m_nPupilPoint(0)
, m_pupil(NULL)
+, m_nWhiteEyePoint(0)
+, m_whiteEye(NULL)
{
}
if (m_nPupilPoint > 0 && m_pupil){
free(m_pupil);
}
+ if (m_nWhiteEyePoint > 0 && m_whiteEye){
+ free(m_whiteEye);
+ }
}
void
m_nPoint = 0;
}
CreateEllipsePoints(centerX, centerY, diam, trans, m_nPoint, m_eyeLiner);
+
+ CreateWhiteEye(centerX, centerY, diam * 0.8, trans);
+}
+
+void
+WLEye::CreateWhiteEye(const float& centerX, const float& centerY,
+ const float& diam, const Transform& trans)
+{
+ if (m_nWhiteEyePoint > 0 && m_whiteEye){
+ free(m_whiteEye);
+ m_nWhiteEyePoint = 0;
+ }
+ CreateEllipsePoints(centerX, centerY, diam, trans, m_nWhiteEyePoint, m_whiteEye);
}
void
}
void
+WLEye::GetWhiteEyeGeom(int* nPoint, float** points)
+{
+ *nPoint = m_nWhiteEyePoint;
+ *points = (float*)m_whiteEye;
+}
+
+void
WLEye::GetPupilGeom(int* nPoint, float** points)
{
*nPoint = m_nPupilPoint;
}
void
+WLEyes::GetWhiteEyeGeom(int n, int* nPoint, float** points)
+{
+ *nPoint = 0;
+ *points = NULL;
+ if (n < 3){
+ m_eyes[n]->GetWhiteEyeGeom(nPoint, points);
+ }
+}
+
+void
WLEyes::GetPupilGeom(int n, int* nPoint, float** points)
{
*nPoint = 0;
extern int gPointerX;
extern int gPointerY;
+const struct wl_pointer_listener PointerListener = {
+ PointerHandleEnter,
+ PointerHandleLeave,
+ PointerHandleMotion,
+ PointerHandleButton,
+ PointerHandleAxis
+};
+
+const struct wl_keyboard_listener KeyboardListener = {
+ KeyboardHandleKeymap,
+ KeyboardHandleEnter,
+ KeyboardHandleLeave,
+ KeyboardHandleKey,
+ KeyboardHandleModifiers,
+};
+
+const struct wl_touch_listener TouchListener = {
+ TouchHandleDown,
+ TouchHandleUp,
+ TouchHandleMotion,
+ TouchHandleFrame,
+ TouchHandleCancel,
+};
+
void WaitForEvent(struct wl_display* wlDisplay)
{
wl_display_iterate(wlDisplay, WL_DISPLAY_READABLE);
//////////////////////////////////////////////////////////////////////////////
+void
+TouchHandleDown(void* data, struct wl_touch* touch, uint32_t serial, uint32_t time,
+ struct wl_surface* surface, int32_t id, wl_fixed_t xw, wl_fixed_t yw)
+{
+ WL_UNUSED(data);
+ WL_UNUSED(touch);
+ WL_UNUSED(serial);
+ WL_UNUSED(time);
+ WL_UNUSED(surface);
+ WL_UNUSED(id);
+ WL_UNUSED(xw);
+ WL_UNUSED(yw);
+ printf("ENTER TouchHandleDown\n");
+}
+
+void
+TouchHandleUp(void* data, struct wl_touch* touch, uint32_t serial, uint32_t time, int32_t id)
+{
+ WL_UNUSED(data);
+ WL_UNUSED(touch);
+ WL_UNUSED(serial);
+ WL_UNUSED(time);
+ WL_UNUSED(id);
+ printf("ENTER TouchHandleUp\n");
+}
+
+void
+TouchHandleMotion(void* data, struct wl_touch* touch, uint32_t time, int32_t id,
+ wl_fixed_t xw, wl_fixed_t yw)
+{
+ WL_UNUSED(data);
+ WL_UNUSED(touch);
+ WL_UNUSED(time);
+ WL_UNUSED(id);
+ WL_UNUSED(xw);
+ WL_UNUSED(yw);
+ printf("ENTER TouchHandleMotion\n");
+}
+
+void
+TouchHandleFrame(void* data, struct wl_touch* touch)
+{
+ WL_UNUSED(data);
+ WL_UNUSED(touch);
+}
+
+void
+TouchHandleCancel(void* data, struct wl_touch* touch)
+{
+ WL_UNUSED(data);
+ WL_UNUSED(touch);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
typedef struct _es2shaderobject {
GLuint fragmentShaderId;
GLuint vertexShaderId;
0.0, b, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
-1.0, -1.0, 0.0, 1.0};
+
glUniformMatrix4fv(gShaderObject.matrixLocation, 1, GL_FALSE, mtx);
eyes->SetPointOfView(gPointerX, gPointerY);
int nPoint = 0;
float* points = NULL;
for (int ii = 0; ii < 2; ++ii){
+ // eye liner
eyes->GetEyeLinerGeom(ii, &nPoint, &points);
if (nPoint <= 0 || points == NULL){
continue;
}
- DrawFillPoly(nPoint, points, white); // eye shape
- DrawPoly((nPoint - 1), &points[2], black, 20); // eye liner
+ DrawFillPoly(nPoint, points, black);
+
+ // eye shape (white eye)
+ eyes->GetWhiteEyeGeom(ii, &nPoint, &points);
+ if (nPoint <= 0 || points == NULL){
+ continue;
+ }
+ DrawFillPoly(nPoint, points, white);
+ // pupil
eyes->GetPupilGeom(ii, &nPoint, &points);
if (nPoint <= 0 || points == NULL){
continue;
}
- DrawFillPoly(nPoint, points, black); // pupil
+ DrawFillPoly(nPoint, points, black);
}
}
DetachVertexBuffer();
rtnv = ilm_layerAddSurface(*layerId, *surfaceId);
rtnv = ilm_UpdateInputEventAcceptanceOn(*surfaceId,
- INPUT_DEVICE_POINTER,
+ INPUT_DEVICE_POINTER | INPUT_DEVICE_TOUCH,
ILM_TRUE);
rtnv = ilm_SetKeyboardFocusOn(*surfaceId);