1 #include "Multitouch.h"
5 #define allocate(x) ((x*)malloc(sizeof(x)))
7 void queueDrawEvent(int type
, int cursor_id
, int x
, int y
);
8 void queueDraggingEvent(int type
, int cursor_id
, int x
, int y
);
10 void queueStartStrokeEvent(int cursor_id
, int x
, int y
)
12 queueDrawEvent(SDL_NP_START_STROKE
, cursor_id
, x
, y
);
15 void queueAppendStrokeEvent(int cursor_id
, int x
, int y
)
17 queueDrawEvent(SDL_NP_APPEND_STROKE
, cursor_id
, x
, y
);
20 void queueFinishStrokeEvent(int cursor_id
, int x
, int y
)
22 queueDrawEvent(SDL_NP_FINISH_STROKE
, cursor_id
, x
, y
);
25 void queueStartRopeEvent(int cursor_id
, int x
, int y
)
27 queueDrawEvent(SDL_NP_START_ROPE
, cursor_id
, x
, y
);
30 void queueAppendRopeEvent(int cursor_id
, int x
, int y
)
32 queueDrawEvent(SDL_NP_APPEND_ROPE
, cursor_id
, x
, y
);
35 void queueFinishRopeEvent(int cursor_id
, int x
, int y
)
37 queueDrawEvent(SDL_NP_FINISH_ROPE
, cursor_id
, x
, y
);
40 void queueDrawEvent(int type
, int cursor_id
, int x
, int y
)
42 DrawEvent
* de
= allocate(DrawEvent
);
43 de
->cursor_id
= cursor_id
;
47 queueUserEvent(type
, de
, 0);
50 void queueStartDragEvent(int cursor_id
, int x
, int y
)
52 queueDraggingEvent(SDL_NP_START_DRAG
, cursor_id
, x
, y
);
55 void queueDragEvent(int cursor_id
, int x
, int y
)
57 queueDraggingEvent(SDL_NP_DRAG
, cursor_id
, x
, y
);
60 void queueEndDragEvent(int cursor_id
, int x
, int y
)
62 queueDraggingEvent(SDL_NP_END_DRAG
, cursor_id
, x
, y
);
65 void queueDraggingEvent(int type
, int cursor_id
, int x
, int y
)
67 DragEvent
* de
= allocate(DragEvent
);
68 de
->cursor_id
= cursor_id
;
72 queueUserEvent(type
, de
, 0);
75 void queuePanEvent(int xdiff
, int ydiff
)
77 PanEvent
* pe
= allocate(PanEvent
);
81 queueUserEvent(SDL_NP_PAN
, pe
, 0);
84 void queueZoomEvent(int x
, int y
, float zoomfactor
)
86 ZoomEvent
* ze
= allocate(ZoomEvent
);
89 ze
->zoomfactor
= zoomfactor
;
91 queueUserEvent(SDL_NP_ZOOM
, ze
, 0);
94 void queueDeleteEvent(int x
, int y
)
96 DeleteEvent
* de
= allocate(DeleteEvent
);
100 queueUserEvent(SDL_NP_DELETE
, de
, 0);
103 void queueUserEvent(int type
, void *data1
, void *data2
)
107 event
.user
.data1
= data1
;
108 event
.user
.data2
= data2
;
110 fprintf(stderr
, "Posting event: %d (%p, %p)\n", type
, data1
, data2
);
112 if (SDL_PushEvent(&event
) != 0)
114 fprintf(stderr
, "could not push SDL event onto queue");