Release s3d 0.2.2
[s3d.git] / server / user.c
blob833122207c55e61151c9228a9fe308df5f4251c8
1 /*
2 * user.c
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
24 #include "global.h"
25 /* this file reads user input */
26 static int ox, oy;
27 int but = -1;
29 int user_init(void)
31 switch (frame_mode) {
32 #ifdef G_SDL
33 case FRAME_SDL:
34 user_init_sdl();
35 break;
36 #endif
37 default:
38 return -1;
40 ox = oy = 0xFFFFFF;
41 return 0;
44 int user_main(void)
46 switch (frame_mode) {
47 #ifdef G_SDL
48 case FRAME_SDL:
49 user_main_sdl();
50 #endif
51 default:
52 return 0;
56 void user_key(uint16_t key, uint16_t unicode, uint16_t mod, int state)
58 event_key_pressed(key, unicode, mod, state);
61 void user_mouse(int button, int state, int x, int y)
63 switch (state) {
64 case 0: /* mouse_down ... */
65 switch (button) {
66 case 0:
67 graphics_pick_obj(x, y);
68 break;
69 case 1:
70 if ((ox != 0xFFFFFF) && (oy != 0xFFFFFF))
71 navi_pos(ox - x, oy - y);
72 break;
73 case 2:
74 if ((ox != 0xFFFFFF) && (oy != 0xFFFFFF))
75 navi_rot(ox - x, oy - y);
76 break;
77 case 3:
78 navi_fwd();
79 break;
80 case 4:
81 navi_back();
82 break;
83 default:
84 s3dprintf(VLOW, "button is ... %d", button);
86 ox = x;
87 oy = y;
88 event_mbutton_clicked(button, state);
89 break;
90 case 1: /* mouse up */
91 ox = oy = 0xFFFFFF;
92 event_mbutton_clicked(button, state);
93 /* s3dprintf(LOW,"state is: %d,button is %d",state,button); */
94 break;
95 case 2: /* mouse still down */
96 switch (button) {
97 case 1:
98 if ((ox != 0xFFFFFF) && (oy != 0xFFFFFF))
99 navi_pos(ox - x, oy - y);
100 break;
101 case 2:
102 if ((ox != 0xFFFFFF) && (oy != 0xFFFFFF))
103 navi_rot(ox - x, oy - y);
104 break;
105 case 3:
106 navi_fwd();
107 break;
108 case 4:
109 navi_back();
110 break;
111 default:
112 s3dprintf(VLOW, "button is ... %d", button);
114 ox = x;
115 oy = y;
116 break;
118 but = button;
119 /* mouse changed? */
120 ptr_move(x, y);
123 int user_quit(void)
125 return 0;