Changeset 2624
- Timestamp:
- 08/03/07 16:42:50 (6 years ago)
- Location:
- trunk/src/target/OM-2007.2
- Files:
-
- 15 added
- 3 edited
-
applications/fingerscroll/example.c (modified) (1 diff)
-
applications/fingerscroll/moko-finger-scroll.c (modified) (11 diffs)
-
applications/fingerscroll/moko-finger-scroll.h (modified) (1 diff)
-
daemons (added)
-
daemons/neod (added)
-
daemons/neod/AUTHORS (added)
-
daemons/neod/COPYING (added)
-
daemons/neod/ChangeLog (added)
-
daemons/neod/Makefile.am (added)
-
daemons/neod/NEWS (added)
-
daemons/neod/README (added)
-
daemons/neod/autogen.sh (added)
-
daemons/neod/configure.ac (added)
-
daemons/neod/po (added)
-
daemons/neod/po/POTFILES.in (added)
-
daemons/neod/src (added)
-
daemons/neod/src/Makefile.am (added)
-
daemons/neod/src/neod-main.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007.2/applications/fingerscroll/example.c
r2483 r2624 114 114 115 115 w = scroll = moko_finger_scroll_new (); 116 g_object_set( G_OBJECT(scroll), "mode", MOKO_FINGER_SCROLL_MODE_PHYSICAL, NULL ); 116 117 gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); 117 118 -
trunk/src/target/OM-2007.2/applications/fingerscroll/moko-finger-scroll.c
r2499 r2624 1 1 2 #include <glib.h> 2 3 #include "moko-finger-scroll.h" 3 4 … … 6 7 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOKO_TYPE_FINGER_SCROLL, MokoFingerScrollPrivate)) 7 8 typedef struct _MokoFingerScrollPrivate MokoFingerScrollPrivate; 9 10 typedef struct _point point; 11 struct _point 12 { 13 gdouble x; 14 gdouble y; 15 gint32 time; 16 }; 8 17 9 18 struct _MokoFingerScrollPrivate { … … 13 22 gdouble ex; 14 23 gdouble ey; 24 point prev_values[3]; 15 25 gboolean enabled; 16 26 gboolean clicked; … … 23 33 gdouble vel_x; 24 34 gdouble vel_y; 25 35 ; 36 26 37 GtkWidget *align; 27 38 gboolean hscroll; … … 38 49 }; 39 50 51 #define PHYSICAL_MOVE_PERIOD 300 52 53 static gint32 54 time_diff (gint32 t1, gint32 t2) 55 { 56 if (t2 > t1) 57 return t2-t1; 58 else 59 return ((gint64)t2 + 1<<32) - (gint64)t1; 60 } 61 62 static void 63 rough_linear (point p0, point p1, point p2, gdouble *xm, gdouble *ym) 64 { 65 /* just calulate two slopes and avarage */ 66 *xm = (((p0.x-p1.x) / time_diff(p1.time,p0.time)) 67 + ((p0.x-p1.x) / time_diff(p2.time,p0.time))) / 2; 68 *ym = (((p0.y-p1.y) / time_diff(p1.time,p0.time)) 69 + ((p0.y-p2.y) / time_diff(p2.time,p0.time))) / 2; 70 } 71 40 72 static gboolean 41 73 moko_finger_scroll_button_press_cb (MokoFingerScroll *scroll, … … 51 83 priv->x = event->x; 52 84 priv->y = event->y; 85 priv->ex = event->x; 86 priv->ey = event->y; 53 87 priv->moved = FALSE; 54 88 priv->clicked = TRUE; … … 56 90 priv->vel_x = 0; 57 91 priv->vel_y = 0; 58 92 93 priv->prev_values[0].x = event->x; 94 priv->prev_values[0].y = event->y; 95 priv->prev_values[0].time = event->time; 96 priv->prev_values[1].x = event->x; 97 priv->prev_values[1].y = event->y; 98 priv->prev_values[1].time = event->time; 59 99 return TRUE; 60 100 } … … 112 152 MokoFingerScrollPrivate *priv = FINGER_SCROLL_PRIVATE (scroll); 113 153 154 g_debug ("vel_x=%f, vel_y=%fr",priv->vel_x,priv->vel_y); 155 114 156 if ((!priv->enabled) || 115 (priv->mode != MOKO_FINGER_SCROLL_MODE_ACCEL)) return FALSE;157 (priv->mode == MOKO_FINGER_SCROLL_MODE_PUSH)) return FALSE; 116 158 if (!priv->clicked) { 117 159 /* Decelerate gradually when pointer is raised */ … … 187 229 (priv->vmax-priv->vmin)) + priv->vmin); 188 230 break; 231 case MOKO_FINGER_SCROLL_MODE_PHYSICAL: 232 /* Scroll by the amount of pixels the cursor has moved 233 * since the last motion event. 234 */ 235 moko_finger_scroll_scroll (scroll, x, y, NULL, NULL); 236 priv->prev_values[1].x = priv->prev_values[0].x; 237 priv->prev_values[1].y = priv->prev_values[0].y; 238 priv->prev_values[1].time = priv->prev_values[0].time; 239 priv->prev_values[0].x = event->x; 240 priv->prev_values[0].y = event->y; 241 priv->prev_values[0].time = event->time; 242 priv->x = event->x; 243 priv->y = event->y; 244 245 break; 246 189 247 default : 190 248 break; … … 273 331 ((GdkEvent *)event)->type = GDK_BUTTON_RELEASE; 274 332 gdk_event_put ((GdkEvent *)event); 333 } 334 if (priv->moved && priv->mode == MOKO_FINGER_SCROLL_MODE_PHYSICAL) { 335 point p0; 336 gdouble velx, vely; 337 p0.x = event->x; 338 p0.y = event->y; 339 p0.time = event->time; 340 g_debug ("doing physical"); 341 /*velx and vely are in pixels/ms..*/ 342 rough_linear (p0, priv->prev_values[0], priv->prev_values[1], &velx, &vely); 343 344 priv->vel_x = (velx * 1000.0) / priv->sps; 345 priv->vel_y = (vely * 1000.0) / priv->sps; 346 g_timeout_add ((gint)(1000.0/(gdouble)priv->sps), 347 (GSourceFunc)moko_finger_scroll_timeout, 348 scroll); 275 349 } 276 350 … … 514 588 "Change the finger-scrolling mode.", 515 589 MOKO_FINGER_SCROLL_MODE_PUSH, 516 MOKO_FINGER_SCROLL_MODE_ ACCEL,517 MOKO_FINGER_SCROLL_MODE_ ACCEL,590 MOKO_FINGER_SCROLL_MODE_PHYSICAL, 591 MOKO_FINGER_SCROLL_MODE_PHYSICAL, 518 592 G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); 519 593 -
trunk/src/target/OM-2007.2/applications/fingerscroll/moko-finger-scroll.h
r2499 r2624 40 40 MOKO_FINGER_SCROLL_MODE_PUSH, 41 41 MOKO_FINGER_SCROLL_MODE_ACCEL, 42 MOKO_FINGER_SCROLL_MODE_PHYSICAL, 42 43 } MokoFingerScrollMode; 43 44
Note: See TracChangeset
for help on using the changeset viewer.
