Back to index

unity  6.0.0
GeisAdapter.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * aint with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Jason Smith <jason.smith@canonical.com>
00018  */
00019 
00020 #ifndef GEISADAPTER_H
00021 #define GEISADAPTER_H
00022 
00023 /* Compiz */
00024 #include <sigc++/sigc++.h>
00025 #include <geis/geis.h>
00026 #include <Nux/Nux.h>
00027 
00028 class GeisAdapter : public sigc::trackable
00029 {
00030 public:
00031   static GeisAdapter& Instance();
00032 
00033   GeisAdapter();
00034   ~GeisAdapter();
00035 
00036   void Run();
00037 
00038   typedef struct _GeisTapData
00039   {
00040     int id;
00041     int device_id;
00042     Window window;
00043     int touches;
00044     int timestamp;
00045     float focus_x;
00046     float focus_y;
00047     int tap_length_ms;
00048     float position_x;
00049     float position_y;
00050     float bound_x1;
00051     float bound_y1;
00052     float bound_x2;
00053     float bound_y2;
00054   } GeisTapData;
00055 
00056   typedef struct _GeisDragData
00057   {
00058     int id;
00059     int device_id;
00060     Window window;
00061     int touches;
00062     int timestamp;
00063     float focus_x;
00064     float focus_y;
00065     float delta_x;
00066     float delta_y;
00067     float velocity_x;
00068     float velocity_y;
00069     float position_x;
00070     float position_y;
00071     float bound_x1;
00072     float bound_y1;
00073     float bound_x2;
00074     float bound_y2;
00075   } GeisDragData;
00076 
00077   typedef struct _GeisRotateData
00078   {
00079     int id;
00080     int device_id;
00081     Window window;
00082     int touches;
00083     int timestamp;
00084     float focus_x;
00085     float focus_y;
00086     float angle;
00087     float angle_delta;
00088     float angle_velocity;
00089     float bound_x1;
00090     float bound_y1;
00091     float bound_x2;
00092     float bound_y2;
00093   } GeisRotateData;
00094 
00095   typedef struct _GeisPinchData
00096   {
00097     int id;
00098     int device_id;
00099     Window window;
00100     int touches;
00101     int timestamp;
00102     float focus_x;
00103     float focus_y;
00104     float radius;
00105     float radius_delta;
00106     float radius_velocity;
00107     float bound_x1;
00108     float bound_y1;
00109     float bound_x2;
00110     float bound_y2;
00111   } GeisPinchData;
00112 
00113   typedef struct _GeisTouchData
00114   {
00115     int id;
00116     int device_id;
00117     Window window;
00118     int touches;
00119     int timestamp;
00120     float focus_x;
00121     float focus_y;
00122     float bound_x1;
00123     float bound_y1;
00124     float bound_x2;
00125     float bound_y2;
00126   } GeisTouchData;
00127 
00128   sigc::signal<void, GeisTapData*> tap;
00129 
00130   sigc::signal<void, GeisDragData*> drag_start;
00131   sigc::signal<void, GeisDragData*> drag_update;
00132   sigc::signal<void, GeisDragData*> drag_finish;
00133 
00134   sigc::signal<void, GeisRotateData*> rotate_start;
00135   sigc::signal<void, GeisRotateData*> rotate_update;
00136   sigc::signal<void, GeisRotateData*> rotate_finish;
00137 
00138   sigc::signal<void, GeisPinchData*> pinch_start;
00139   sigc::signal<void, GeisPinchData*> pinch_update;
00140   sigc::signal<void, GeisPinchData*> pinch_finish;
00141 
00142   sigc::signal<void, GeisTouchData*> touch_start;
00143   sigc::signal<void, GeisTouchData*> touch_update;
00144   sigc::signal<void, GeisTouchData*> touch_finish;
00145 protected:
00146   static gboolean OnWatchIn(GIOChannel* source, GIOCondition condition, gpointer data);
00147 
00148   static void InputDeviceAdded(void* cookie, GeisInputDeviceId device_id, void* attrs);
00149   static void InputDeviceChanged(void* cookie, GeisInputDeviceId device_id, void* attrs);
00150   static void InputDeviceRemoved(void* cookie, GeisInputDeviceId device_id, void* attrs);
00151 
00152   static void GestureAdded(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize attr_count, GeisGestureAttr* attrs);
00153   static void GestureRemoved(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize attr_count, GeisGestureAttr* attrs);
00154 
00155   static void GestureStart(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize attr_count, GeisGestureAttr* attrs);
00156   static void GestureUpdate(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize attr_count, GeisGestureAttr* attrs);
00157   static void GestureFinish(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize attr_count, GeisGestureAttr* attrs);
00158 
00159   GeisTapData*     ProcessTapGesture(GeisSize attr_count, GeisGestureAttr* attrs);
00160   GeisDragData*    ProcessDragGesture(GeisSize attr_count, GeisGestureAttr* attrs);
00161   GeisPinchData*   ProcessPinchGesture(GeisSize attr_count, GeisGestureAttr* attrs);
00162   GeisRotateData* ProcessRotateGesture(GeisSize attr_count, GeisGestureAttr* attrs);
00163   GeisTouchData*   ProcessTouchGesture(GeisSize attr_count, GeisGestureAttr* attrs);
00164 
00165 private:
00166   void RegisterRootInstance();
00167 
00168   GeisInstance _root_instance;
00169   guint _watch_id;
00170 };
00171 
00172 #endif