4 * Copyright (C) 2004-2011 Simon Wunderlich <dotslash@packetmixer.de>
6 * This file is part of s3d, a 3d network display server.
7 * See http://s3d.berlios.de/ for more updates.
9 * s3d is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * s3d is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with s3d; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 /* this file reads user input */
27 /* this is done right now by SDL-polling */
29 int user_init_sdl(void)
35 int user_main_sdl(void)
38 while (SDL_PollEvent(&event
)) {
41 /* s3dprintf(VLOW,"Current mouse position is: (%d, %d),button %d", event.motion.x, event.motion.y,event.button.button); */
42 switch (event
.button
.button
) {
44 user_mouse(0, 2, event
.motion
.x
, event
.motion
.y
);
46 case SDL_BUTTON_MIDDLE
:
47 user_mouse(1, 2, event
.motion
.x
, event
.motion
.y
);
49 case SDL_BUTTON_RIGHT
:
50 case SDL_BUTTON_RMASK
:
51 user_mouse(2, 2, event
.motion
.x
, event
.motion
.y
);
54 user_mouse(-1, -1, event
.motion
.x
, event
.motion
.y
);
58 s3dprintf(LOW
, "don't know button %d", event
.button
.button
);
62 case SDL_MOUSEBUTTONDOWN
:
63 switch (event
.button
.button
) {
65 user_mouse(0, 0, event
.motion
.x
, event
.motion
.y
);
67 case SDL_BUTTON_MIDDLE
:
68 user_mouse(1, 0, event
.motion
.x
, event
.motion
.y
);
70 case SDL_BUTTON_RIGHT
:
71 user_mouse(2, 0, event
.motion
.x
, event
.motion
.y
);
73 case SDL_BUTTON_WHEELUP
:
74 user_mouse(3, 0, event
.motion
.x
, event
.motion
.y
);
76 case SDL_BUTTON_WHEELDOWN
:
77 user_mouse(4, 0, event
.motion
.x
, event
.motion
.y
);
80 s3dprintf(LOW
, "don't know button %d", event
.button
.button
);
83 case SDL_MOUSEBUTTONUP
:
84 switch (event
.button
.button
) {
86 user_mouse(0, 1, event
.motion
.x
, event
.motion
.y
);
88 case SDL_BUTTON_MIDDLE
:
89 user_mouse(1, 1, event
.motion
.x
, event
.motion
.y
);
91 case SDL_BUTTON_RIGHT
:
92 user_mouse(2, 1, event
.motion
.x
, event
.motion
.y
);
94 case SDL_BUTTON_WHEELUP
:
95 user_mouse(3, 1, event
.motion
.x
, event
.motion
.y
);
97 case SDL_BUTTON_WHEELDOWN
:
98 user_mouse(4, 1, event
.motion
.x
, event
.motion
.y
);
101 s3dprintf(LOW
, "don't know button %d", event
.button
.button
);
106 user_key(event
.key
.keysym
.sym
, event
.key
.keysym
.unicode
, event
.key
.keysym
.mod
, 0);
109 user_key(event
.key
.keysym
.sym
, event
.key
.keysym
.unicode
, event
.key
.keysym
.mod
, 1);
112 s3dprintf(HIGH
, "SDL_QUIT");
115 /* these events are not processed right now ... */
116 case SDL_ACTIVEEVENT
:
117 s3dprintf(VLOW
, "SDL_ACTIVEEVENT");
120 s3dprintf(VLOW
, "SDL_SYSWMEVENT");
122 case SDL_VIDEORESIZE
:
123 if (SDL_SetVideoMode(event
.resize
.w
, event
.resize
.h
, 16, SDLFlags
) == NULL
)
124 errsf("SDL_SetVideoMode()", SDL_GetError());
125 graphics_reshape(event
.resize
.w
, event
.resize
.h
);
127 case SDL_VIDEOEXPOSE
:
128 s3dprintf(VLOW
, "SDL_VIDEOEXPOSE");
131 s3dprintf(VLOW
, "SDL_USEREVENT");
133 case SDL_JOYAXISMOTION
:
134 s3dprintf(VLOW
, "SDL_JOYAXISMOTION");
136 case SDL_JOYBALLMOTION
:
137 s3dprintf(VLOW
, "SDL_JOYBALLMOTION");
139 case SDL_JOYHATMOTION
:
140 s3dprintf(VLOW
, "SDL_JOYHATMOTION");
142 case SDL_JOYBUTTONDOWN
:
143 s3dprintf(VLOW
, "SDL_JOYBUTTONDOWN");
145 case SDL_JOYBUTTONUP
:
146 s3dprintf(VLOW
, "SDL_JOYBUTTONUP");
149 s3dprintf(MED
, "SDL_PollEvent(): unhandled event");
157 int user_quit_sdl(void)