2 Copyright (C) 1996-1997 Id Software, Inc.
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.
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.
13 See the GNU General Public License for more details.
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.
20 //#include <termios.h>
21 //#include <sys/ioctl.h>
22 //#include <sys/stat.h>
31 #include <X11/Xutil.h>
34 #include <X11/keysym.h>
35 #include <X11/cursorfont.h>
37 #include <X11/extensions/XShm.h>
38 #if !defined(__APPLE__) && !defined(__MACH__) && !defined(SUNOS)
39 #include <X11/extensions/xf86dga.h>
41 #include <X11/extensions/xf86vmode.h>
45 // Tell startup code that we have a client
46 int cl_available = true;
49 XVisualInfo *(GLAPIENTRY *qglXChooseVisual)(Display *dpy, int screen, int *attribList);
50 GLXContext (GLAPIENTRY *qglXCreateContext)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
51 void (GLAPIENTRY *qglXDestroyContext)(Display *dpy, GLXContext ctx);
52 Bool (GLAPIENTRY *qglXMakeCurrent)(Display *dpy, GLXDrawable drawable, GLXContext ctx);
53 void (GLAPIENTRY *qglXSwapBuffers)(Display *dpy, GLXDrawable drawable);
54 const char *(GLAPIENTRY *qglXQueryExtensionsString)(Display *dpy, int screen);
56 //GLX_ARB_get_proc_address
57 void *(GLAPIENTRY *qglXGetProcAddressARB)(const GLubyte *procName);
59 static dllfunction_t getprocaddressfuncs[] =
61 {"glXGetProcAddressARB", (void **) &qglXGetProcAddressARB},
65 //GLX_SGI_swap_control
66 GLint (GLAPIENTRY *qglXSwapIntervalSGI)(GLint interval);
68 static dllfunction_t swapcontrolfuncs[] =
70 {"glXSwapIntervalSGI", (void **) &qglXSwapIntervalSGI},
74 static Display *vidx11_display = NULL;
75 static int vidx11_screen;
77 static GLXContext ctx = NULL;
79 Atom wm_delete_window_atom;
81 #define KEY_MASK (KeyPressMask | KeyReleaseMask)
82 #define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | \
83 PointerMotionMask | ButtonMotionMask)
84 #define X_MASK (KEY_MASK | MOUSE_MASK | VisibilityChangeMask | \
85 StructureNotifyMask | FocusChangeMask | EnterWindowMask | \
89 static qboolean mouse_avail = true;
90 static qboolean vid_usingmouse = false;
91 static qboolean vid_usingvsync = false;
92 static qboolean vid_usevsync = false;
93 static float mouse_x, mouse_y;
94 static int p_mouse_x, p_mouse_y;
96 #if !defined(__APPLE__) && !defined(SUNOS)
97 cvar_t vid_dga = {CVAR_SAVE, "vid_dga", "1"};
98 cvar_t vid_dga_mouseaccel = {0, "vid_dga_mouseaccel", "1"};
101 qboolean vidmode_ext = false;
103 static int win_x, win_y;
105 static XF86VidModeModeInfo **vidmodes;
106 static int num_vidmodes;
107 static qboolean vid_isfullscreen = false;
109 static Visual *vidx11_visual;
110 static Colormap vidx11_colormap;
112 /*-----------------------------------------------------------------------*/
114 static int XLateKey(XKeyEvent *ev, char *ascii)
118 KeySym keysym, shifted;
120 keysym = XLookupKeysym (ev, 0);
121 XLookupString(ev, buf, sizeof buf, &shifted, 0);
126 case XK_KP_Page_Up: key = K_KP_PGUP; break;
127 case XK_Page_Up: key = K_PGUP; break;
129 case XK_KP_Page_Down: key = K_KP_PGDN; break;
130 case XK_Page_Down: key = K_PGDN; break;
132 case XK_KP_Home: key = K_KP_HOME; break;
133 case XK_Home: key = K_HOME; break;
135 case XK_KP_End: key = K_KP_END; break;
136 case XK_End: key = K_END; break;
138 case XK_KP_Left: key = K_KP_LEFTARROW; break;
139 case XK_Left: key = K_LEFTARROW; break;
141 case XK_KP_Right: key = K_KP_RIGHTARROW; break;
142 case XK_Right: key = K_RIGHTARROW; break;
144 case XK_KP_Down: key = K_KP_DOWNARROW; break;
145 case XK_Down: key = K_DOWNARROW; break;
147 case XK_KP_Up: key = K_KP_UPARROW; break;
148 case XK_Up: key = K_UPARROW; break;
150 case XK_Escape: key = K_ESCAPE; break;
152 case XK_KP_Enter: key = K_KP_ENTER; break;
153 case XK_Return: key = K_ENTER; break;
155 case XK_Tab: key = K_TAB; break;
157 case XK_F1: key = K_F1; break;
159 case XK_F2: key = K_F2; break;
161 case XK_F3: key = K_F3; break;
163 case XK_F4: key = K_F4; break;
165 case XK_F5: key = K_F5; break;
167 case XK_F6: key = K_F6; break;
169 case XK_F7: key = K_F7; break;
171 case XK_F8: key = K_F8; break;
173 case XK_F9: key = K_F9; break;
175 case XK_F10: key = K_F10; break;
177 case XK_F11: key = K_F11; break;
179 case XK_F12: key = K_F12; break;
181 case XK_BackSpace: key = K_BACKSPACE; break;
183 case XK_KP_Delete: key = K_KP_DEL; break;
184 case XK_Delete: key = K_DEL; break;
186 case XK_Pause: key = K_PAUSE; break;
189 case XK_Shift_R: key = K_SHIFT; break;
193 case XK_Control_R: key = K_CTRL; break;
198 case XK_Meta_R: key = K_ALT; break;
200 case XK_KP_Begin: key = K_KP_5; break;
202 case XK_Insert:key = K_INS; break;
203 case XK_KP_Insert: key = K_KP_INS; break;
205 case XK_KP_Multiply: key = '*'; break;
206 case XK_KP_Add: key = K_KP_PLUS; break;
207 case XK_KP_Subtract: key = K_KP_MINUS; break;
208 case XK_KP_Divide: key = K_KP_SLASH; break;
210 case XK_section: key = '~'; break;
216 if (keysym >= 'A' && keysym <= 'Z')
217 key = keysym - 'A' + 'a';
227 static Cursor CreateNullCursor(Display *display, Window root)
235 cursormask = XCreatePixmap(display, root, 1, 1, 1);
236 xgc.function = GXclear;
237 gc = XCreateGC(display, cursormask, GCFunction, &xgc);
238 XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
239 dummycolour.pixel = 0;
241 dummycolour.flags = 04;
242 cursor = XCreatePixmapCursor(display, cursormask, cursormask, &dummycolour,&dummycolour, 0,0);
243 XFreePixmap(display,cursormask);
248 static void IN_Activate (qboolean grab)
254 if (!vid_usingmouse && mouse_avail && win)
256 XWindowAttributes attribs_1;
257 XSetWindowAttributes attribs_2;
259 XGetWindowAttributes(vidx11_display, win, &attribs_1);
260 attribs_2.event_mask = attribs_1.your_event_mask | KEY_MASK | MOUSE_MASK;
261 XChangeWindowAttributes(vidx11_display, win, CWEventMask, &attribs_2);
264 XDefineCursor(vidx11_display, win, CreateNullCursor(vidx11_display, win));
266 XGrabPointer(vidx11_display, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
268 #if !defined(__APPLE__) && !defined(SUNOS)
271 int MajorVersion, MinorVersion;
273 if (!XF86DGAQueryVersion(vidx11_display, &MajorVersion, &MinorVersion))
275 // unable to query, probably not supported
276 Con_Print( "Failed to detect XF86DGA Mouse\n" );
277 Cvar_SetValueQuick(&vid_dga, 0);
278 XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);
282 XF86DGADirectVideo(vidx11_display, DefaultScreen(vidx11_display), XF86DGADirectMouse);
283 XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, 0, 0);
288 XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);
290 XGrabKeyboard(vidx11_display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
292 mouse_x = mouse_y = 0;
293 cl_ignoremousemove = true;
294 vid_usingmouse = true;
301 #if !defined(__APPLE__) && !defined(SUNOS)
303 XF86DGADirectVideo(vidx11_display, DefaultScreen(vidx11_display), 0);
306 XUngrabPointer(vidx11_display, CurrentTime);
307 XUngrabKeyboard(vidx11_display, CurrentTime);
311 XUndefineCursor(vidx11_display, win);
313 cl_ignoremousemove = true;
314 vid_usingmouse = false;
319 static keynum_t buttonremap[18] =
341 static void HandleEvents(void)
346 qboolean dowarp = false;
351 while (XPending(vidx11_display))
353 XNextEvent(vidx11_display, &event);
359 key = XLateKey (&event.xkey, &ascii);
360 Key_Event(key, ascii, true);
365 key = XLateKey (&event.xkey, &ascii);
366 Key_Event(key, ascii, false);
373 #if !defined(__APPLE__) && !defined(SUNOS)
374 if (vid_dga.integer == 1)
376 mouse_x += event.xmotion.x_root * vid_dga_mouseaccel.value;
377 mouse_y += event.xmotion.y_root * vid_dga_mouseaccel.value;
383 if (!event.xmotion.send_event)
385 mouse_x += event.xmotion.x - p_mouse_x;
386 mouse_y += event.xmotion.y - p_mouse_y;
387 if (abs(vid.width/2 - event.xmotion.x) > vid.width / 4 || abs(vid.height/2 - event.xmotion.y) > vid.height / 4)
390 p_mouse_x = event.xmotion.x;
391 p_mouse_y = event.xmotion.y;
395 // ui_mouseupdate(event.xmotion.x, event.xmotion.y);
399 // mouse button pressed
400 if (event.xbutton.button <= 18)
401 Key_Event(buttonremap[event.xbutton.button - 1], 0, true);
403 Con_Printf("HandleEvents: ButtonPress gave value %d, 1-18 expected\n", event.xbutton.button);
407 // mouse button released
408 if (event.xbutton.button <= 18)
409 Key_Event(buttonremap[event.xbutton.button - 1], 0, false);
411 Con_Printf("HandleEvents: ButtonRelease gave value %d, 1-18 expected\n", event.xbutton.button);
416 win_x = event.xcreatewindow.x;
417 win_y = event.xcreatewindow.y;
420 case ConfigureNotify:
421 // window changed size/location
422 win_x = event.xconfigure.x;
423 win_y = event.xconfigure.y;
426 // window has been destroyed
430 // window manager messages
431 if ((event.xclient.format == 32) && ((unsigned int)event.xclient.data.l[0] == wm_delete_window_atom))
437 vid_activewindow = false;
438 VID_RestoreSystemGamma();
441 // window iconified/rolledup/whatever
443 vid_activewindow = false;
444 VID_RestoreSystemGamma();
447 // window is now the input focus
448 vid_activewindow = true;
451 // window is no longer the input focus
452 vid_activewindow = false;
453 VID_RestoreSystemGamma();
456 // mouse entered window
466 /* move the mouse to the window center again */
467 p_mouse_x = vid.width / 2;
468 p_mouse_y = vid.height / 2;
469 XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, p_mouse_x, p_mouse_y);
473 static void *prjobj = NULL;
475 static void GL_CloseLibrary(void)
481 qglXGetProcAddressARB = NULL;
484 gl_platformextensions = "";
487 static int GL_OpenLibrary(const char *name)
489 Con_Printf("Loading OpenGL driver %s\n", name);
491 if (!(prjobj = dlopen(name, RTLD_LAZY)))
493 Con_Printf("Unable to open symbol list for %s\n", name);
496 strcpy(gl_driver, name);
500 void *GL_GetProcAddress(const char *name)
503 if (qglXGetProcAddressARB != NULL)
504 p = (void *) qglXGetProcAddressARB((GLubyte *)name);
506 p = (void *) dlsym(prjobj, name);
510 void VID_Shutdown(void)
512 if (!ctx || !vidx11_display)
518 VID_RestoreSystemGamma();
520 // FIXME: glXDestroyContext here?
521 if (vid_isfullscreen)
522 XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, vidmodes[0]);
524 XDestroyWindow(vidx11_display, win);
525 XCloseDisplay(vidx11_display);
528 vid_isfullscreen = false;
529 vidx11_display = NULL;
537 void signal_handler(int sig)
539 Con_Printf("Received signal %d, exiting...\n", sig);
540 VID_RestoreSystemGamma();
547 signal(SIGHUP, signal_handler);
548 signal(SIGINT, signal_handler);
549 signal(SIGQUIT, signal_handler);
550 signal(SIGILL, signal_handler);
551 signal(SIGTRAP, signal_handler);
552 signal(SIGIOT, signal_handler);
553 signal(SIGBUS, signal_handler);
554 signal(SIGFPE, signal_handler);
555 signal(SIGSEGV, signal_handler);
556 signal(SIGTERM, signal_handler);
559 void VID_Finish (void)
561 qboolean vid_usemouse;
563 vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable;
564 if (vid_usingvsync != vid_usevsync && gl_videosyncavailable)
566 vid_usingvsync = vid_usevsync;
567 if (qglXSwapIntervalSGI (vid_usevsync))
568 Con_Print("glXSwapIntervalSGI didn't accept the vid_vsync change, it will take effect on next vid_restart (GLX_SGI_swap_control does not allow turning off vsync)\n");
571 // handle the mouse state when windowed if that's changed
572 vid_usemouse = false;
573 if (vid_mouse.integer && !key_consoleactive && !cls.demoplayback)
575 if (!vid_activewindow)
576 vid_usemouse = false;
577 if (vid_isfullscreen)
579 IN_Activate(vid_usemouse);
581 if (r_render.integer)
583 if (r_speeds.integer || gl_finish.integer)
585 qglXSwapBuffers(vidx11_display, win);
589 int VID_SetGamma(unsigned short *ramps)
591 return XF86VidModeSetGammaRamp(vidx11_display, vidx11_screen, 256, ramps, ramps + 256, ramps + 512);
594 int VID_GetGamma(unsigned short *ramps)
596 return XF86VidModeGetGammaRamp(vidx11_display, vidx11_screen, 256, ramps, ramps + 256, ramps + 512);
601 #if !defined(__APPLE__) && !defined(SUNOS)
602 Cvar_RegisterVariable (&vid_dga);
603 Cvar_RegisterVariable (&vid_dga_mouseaccel);
605 InitSig(); // trap evil signals
606 // COMMANDLINEOPTION: Input: -nomouse disables mouse support (see also vid_mouse cvar)
607 if (COM_CheckParm ("-nomouse") || COM_CheckParm("-safe"))
611 void VID_BuildGLXAttrib(int *attrib, int stencil)
613 *attrib++ = GLX_RGBA;
614 *attrib++ = GLX_RED_SIZE;*attrib++ = 1;
615 *attrib++ = GLX_GREEN_SIZE;*attrib++ = 1;
616 *attrib++ = GLX_BLUE_SIZE;*attrib++ = 1;
617 *attrib++ = GLX_DOUBLEBUFFER;
618 *attrib++ = GLX_DEPTH_SIZE;*attrib++ = 1;
619 // if stencil is enabled, ask for alpha too
622 *attrib++ = GLX_STENCIL_SIZE;*attrib++ = 8;
623 *attrib++ = GLX_ALPHA_SIZE;*attrib++ = 1;
628 int VID_InitMode(int fullscreen, int width, int height, int bpp)
632 XSetWindowAttributes attr;
635 XVisualInfo *visinfo;
636 int MajorVersion, MinorVersion;
637 const char *drivername;
639 #if defined(__APPLE__) && defined(__MACH__)
640 drivername = "/usr/X11R6/lib/libGL.1.dylib";
642 drivername = "libGL.so.1";
644 // COMMANDLINEOPTION: Linux GLX: -gl_driver <drivername> selects a GL driver library, default is libGL.so.1, useful only for using fxmesa or similar, if you don't know what this is for, you don't need it
645 // COMMANDLINEOPTION: BSD GLX: -gl_driver <drivername> selects a GL driver library, default is libGL.so.1, useful only for using fxmesa or similar, if you don't know what this is for, you don't need it
646 // LordHavoc: although this works on MacOSX, it's useless there (as there is only one system libGL)
647 i = COM_CheckParm("-gl_driver");
648 if (i && i < com_argc - 1)
649 drivername = com_argv[i + 1];
650 if (!GL_OpenLibrary(drivername))
652 Con_Printf("Unable to load GL driver \"%s\"\n", drivername);
656 if (!(vidx11_display = XOpenDisplay(NULL)))
658 Con_Print("Couldn't open the X display\n");
662 vidx11_screen = DefaultScreen(vidx11_display);
663 root = RootWindow(vidx11_display, vidx11_screen);
665 // Get video mode list
666 MajorVersion = MinorVersion = 0;
667 if (!XF86VidModeQueryVersion(vidx11_display, &MajorVersion, &MinorVersion))
671 Con_DPrintf("Using XFree86-VidModeExtension Version %d.%d\n", MajorVersion, MinorVersion);
675 if ((qglXChooseVisual = (XVisualInfo *(GLAPIENTRY *)(Display *dpy, int screen, int *attribList))GL_GetProcAddress("glXChooseVisual")) == NULL
676 || (qglXCreateContext = (GLXContext (GLAPIENTRY *)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct))GL_GetProcAddress("glXCreateContext")) == NULL
677 || (qglXDestroyContext = (void (GLAPIENTRY *)(Display *dpy, GLXContext ctx))GL_GetProcAddress("glXDestroyContext")) == NULL
678 || (qglXMakeCurrent = (Bool (GLAPIENTRY *)(Display *dpy, GLXDrawable drawable, GLXContext ctx))GL_GetProcAddress("glXMakeCurrent")) == NULL
679 || (qglXSwapBuffers = (void (GLAPIENTRY *)(Display *dpy, GLXDrawable drawable))GL_GetProcAddress("glXSwapBuffers")) == NULL
680 || (qglXQueryExtensionsString = (const char *(GLAPIENTRY *)(Display *dpy, int screen))GL_GetProcAddress("glXQueryExtensionsString")) == NULL)
682 Con_Printf("glX functions not found in %s\n", gl_driver);
686 VID_BuildGLXAttrib(attrib, bpp == 32);
687 visinfo = qglXChooseVisual(vidx11_display, vidx11_screen, attrib);
690 Con_Print("Couldn't get an RGB, Double-buffered, Depth visual\n");
696 int best_fit, best_dist, dist, x, y;
698 // Are we going fullscreen? If so, let's change video mode
701 XF86VidModeGetAllModeLines(vidx11_display, vidx11_screen, &num_vidmodes, &vidmodes);
705 for (i = 0; i < num_vidmodes; i++)
707 if (width > vidmodes[i]->hdisplay || height > vidmodes[i]->vdisplay)
710 x = width - vidmodes[i]->hdisplay;
711 y = height - vidmodes[i]->vdisplay;
712 dist = (x * x) + (y * y);
713 if (dist < best_dist)
722 // LordHavoc: changed from ActualWidth/ActualHeight =,
723 // to width/height =, so the window will take the full area of
725 width = vidmodes[best_fit]->hdisplay;
726 height = vidmodes[best_fit]->vdisplay;
728 // change to the mode
729 XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, vidmodes[best_fit]);
730 vid_isfullscreen = true;
732 // Move the viewport to top left
733 XF86VidModeSetViewPort(vidx11_display, vidx11_screen, 0, 0);
740 // LordHavoc: save the visual for use in gamma ramp settings later
741 vidx11_visual = visinfo->visual;
743 /* window attributes */
744 attr.background_pixel = 0;
745 attr.border_pixel = 0;
746 // LordHavoc: save the colormap for later, too
747 vidx11_colormap = attr.colormap = XCreateColormap(vidx11_display, root, visinfo->visual, AllocNone);
748 attr.event_mask = X_MASK;
749 if (vid_isfullscreen)
751 mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore | CWEventMask | CWOverrideRedirect;
752 attr.override_redirect = True;
753 attr.backing_store = NotUseful;
754 attr.save_under = False;
757 mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
759 win = XCreateWindow(vidx11_display, root, 0, 0, width, height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr);
760 XStoreName(vidx11_display, win, gamename);
761 XMapWindow(vidx11_display, win);
763 // LordHavoc: making the close button on a window do the right thing
764 // seems to involve this mess, sigh...
765 wm_delete_window_atom = XInternAtom(vidx11_display, "WM_DELETE_WINDOW", false);
766 XSetWMProtocols(vidx11_display, win, &wm_delete_window_atom, 1);
768 if (vid_isfullscreen)
770 XMoveWindow(vidx11_display, win, 0, 0);
771 XRaiseWindow(vidx11_display, win);
772 XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, 0, 0);
773 XFlush(vidx11_display);
774 // Move the viewport to top left
775 XF86VidModeSetViewPort(vidx11_display, vidx11_screen, 0, 0);
778 //XSync(vidx11_display, False);
780 ctx = qglXCreateContext(vidx11_display, visinfo, NULL, True);
783 Con_Printf ("glXCreateContext failed\n");
787 if (!qglXMakeCurrent(vidx11_display, win, ctx))
789 Con_Printf ("glXMakeCurrent failed\n");
793 XSync(vidx11_display, False);
795 if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL)
797 Con_Printf ("glGetString not found in %s\n", gl_driver);
801 gl_renderer = (const char *)qglGetString(GL_RENDERER);
802 gl_vendor = (const char *)qglGetString(GL_VENDOR);
803 gl_version = (const char *)qglGetString(GL_VERSION);
804 gl_extensions = (const char *)qglGetString(GL_EXTENSIONS);
806 gl_platformextensions = qglXQueryExtensionsString(vidx11_display, vidx11_screen);
808 gl_videosyncavailable = false;
810 // COMMANDLINEOPTION: Linux GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
811 // COMMANDLINEOPTION: BSD GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
812 // COMMANDLINEOPTION: MacOSX GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
813 GL_CheckExtension("GLX_ARB_get_proc_address", getprocaddressfuncs, "-nogetprocaddress", false);
814 // COMMANDLINEOPTION: Linux GLX: -novideosync disables GLX_SGI_swap_control
815 // COMMANDLINEOPTION: BSD GLX: -novideosync disables GLX_SGI_swap_control
816 // COMMANDLINEOPTION: MacOSX GLX: -novideosync disables GLX_SGI_swap_control
817 gl_videosyncavailable = GL_CheckExtension("GLX_SGI_swap_control", swapcontrolfuncs, "-novideosync", false);
819 vid_usingmouse = false;
820 vid_usingvsync = false;
822 vid_activewindow = true;
827 void Sys_SendKeyEvents(void)
836 in_mouse_x = mouse_x;
837 in_mouse_y = mouse_y;