📄 x11.cpp
字号:
case XK_BackSpace: if (event.type == KeyPress) { Settings.DisableGraphicWindows = !Settings.DisableGraphicWindows; S9xDisplayStateChange ("Graphic clip windows", !Settings.DisableGraphicWindows); } break; case XK_bracketleft: if (event.type == KeyPress) { Settings.InterpolatedSound ^= 1; S9xDisplayStateChange ("Interpolated sound", Settings.InterpolatedSound); } break; case XK_bracketright: if (event.type == KeyPress) { Settings.SoundSync ^= 1; S9xDisplayStateChange ("Synchronised sound", Settings.SoundSync); } break; case XK_Scroll_Lock: case XK_Pause: case XK_Break: if (event.type == KeyPress) { Settings.Paused ^= 1; S9xDisplayStateChange ("Pause", Settings.Paused); } break; case XK_Tab: Settings.TurboMode = event.type == KeyPress; break; case XK_grave: case XK_asciitilde: case XK_numbersign: if (event.type == KeyPress) GUI.superscope_turbo = !GUI.superscope_turbo; break; case XK_slash: GUI.superscope_pause = event.type == KeyPress; break;#ifdef USE_DGA_EXTENSION case XK_f: if (!(event.xkey.state & Mod1Mask)) break; /* FALL */ case XK_Print: if (event.type == KeyPress) S9xSwitchToFullScreen (!XF86.is_full_screen); break;#endif case XK_F1: if (event.type == KeyPress && (event.xkey.state & (Mod1Mask | ControlMask))) { char def [PATH_MAX]; char filename [PATH_MAX]; char drive [_MAX_DRIVE]; char dir [_MAX_DIR]; char ext [_MAX_EXT]; _splitpath (Memory.ROMFilename, drive, dir, def, ext); strcpy (ext, "spc"); _makepath (filename, drive, S9xGetSnapshotDirectory (), def, ext); if (S9xSPCDump (filename)) sprintf (GUI.info_string, "%s.%s saved", def, ext); else sprintf (GUI.info_string, "%s.%s not saved (%s)", def, ext, strerror (errno)); S9xSetInfoString (GUI.info_string); break; } // Fall... case XK_F2: if (event.type == KeyPress && (event.xkey.state & (Mod1Mask | ControlMask))) { S9xUnfreezeGame (S9xChooseFilename (TRUE)); break; } // Fall... case XK_F3: if (event.type == KeyPress && (event.xkey.state & (Mod1Mask | ControlMask))) { S9xFreezeGame (S9xChooseFilename (FALSE)); break; } // Fall... case XK_F4: case XK_F5: case XK_F6: case XK_F7: case XK_F8: case XK_F9: case XK_F10: case XK_F11: case XK_F12: if (event.type == KeyPress) { if (!(event.xkey.state & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask))) { if (key == XK_F11) { S9xLoadSnapshot (S9xChooseFilename (TRUE)); break; } else if (key == XK_F12) { Snapshot (S9xChooseFilename (FALSE)); break; } char def [PATH_MAX]; char filename [PATH_MAX]; char drive [_MAX_DRIVE]; char dir [_MAX_DIR]; char ext [_MAX_EXT]; _splitpath (Memory.ROMFilename, drive, dir, def, ext); sprintf (filename, "%s%s%s.%03d", S9xGetSnapshotDirectory (), SLASH_STR, def, key - XK_F1); if (S9xLoadSnapshot (filename)) { sprintf (GUI.info_string, "%s.%03d loaded", def, key - XK_F1); S9xSetInfoString (GUI.info_string); } else { static char *digits = "t123456789"; _splitpath (Memory.ROMFilename, drive, dir, def, ext); sprintf (filename, "%s%s%s.zs%c", S9xGetSnapshotDirectory (), SLASH_STR, def, digits [key - XK_F1]); if (S9xLoadSnapshot (filename)) { sprintf (GUI.info_string, "Loaded ZSNES freeze file %s.zs%c", def, digits [key - XK_F1]); S9xSetInfoString (GUI.info_string); } else S9xMessage (S9X_ERROR, S9X_FREEZE_FILE_NOT_FOUND, "Freeze file not found"); } } else if (event.xkey.state & (Mod1Mask | ControlMask | Mod4Mask)) { if (key >= XK_F4) S9xToggleSoundChannel (key - XK_F4); if (key == XK_F12) S9xSetInfoString ("All sound channels on"); else { sprintf (GUI.info_string, "Sound channel %d %s", key - XK_F4, (so.sound_switch & (1 << (key - XK_F4))) ? "on" : "off"); S9xSetInfoString (GUI.info_string); } } else { char def [PATH_MAX]; char filename [PATH_MAX]; char drive [_MAX_DRIVE]; char dir [_MAX_DIR]; char ext [_MAX_EXT]; _splitpath (Memory.ROMFilename, drive, dir, def, ext); sprintf (filename, "%s%s%s.%03d", S9xGetSnapshotDirectory (), SLASH_STR, def, key - XK_F1); sprintf (GUI.info_string, "%s.%03d saved", def, key - XK_F1); S9xSetInfoString (GUI.info_string); Snapshot (filename); } } break; } if (event.type == KeyPress) { joypads [0] |= byte1; joypads [0] |= (byte2 << 8); joypads [1] |= byte3; joypads [1] |= (byte4 << 8); } else { joypads [0] &= ~byte1; joypads [0] &= ~(byte2 << 8); joypads [1] &= ~byte3; joypads [1] &= ~(byte4 << 8); } break; } case FocusIn: XAutoRepeatOff (GUI.display); XFlush (GUI.display); //Settings.Paused &= ~2; break; case FocusOut: XAutoRepeatOn (GUI.display); XFlush (GUI.display); //Settings.Paused |= 2; break; case ConfigureNotify: if (event.xany.window == GUI.window && (GUI.window_width != event.xconfigure.width || GUI.window_height != event.xconfigure.height)) { GUI.window_width = event.xconfigure.width; GUI.window_height = event.xconfigure.height; IPPU.RenderThisFrame = TRUE; IPPU.FrameSkip = Settings.SkipFrames; SetupImage (); }#ifdef USE_DGA_EXTENSION if (XF86.start_full_screen) { XF86.start_full_screen = FALSE; S9xSwitchToFullScreen (TRUE); }#endif break;#if 0 case ButtonPress: GUI.mouse_buttons = (event.xbutton.state | (1 << event.xbutton.button)) & 0x1f; break; case ButtonRelease: GUI.mouse_buttons = (event.xbutton.state & ~(1 << event.xbutton.button)) & 0x1f; break;#endif } }}void S9xPutImage (int snes_width, int snes_height){#ifdef USE_GLIDE if (Settings.GlideEnable) S9xGlidePutImage (snes_width, snes_height); else {#endif bool8 done = FALSE; int width, height; width = snes_width; height = snes_height; if (GUI.interpolate && Settings.SixteenBit) { if (snes_width == 512 && snes_height > 240 && GUI.interpolate != 5) { GUI.output_screen = GFX.Screen; GUI.output_pitch = GFX.Pitch;#ifdef USE_DGA_EXTENSION if (XF86.is_full_screen) { if (XF86.scale) GUI.image_date = (uint8 *) XF86.vram; else { GUI.box.x = (XF86.window_width - width) / 2; GUI.box.y = (XF86.window_height - height) / 2; GUI.image_date = (uint8 *) XF86.vram + GUI.box.x * GUI.bytes_per_pixel + GUI.box.y * GUI.bytes_per_line; } }#endif if (!GUI.image_needs_scaling) { for (int y = 0; y < snes_height; y++) { memmove (GUI.image_date + y * GUI.bytes_per_line, GFX.Screen + GFX.Pitch * y, snes_width * GUI.bytes_per_pixel); } done = TRUE; } } else { if (GUI.interpolate != 5) { width = 512; if (snes_height < 240) height = snes_height << 1; else height = snes_height; } else { width = GUI.window_width; height = GUI.window_height; } if (GUI.image_needs_scaling || GUI.interpolate == 5) { GUI.box.x = 0; GUI.box.y = 0; } else { GUI.box.x = (GUI.window_width - width) / 2; GUI.box.y = (GUI.window_height - height) / 2; } // Kreed's bi-linear image filter scales as well if ((GUI.image_needs_scaling && GUI.interpolate != 5) || (GUI.depth != 15 && GUI.depth != 16)) { GUI.output_screen = GUI.interpolated_screen; GUI.output_pitch = 512 * 2; } else {#ifdef USE_DGA_EXTENSION if (XF86.is_full_screen) { if (XF86.scale) GUI.image_date = (uint8 *) XF86.vram; else { GUI.box.x = (XF86.window_width - width) / 2; GUI.box.y = (XF86.window_height - height) / 2; GUI.image_date = (uint8 *) XF86.vram + GUI.box.x * GUI.bytes_per_pixel + GUI.box.y * GUI.bytes_per_line; } GUI.output_screen = GUI.image_date; GUI.output_pitch = GUI.bytes_per_line; done = TRUE; } else#endif { GUI.output_screen = (uint8 *) GUI.image->data; GUI.output_pitch = GUI.image->bytes_per_line; } } if (snes_width != GUI.last_snes_width || snes_height != GUI.last_snes_height) { memset (GUI.delta_screen, 255, GFX.Pitch * snes_height); } TVMode (snes_width, snes_height); } } else { GUI.output_screen = GFX.Screen; GUI.output_pitch = GFX.Pitch; width = snes_width; height = snes_height; if (GUI.image_needs_scaling) { GUI.box.x = 0; GUI.box.y = 0; } else { GUI.box.x = (GUI.window_width - width) / 2; GUI.box.y = (GUI.window_height - height) / 2; } } if ((Settings.SixteenBit && GUI.depth != 15 && GUI.depth != 16) || (!Settings.SixteenBit && (!GUI.pseudo || GUI.depth != 8)) || (GUI.image_needs_scaling && !(Settings.SixteenBit && GUI.interpolate == 5))) { done = TRUE; switch (GUI.depth) { case 8: if (Settings.SixteenBit) Convert16To8 (width, height); else Scale8 (width, height); break; case 15: case 16: if (!Settings.SixteenBit) Convert8To16 (width, height); else Scale16 (width, height); break; case 32: case 24: if (Settings.SixteenBit) { if (GUI.image->bits_per_pixel == 32) Convert16To24 (width, height); else Convert16To24Packed (width, height); } else { if (GUI.image->bits_per_pixel == 32) Convert8To24 (width, height); else Convert8To24Packed (width, height); } break; } } if (GUI.image_needs_scaling) { GUI.box.width = GUI.window_width; GUI.box.height = GUI.window_height; } else { GUI.box.width = width; GUI.box.height = height; }#ifdef USE_DGA_EXTENSION if (XF86.is_full_screen && !done) { if (XF86.scale) GUI.image_date = (uint8 *) XF86.vram; else GUI.image_date = (uint8 *) XF86.vram + ((XF86.window_width - width) / 2) * GUI.bytes_per_pixel + ((XF86.window_height - height) / 2) * GUI.bytes_per_line; for (int y = 0; y < snes_height; y++) { memmove (GUI.image_date + y * GUI.bytes_per_line, GFX.Screen + GFX.Pitch * y, snes_width * GUI.bytes_per_pixel); } }#endif#ifdef USE_DGA_EXTENSION if (!XF86.is_full_screen) {#endif#ifdef MITSHM if(GUI.use_shared_memory) XShmPutImage (GUI.display, GUI.window, GUI.gc, GUI.image, 0, 0, GUI.box.x, GUI.box.y, GUI.box.width, GUI.box.height, False); else#endif XPutImage (GUI.display, GUI.window, GUI.gc, GUI.image, 0, 0, GUI.box.x, GUI.box.y, GUI.box.width, GUI.box.height);#ifdef USE_DGA_EXTENSION }#endif GUI.last_snes_width = snes_width; GUI.last_snes_height = snes_height; if (GUI.box.x != GUI.old_box.x || GUI.box.y != GUI.old_box.y || GUI.box.width != GUI.old_box.width || GUI.box.height != GUI.old_box.height) { // If the rendered image has changed size/position clear any areas of the // screen that should now be border Region old_box = XCreateRegion (); Region new_box = XCreateRegion (); XUnionRectWithRegion (&GUI.old_box, old_box, old_box); XUnionRectWithRegion (&GUI.box, new_box, new_box); XSubtractRegion (old_box, new_box, old_box); if (!XEmptyRegion (old_box)) { Window window = GUI.window; XRectangle clip; XClipBox (old_box, &clip); XSetRegion (GUI.display, GUI.gc, old_box); XSetForeground (GUI.display, GUI.gc, GUI.depth == 8 ? 0 : BlackPixelOfScreen (GUI.screen));#ifdef USE_DGA_EXTENSION if (XF86.full_screen_available) window = XF86.fs_window;#endif XFillRectangle (GUI.display, window, GUI.gc, clip.x, clip.y, clip.width, clip.height); XSetClipMask (GUI.display, GUI.gc, None); } XDestroyRegion (new_box); XDestroyRegion (old_box); GUI.old_box = GUI.box; } Window root, child; int root_x, root_y; int x, y; unsigned int mask; // Use QueryPointer to sync X server and as a side effect also gets // current pointer position for SNES mouse emulation. XQueryPointer (GUI.display, GUI.window, &root, &child, &root_x, &root_y, &x, &y, &mask); if (IPPU.Controller == SNES_SUPERSCOPE) { if (!GUI.superscope) { XDefineCursor (GUI.display, GUI.window, GUI.cross_hair_cursor);#ifdef USE_DGA_EXTENSION if (XF86.is_full_screen) XDefineCursor (GUI.display, GUI.window, GUI.cross_hair_cursor);#endif GUI.superscope = TRUE; } } else if (GUI.superscope) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -