removed support for GL_SGIS_multitexture (ancient)
[divverent/darkplaces.git] / vid_glx.c
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 */
19
20 #include <termios.h>
21 #include <sys/ioctl.h>
22 #include <sys/stat.h>
23 #include <sys/vt.h>
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <signal.h>
27
28 #include <dlfcn.h>
29
30 #include "quakedef.h"
31
32 #include <GL/glx.h>
33
34 #include <X11/keysym.h>
35 #include <X11/cursorfont.h>
36
37 #include <X11/extensions/XShm.h>
38 #include <X11/extensions/xf86dga.h>
39 #include <X11/extensions/xf86vmode.h>
40
41 static Display *dpy = NULL;
42 static int scrnum;
43 static Window win;
44 static GLXContext ctx = NULL;
45
46 #define KEY_MASK (KeyPressMask | KeyReleaseMask)
47 #define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | \
48                     PointerMotionMask | ButtonMotionMask )
49 #define X_MASK (KEY_MASK | MOUSE_MASK | VisibilityChangeMask | StructureNotifyMask )
50
51
52 viddef_t        vid;                            // global video state
53
54 static qboolean         mouse_avail = true;
55 static qboolean         mouse_active = false, usingmouse = false;
56 // static qboolean              dga_active;
57 static float    mouse_x, mouse_y;
58 static float    old_mouse_x, old_mouse_y;
59 static int p_mouse_x, p_mouse_y;
60
61 cvar_t vid_dga = {CVAR_SAVE, "vid_dga", "1"};
62 cvar_t vid_dga_mouseaccel = {0, "vid_dga_mouseaccel", "1"};
63 cvar_t m_filter = {0, "m_filter", "0"};
64
65 qboolean vidmode_ext = false;
66
67 static int win_x, win_y;
68
69 static int scr_width, scr_height;
70
71 static XF86VidModeModeInfo **vidmodes;
72 //static int default_dotclock_vidmode;
73 static int num_vidmodes;
74 static qboolean vidmode_active = false;
75
76 /*-----------------------------------------------------------------------*/
77
78 float           gldepthmin, gldepthmax;
79
80 const char *gl_vendor;
81 const char *gl_renderer;
82 const char *gl_version;
83 const char *gl_extensions;
84
85 /*-----------------------------------------------------------------------*/
86 static int
87 XLateKey(XKeyEvent *ev/*, qboolean modified*/)
88 {
89 //      char tmp[2];
90         int key = 0;
91         KeySym keysym;
92
93         keysym = XLookupKeysym(ev, 0);
94
95         switch(keysym)
96         {
97                 case XK_KP_Page_Up:     key = KP_PGUP; break;
98                 case XK_Page_Up:        key = K_PGUP; break;
99
100                 case XK_KP_Page_Down:   key = KP_PGDN; break;
101                 case XK_Page_Down:      key = K_PGDN; break;
102
103                 case XK_KP_Home:        key = KP_HOME; break;
104                 case XK_Home:           key = K_HOME; break;
105
106                 case XK_KP_End:         key = KP_END; break;
107                 case XK_End:            key = K_END; break;
108
109                 case XK_KP_Left:        key = KP_LEFTARROW; break;
110                 case XK_Left:           key = K_LEFTARROW; break;
111
112                 case XK_KP_Right:       key = KP_RIGHTARROW; break;
113                 case XK_Right:          key = K_RIGHTARROW; break;
114
115                 case XK_KP_Down:        key = KP_DOWNARROW; break;
116                 case XK_Down:           key = K_DOWNARROW; break;
117
118                 case XK_KP_Up:          key = KP_UPARROW; break;
119                 case XK_Up:                     key = K_UPARROW; break;
120
121                 case XK_Escape:         key = K_ESCAPE; break;
122
123                 case XK_KP_Enter:       key = KP_ENTER; break;
124                 case XK_Return:         key = K_ENTER; break;
125
126                 case XK_Tab:            key = K_TAB; break;
127
128                 case XK_F1:                     key = K_F1; break;
129                 case XK_F2:                     key = K_F2; break;
130                 case XK_F3:                     key = K_F3; break;
131                 case XK_F4:                     key = K_F4; break;
132                 case XK_F5:                     key = K_F5; break;
133                 case XK_F6:                     key = K_F6; break;
134                 case XK_F7:                     key = K_F7; break;
135                 case XK_F8:                     key = K_F8; break;
136                 case XK_F9:                     key = K_F9; break;
137                 case XK_F10:            key = K_F10; break;
138                 case XK_F11:            key = K_F11; break;
139                 case XK_F12:            key = K_F12; break;
140
141                 case XK_BackSpace:      key = K_BACKSPACE; break;
142
143                 case XK_KP_Delete:      key = KP_DEL; break;
144                 case XK_Delete:         key = K_DEL; break;
145
146                 case XK_Pause:          key = K_PAUSE; break;
147
148                 case XK_Shift_L:
149                 case XK_Shift_R:        key = K_SHIFT; break;
150
151                 case XK_Execute:
152                 case XK_Control_L:
153                 case XK_Control_R:      key = K_CTRL; break;
154
155                 case XK_Mode_switch:
156                 case XK_Alt_L:
157                 case XK_Meta_L:
158                 case XK_Alt_R:
159                 case XK_Meta_R:         key = K_ALT; break;
160
161                 case XK_Caps_Lock:      key = K_CAPSLOCK; break;
162                 case XK_KP_Begin:       key = KP_5; break;
163
164                 case XK_Insert:         key = K_INS; break;
165                 case XK_KP_Insert:      key = KP_INS; break;
166
167                 case XK_KP_Multiply:    key = KP_MULTIPLY; break;
168                 case XK_KP_Add:         key = KP_PLUS; break;
169                 case XK_KP_Subtract:    key = KP_MINUS; break;
170                 case XK_KP_Divide:      key = KP_DIVIDE; break;
171
172                 /* For Sun keyboards */
173                 case XK_F27:            key = K_HOME; break;
174                 case XK_F29:            key = K_PGUP; break;
175                 case XK_F33:            key = K_END; break;
176                 case XK_F35:            key = K_PGDN; break;
177
178                 default:
179                         if (keysym < 128)
180                         {
181                                 /* ASCII keys */
182                                 key = keysym;
183                                 if (/*!modified && */((key >= 'A') && (key <= 'Z')))
184                                         key = key + ('a' - 'A');
185                         }
186                         break;
187         }
188
189         return key;
190 }
191
192 static Cursor CreateNullCursor(Display *display, Window root)
193 {
194         Pixmap cursormask;
195         XGCValues xgc;
196         GC gc;
197         XColor dummycolour;
198         Cursor cursor;
199
200         cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);
201         xgc.function = GXclear;
202         gc =  XCreateGC(display, cursormask, GCFunction, &xgc);
203         XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
204         dummycolour.pixel = 0;
205         dummycolour.red = 0;
206         dummycolour.flags = 04;
207         cursor = XCreatePixmapCursor(display, cursormask, cursormask, &dummycolour,&dummycolour, 0,0);
208         XFreePixmap(display,cursormask);
209         XFreeGC(display,gc);
210         return cursor;
211 }
212
213 static void install_grabs(void)
214 {
215         XWindowAttributes attribs_1;
216         XSetWindowAttributes attribs_2;
217
218         XGetWindowAttributes(dpy, win, &attribs_1);
219         attribs_2.event_mask = attribs_1.your_event_mask | KEY_MASK | MOUSE_MASK;
220         XChangeWindowAttributes(dpy, win, CWEventMask, &attribs_2);
221
222 // inviso cursor
223         XDefineCursor(dpy, win, CreateNullCursor(dpy, win));
224
225         XGrabPointer(dpy, win,  True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
226
227         if (vid_dga.value)
228         {
229                 int MajorVersion, MinorVersion;
230
231                 if (!XF86DGAQueryVersion(dpy, &MajorVersion, &MinorVersion))
232                 {
233                         // unable to query, probalby not supported
234                         Con_Printf( "Failed to detect XF86DGA Mouse\n" );
235                         vid_dga.value = 0;
236                 }
237                 else
238                 {
239                         vid_dga.value = 1;
240                         XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
241                         XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
242                 }
243         }
244         else
245                 XWarpPointer(dpy, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);
246
247         XGrabKeyboard(dpy, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
248
249         mouse_active = true;
250         mouse_x = mouse_y = 0;
251
252 //      XSync(dpy, True);
253 }
254
255 static void uninstall_grabs(void)
256 {
257         if (!dpy || !win)
258                 return;
259
260         if (vid_dga.value == 1)
261                 XF86DGADirectVideo(dpy, DefaultScreen(dpy), 0);
262
263         XUngrabPointer(dpy, CurrentTime);
264         XUngrabKeyboard(dpy, CurrentTime);
265
266 // inviso cursor
267         XUndefineCursor(dpy, win);
268
269         mouse_active = false;
270 }
271
272 static void HandleEvents(void)
273 {
274         XEvent event;
275 //      KeySym ks;
276         qboolean dowarp = false;
277
278         if (!dpy)
279                 return;
280
281         while (XPending(dpy))
282         {
283                 XNextEvent(dpy, &event);
284
285                 switch (event.type)
286                 {
287                 case KeyPress:
288                 case KeyRelease:
289                         Key_Event(XLateKey(&event.xkey), event.type == KeyPress);
290                         break;
291
292                 case MotionNotify:
293                         if (usingmouse)
294                         {
295                                 if (vid_dga.value == 1)
296                                 {
297                                         mouse_x += event.xmotion.x_root * vid_dga_mouseaccel.value;
298                                         mouse_y += event.xmotion.y_root * vid_dga_mouseaccel.value;
299                                 }
300                                 else
301                                 {
302                                         /*
303                                         if (!p_mouse_x && !p_mouse_y)
304                                         {
305                                                 Con_Printf("event->xmotion.x: %d\n", event.xmotion.x);
306                                                 Con_Printf("event->xmotion.y: %d\n", event.xmotion.y);
307                                         }
308                                         */
309                                         //if (usingmouse)
310                                         {
311                                                 if (!event.xmotion.send_event)
312                                                 {
313                                                         mouse_x += event.xmotion.x - p_mouse_x;
314                                                         mouse_y += event.xmotion.y - p_mouse_y;
315                                                         if (abs(vid.width/2 - event.xmotion.x) > vid.width / 4 || abs(vid.height/2 - event.xmotion.y) > vid.height / 4)
316                                                                 dowarp = true;
317                                                 }
318                                         }
319                                         /*
320                                         else
321                                         {
322                                                 mouse_x += (event.xmotion.x - p_mouse_x);
323                                                 mouse_y += (event.xmotion.y - p_mouse_y);
324                                         }
325                                         */
326                                         p_mouse_x = event.xmotion.x;
327                                         p_mouse_y = event.xmotion.y;
328                                 }
329                         }
330                         else
331                                 ui_mouseupdate(event.xmotion.x, event.xmotion.y);
332                         break;
333
334                 case ButtonPress:
335                         switch(event.xbutton.button)
336                         {
337                         case 1:
338                                 Key_Event(K_MOUSE1, true);
339                                 break;
340                         case 2:
341                                 Key_Event(K_MOUSE3, true);
342                                 break;
343                         case 3:
344                                 Key_Event(K_MOUSE2, true);
345                                 break;
346                         case 4:
347                                 Key_Event(K_MWHEELUP, true);
348                                 break;
349                         case 5:
350                                 Key_Event(K_MWHEELDOWN, true);
351                                 break;
352                 default:
353                                 Con_Printf("HandleEvents: ButtonPress gave value %d, 1-5 expected\n", event.xbutton.button);
354                                 break;
355                         }
356                         break;
357
358                 case ButtonRelease:
359                         switch(event.xbutton.button)
360                         {
361                         case 1:
362                                 Key_Event(K_MOUSE1, false);
363                                 break;
364                         case 2:
365                                 Key_Event(K_MOUSE3, false);
366                                 break;
367                         case 3:
368                                 Key_Event(K_MOUSE2, false);
369                                 break;
370                         case 4:
371                                 Key_Event(K_MWHEELUP, false);
372                                 break;
373                         case 5:
374                                 Key_Event(K_MWHEELDOWN, false);
375                                 break;
376                 default:
377                                 Con_Printf("HandleEvents: ButtonRelease gave value %d, 1-5 expected\n", event.xbutton.button);
378                                 break;
379                         }
380                         break;
381
382                 case CreateNotify :
383                         win_x = event.xcreatewindow.x;
384                         win_y = event.xcreatewindow.y;
385                         break;
386
387                 case ConfigureNotify :
388                         win_x = event.xconfigure.x;
389                         win_y = event.xconfigure.y;
390                         break;
391                 }
392         }
393
394         if (dowarp)
395         {
396                 /* move the mouse to the window center again */
397                 p_mouse_x = vid.width / 2;
398                 p_mouse_y = vid.height / 2;
399                 XWarpPointer(dpy, None, win, 0, 0, 0, 0, p_mouse_x, p_mouse_y);
400         }
401
402 }
403
404 static void IN_DeactivateMouse( void )
405 {
406         if (!mouse_avail || !dpy || !win)
407                 return;
408
409         if (mouse_active)
410         {
411                 uninstall_grabs();
412                 mouse_active = false;
413         }
414 }
415
416 static void IN_ActivateMouse( void )
417 {
418         if (!mouse_avail || !dpy || !win)
419                 return;
420
421         if (!mouse_active)
422         {
423                 mouse_x = mouse_y = 0; // don't spazz
424                 install_grabs();
425                 mouse_active = true;
426         }
427 }
428
429
430 void VID_Shutdown(void)
431 {
432         if (!ctx || !dpy)
433                 return;
434
435         if (dpy)
436         {
437                 uninstall_grabs();
438
439                 if (vidmode_active)
440                         XF86VidModeSwitchToMode(dpy, scrnum, vidmodes[0]);
441 /* Disabled, causes a segfault during shutdown.
442                 if (ctx)
443                         glXDestroyContext(dpy, ctx);
444 */
445                 if (win)
446                         XDestroyWindow(dpy, win);
447                 XCloseDisplay(dpy);
448         }
449         vidmode_active = false;
450         dpy = NULL;
451         win = 0;
452         ctx = NULL;
453 }
454
455 void signal_handler(int sig)
456 {
457         printf("Received signal %d, exiting...\n", sig);
458         Sys_Quit();
459         exit(0);
460 }
461
462 void InitSig(void)
463 {
464         signal(SIGHUP, signal_handler);
465         signal(SIGINT, signal_handler);
466         signal(SIGQUIT, signal_handler);
467         signal(SIGILL, signal_handler);
468         signal(SIGTRAP, signal_handler);
469         signal(SIGIOT, signal_handler);
470         signal(SIGBUS, signal_handler);
471         signal(SIGFPE, signal_handler);
472         signal(SIGSEGV, signal_handler);
473         signal(SIGTERM, signal_handler);
474 }
475
476 /*
477 =================
478 GL_BeginRendering
479
480 =================
481 */
482 void GL_BeginRendering (int *x, int *y, int *width, int *height)
483 {
484         *x = *y = 0;
485         *width = scr_width;
486         *height = scr_height;
487
488 //      glViewport (*x, *y, *width, *height);
489 }
490
491
492 void GL_EndRendering (void)
493 {
494         int usemouse;
495         if (!r_render.value)
496                 return;
497         glFlush();
498         glXSwapBuffers(dpy, win);
499
500 // handle the mouse state when windowed if that's changed
501         usemouse = false;
502         if (vid_mouse.value && key_dest == key_game)
503                 usemouse = true;
504         if (vidmode_active)
505                 usemouse = true;
506         if (usemouse)
507         {
508                 if (!usingmouse)
509                 {
510                         usingmouse = true;
511                         IN_ActivateMouse ();
512                 }
513         }
514         else
515         {
516                 if (usingmouse)
517                 {
518                         usingmouse = false;
519                         IN_DeactivateMouse ();
520                 }
521         }
522 }
523
524 int VID_SetGamma(float prescale, float gamma, float scale, float base)
525 {
526         return FALSE;
527 }
528
529 void VID_Init(void)
530 {
531         int i;
532         int attrib[] =
533         {
534                 GLX_RGBA,
535                 GLX_RED_SIZE, 1,
536                 GLX_GREEN_SIZE, 1,
537                 GLX_BLUE_SIZE, 1,
538                 GLX_DOUBLEBUFFER,
539                 GLX_DEPTH_SIZE, 1,
540                 None
541         };
542 //      char    gldir[MAX_OSPATH];
543         int width = 640, height = 480;
544         XSetWindowAttributes attr;
545         unsigned long mask;
546         Window root;
547         XVisualInfo *visinfo;
548         qboolean fullscreen = true;
549         int MajorVersion, MinorVersion;
550         int actualWidth, actualHeight;
551
552         Cvar_RegisterVariable (&vid_mouse);
553         Cvar_RegisterVariable (&vid_dga);
554         Cvar_RegisterVariable (&vid_dga_mouseaccel);
555         Cvar_RegisterVariable (&m_filter);
556
557 // interpret command-line params
558
559 // set vid parameters
560         if ((i = COM_CheckParm("-window")) != 0)
561                 fullscreen = false;
562
563         if ((i = COM_CheckParm("-width")) != 0)
564                 width = atoi(com_argv[i+1]);
565
566         if ((i = COM_CheckParm("-height")) != 0)
567                 height = atoi(com_argv[i+1]);
568
569         if ((i = COM_CheckParm("-conwidth")) != 0)
570                 vid.conwidth = atoi(com_argv[i+1]);
571         else
572                 vid.conwidth = 640;
573
574         vid.conwidth &= 0xfff8; // make it a multiple of eight
575
576         if (vid.conwidth < 320)
577                 vid.conwidth = 320;
578
579         // pick a conheight that matches with correct aspect
580         vid.conheight = vid.conwidth*3 / 4;
581
582         if ((i = COM_CheckParm("-conheight")) != 0)
583                 vid.conheight = atoi(com_argv[i+1]);
584         if (vid.conheight < 200)
585                 vid.conheight = 200;
586
587         if (!(dpy = XOpenDisplay(NULL)))
588         {
589                 fprintf(stderr, "Error couldn't open the X display\n");
590                 exit(1);
591         }
592
593         scrnum = DefaultScreen(dpy);
594         root = RootWindow(dpy, scrnum);
595
596         // Get video mode list
597         MajorVersion = MinorVersion = 0;
598         if (!XF86VidModeQueryVersion(dpy, &MajorVersion, &MinorVersion))
599                 vidmode_ext = false;
600         else
601         {
602                 Con_Printf("Using XFree86-VidModeExtension Version %d.%d\n", MajorVersion, MinorVersion);
603                 vidmode_ext = true;
604         }
605
606         visinfo = glXChooseVisual(dpy, scrnum, attrib);
607         if (!visinfo)
608         {
609                 fprintf(stderr, "qkHack: Error couldn't get an RGB, Double-buffered, Depth visual\n");
610                 exit(1);
611         }
612
613         if (vidmode_ext)
614         {
615                 int best_fit, best_dist, dist, x, y;
616
617                 XF86VidModeGetAllModeLines(dpy, scrnum, &num_vidmodes, &vidmodes);
618
619                 // Are we going fullscreen?  If so, let's change video mode
620                 if (fullscreen)
621                 {
622                         best_dist = 9999999;
623                         best_fit = -1;
624
625                         for (i = 0; i < num_vidmodes; i++)
626                         {
627                                 if (width > vidmodes[i]->hdisplay || height > vidmodes[i]->vdisplay)
628                                         continue;
629
630                                 x = width - vidmodes[i]->hdisplay;
631                                 y = height - vidmodes[i]->vdisplay;
632                                 dist = (x * x) + (y * y);
633                                 if (dist < best_dist)
634                                 {
635                                         best_dist = dist;
636                                         best_fit = i;
637                                 }
638                         }
639
640                         if (best_fit != -1)
641                         {
642                                 actualWidth = vidmodes[best_fit]->hdisplay;
643                                 actualHeight = vidmodes[best_fit]->vdisplay;
644
645                                 // change to the mode
646                                 XF86VidModeSwitchToMode(dpy, scrnum, vidmodes[best_fit]);
647                                 vidmode_active = true;
648
649                                 // Move the viewport to top left
650                                 XF86VidModeSetViewPort(dpy, scrnum, 0, 0);
651                         }
652                         else
653                                 fullscreen = 0;
654                 }
655         }
656
657         /* window attributes */
658         attr.background_pixel = 0;
659         attr.border_pixel = 0;
660         attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
661         attr.event_mask = X_MASK;
662         if (vidmode_active)
663         {
664                 mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore | CWEventMask | CWOverrideRedirect;
665                 attr.override_redirect = True;
666                 attr.backing_store = NotUseful;
667                 attr.save_under = False;
668         }
669         else
670                 mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
671
672         win = XCreateWindow(dpy, root, 0, 0, width, height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr);
673         XStoreName(dpy, win, "DarkPlaces-GLX");
674         XMapWindow(dpy, win);
675
676         if (vidmode_active)
677         {
678                 XMoveWindow(dpy, win, 0, 0);
679                 XRaiseWindow(dpy, win);
680                 XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
681                 XFlush(dpy);
682                 // Move the viewport to top left
683                 XF86VidModeSetViewPort(dpy, scrnum, 0, 0);
684         }
685
686         XFlush(dpy);
687
688         ctx = glXCreateContext(dpy, visinfo, NULL, True);
689
690         glXMakeCurrent(dpy, win, ctx);
691
692         scr_width = width;
693         scr_height = height;
694
695         if (vid.conheight > height)
696                 vid.conheight = height;
697         if (vid.conwidth > width)
698                 vid.conwidth = width;
699         vid.width = vid.conwidth;
700         vid.height = vid.conheight;
701
702         InitSig(); // trap evil signals
703
704         GL_Init();
705
706         Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
707
708         // force a surface cache flush
709         vid.recalc_refdef = 1;
710 }
711
712 void Sys_SendKeyEvents(void)
713 {
714         HandleEvents();
715 }
716
717 void IN_Init(void)
718 {
719 }
720
721 void IN_Shutdown(void)
722 {
723 }
724
725 /*
726 ===========
727 IN_Commands
728 ===========
729 */
730 void IN_Commands (void)
731 {
732 }
733
734 /*
735 ===========
736 IN_Move
737 ===========
738 */
739 void IN_MouseMove (usercmd_t *cmd)
740 {
741         if (!mouse_avail)
742                 return;
743
744         if (m_filter.value)
745         {
746                 mouse_x = (mouse_x + old_mouse_x) * 0.5;
747                 mouse_y = (mouse_y + old_mouse_y) * 0.5;
748
749                 old_mouse_x = mouse_x;
750                 old_mouse_y = mouse_y;
751         }
752
753         mouse_x *= sensitivity.value;
754         mouse_y *= sensitivity.value;
755
756         if (in_strafe.state & 1)
757                 cmd->sidemove += m_side.value * mouse_x;
758         else
759                 cl.viewangles[YAW] -= m_yaw.value * mouse_x;
760
761         //if (freelook)
762                 V_StopPitchDrift ();
763
764         if (/*freelook && */!(in_strafe.state & 1))
765         {
766                 cl.viewangles[PITCH] += m_pitch.value * mouse_y;
767                 cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
768         }
769         else
770         {
771                 if ((in_strafe.state & 1) && noclip_anglehack)
772                         cmd->upmove -= m_forward.value * mouse_y;
773                 else
774                         cmd->forwardmove -= m_forward.value * mouse_y;
775         }
776         mouse_x = mouse_y = 0.0;
777 }
778
779 void IN_Move (usercmd_t *cmd)
780 {
781         IN_MouseMove(cmd);
782 }
783
784