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 queueCancelDrawEvent(int cursor_id
)
27 queueCursorEvent(SDL_NP_CANCEL_DRAW
, cursor_id
);
30 void queuePreviewCursorEvent(int cursor_id
, int x
, int y
)
32 queueDrawEvent(SDL_NP_PREVIEW_CURSOR
, cursor_id
, x
, y
);
35 void queueStartRopeEvent(int cursor_id
, int x
, int y
)
37 queueDrawEvent(SDL_NP_START_ROPE
, cursor_id
, x
, y
);
40 void queueAppendRopeEvent(int cursor_id
, int x
, int y
)
42 queueDrawEvent(SDL_NP_APPEND_ROPE
, cursor_id
, x
, y
);
45 void queueFinishRopeEvent(int cursor_id
, int x
, int y
)
47 queueDrawEvent(SDL_NP_FINISH_ROPE
, cursor_id
, x
, y
);
50 void queueCursorEvent(int type
, int cursor_id
)
52 CursorEvent
* ce
= allocate(CursorEvent
);
53 ce
->cursor_id
= cursor_id
;
55 queueUserEvent(type
, ce
, 0);
58 void queueDrawEvent(int type
, int cursor_id
, int x
, int y
)
60 DrawEvent
* de
= allocate(DrawEvent
);
61 de
->cursor_id
= cursor_id
;
65 queueUserEvent(type
, de
, 0);
68 void queueStartDragEvent(int cursor_id
, int x
, int y
)
70 queueDraggingEvent(SDL_NP_START_DRAG
, cursor_id
, x
, y
);
73 void queueDragEvent(int cursor_id
, int x
, int y
)
75 queueDraggingEvent(SDL_NP_DRAG
, cursor_id
, x
, y
);
78 void queueEndDragEvent(int cursor_id
, int x
, int y
)
80 queueDraggingEvent(SDL_NP_END_DRAG
, cursor_id
, x
, y
);
83 void queueDraggingEvent(int type
, int cursor_id
, int x
, int y
)
85 DragEvent
* de
= allocate(DragEvent
);
86 de
->cursor_id
= cursor_id
;
90 queueUserEvent(type
, de
, 0);
93 void queuePanEvent(int xdiff
, int ydiff
)
95 PanEvent
* pe
= allocate(PanEvent
);
99 queueUserEvent(SDL_NP_PAN
, pe
, 0);
102 void queueZoomEvent(int x
, int y
, float zoomfactor
)
104 ZoomEvent
* ze
= allocate(ZoomEvent
);
107 ze
->zoomfactor
= zoomfactor
;
109 queueUserEvent(SDL_NP_ZOOM
, ze
, 0);
112 void queueDeleteEvent(int x
, int y
)
114 DeleteEvent
* de
= allocate(DeleteEvent
);
118 queueUserEvent(SDL_NP_DELETE
, de
, 0);
121 void queueRestartLevelEvent()
123 queueUserEvent(SDL_NP_RESTART_LEVEL
, 0, 0);
126 void queueNextLevelEvent()
128 queueUserEvent(SDL_NP_NEXT_LEVEL
, 0, 0);
131 void queuePreviousLevelEvent()
133 queueUserEvent(SDL_NP_PREV_LEVEL
, 0, 0);
136 void queueToggleMenuEvent()
138 queueUserEvent(SDL_NP_TOGGLE_MENU
, 0, 0);
141 void queueShowMenuEvent()
143 queueUserEvent(SDL_NP_SHOW_MENU
, 0, 0);
146 void queueHideMenuEvent()
148 queueUserEvent(SDL_NP_HIDE_MENU
, 0, 0);
151 void queueTogglePauseEvent()
154 queueUserEvent(SDL_NP_TOGGLE_PAUSE
, 0, 0);
157 void queuePauseEvent()
159 queueUserEvent(SDL_NP_PAUSE
, 0, 0);
162 void queueResumeEvent()
164 queueUserEvent(SDL_NP_RESUME
, 0, 0);
167 void queueSaveEvent()
169 queueUserEvent(SDL_NP_SAVE
, 0, 0);
172 void queueToggleEditorEvent()
174 queueUserEvent(SDL_NP_TOGGLE_EDITOR
, 0, 0);
177 void queueReplayEvent()
179 queueUserEvent(SDL_NP_REPLAY
, 0, 0);
182 void queueUserEvent(int type
, void *data1
, void *data2
)
186 event
.user
.data1
= data1
;
187 event
.user
.data2
= data2
;
189 fprintf(stderr
, "Posting event: %d (%p, %p)\n", type
, data1
, data2
);
191 if (SDL_PushEvent(&event
) != 0)
193 fprintf(stderr
, "could not push SDL event onto queue");