|
|
1.1 root 1: /*
2: * UAE - The Un*x Amiga Emulator
3: *
1.1.1.4 root 4: * SDL graphics support
1.1 root 5: *
6: * Copyright 2001 Bernd Lachner (EMail: [email protected])
1.1.1.4 root 7: * Copyright 2003-2006 Richard Drummond
1.1 root 8: *
9: * Partialy based on the UAE X interface (xwin.c)
10: *
11: * Copyright 1995, 1996 Bernd Schmidt
12: * Copyright 1996 Ed Hanway, Andre Beck, Samuel Devulder, Bruno Coste
13: * Copyright 1998 Marcus Sundberg
14: * DGA support by Kai Kollmorgen
15: * X11/DGA merge, hotkeys and grabmouse by Marcus Sundberg
16: */
17:
18: #include "sysconfig.h"
19: #include "sysdeps.h"
20:
21: #include <signal.h>
1.1.1.4 root 22: #include <SDL.h>
23: #include <SDL_endian.h>
1.1 root 24:
25: #include "options.h"
26: #include "uae.h"
27: #include "xwin.h"
28: #include "custom.h"
29: #include "drawing.h"
30: #include "keyboard.h"
31: #include "keybuf.h"
32: #include "gui.h"
33: #include "debug.h"
34: #include "picasso96.h"
1.1.1.4 root 35: #include "inputdevice.h"
36: #include "hotkeys.h"
37: #include "sdlgfx.h"
1.1 root 38:
39: /* Uncomment for debugging output */
1.1.1.4 root 40: //#define DEBUG
41: #ifdef DEBUG
42: #define DEBUG_LOG write_log
1.1 root 43: #else
1.1.1.4 root 44: #define DEBUG_LOG(...) do ; while(0)
1.1 root 45: #endif
46:
1.1.1.4 root 47: static SDL_Surface *display;
48: static SDL_Surface *screen;
1.1 root 49:
1.1.1.4 root 50: /* Standard P96 screen modes */
51: #define MAX_SCREEN_MODES 12
1.1 root 52: static int x_size_table[MAX_SCREEN_MODES] = { 320, 320, 320, 320, 640, 640, 640, 800, 1024, 1152, 1280 };
1.1.1.4 root 53: static int y_size_table[MAX_SCREEN_MODES] = { 200, 240, 256, 400, 350, 480, 512, 600, 768, 864, 1024 };
54:
1.1 root 55: static int red_bits, green_bits, blue_bits;
56: static int red_shift, green_shift, blue_shift;
57:
1.1.1.4 root 58: #ifdef PICASSO96
1.1 root 59: static char picasso_invalid_lines[1201];
60: static int picasso_has_invalid_lines;
61: static int picasso_invalid_start, picasso_invalid_stop;
62: static int picasso_maxw = 0, picasso_maxh = 0;
1.1.1.4 root 63: #endif
1.1 root 64:
65: static int bitdepth, bit_unit;
66: static int current_width, current_height;
67:
1.1.1.4 root 68: /* If we have to lock the SDL surface, then we remember the address
69: * of its pixel data - and recalculate the row maps only when this
70: * address changes */
71: static void *old_pixels;
1.1 root 72:
1.1.1.4 root 73: static SDL_Color arSDLColors[256];
74: #ifdef PICASSO96
75: static SDL_Color p96Colors[256];
76: #endif
77: static int ncolors;
1.1 root 78:
1.1.1.5 ! root 79: static int fullscreen, prev_fullscreen;
1.1.1.4 root 80: static int mousegrab;
1.1 root 81:
1.1.1.4 root 82: static int is_hwsurface;
1.1 root 83:
1.1.1.4 root 84: static int have_rawkeys;
1.1 root 85:
1.1.1.4 root 86: /* This isn't supported yet.
87: * gui_handle_events() needs to be reworked fist
88: */
89: int pause_emulation;
1.1 root 90:
1.1.1.4 root 91: #ifdef __cplusplus
92: static RETSIGTYPE sigbrkhandler(...)
93: #else
94: static RETSIGTYPE sigbrkhandler (int foo)
95: #endif
1.1 root 96: {
1.1.1.4 root 97: activate_debugger();
98: #if !defined(__unix) || defined(__NeXT__)
99: signal (SIGINT, sigbrkhandler);
1.1 root 100: #endif
101: }
102:
1.1.1.4 root 103: void setup_brkhandler (void)
1.1 root 104: {
1.1.1.4 root 105: #if defined(__unix) && !defined(__NeXT__)
106: struct sigaction sa;
107: sa.sa_handler = sigbrkhandler;
108: sa.sa_flags = 0;
109: #ifdef SA_RESTART
110: sa.sa_flags = SA_RESTART;
111: #endif
112: sigemptyset (&sa.sa_mask);
113: sigaction (SIGINT, &sa, NULL);
114: #else
115: signal (SIGINT, sigbrkhandler);
1.1 root 116: #endif
117: }
118:
1.1.1.4 root 119: /*
120: * What graphics platform are we running on . . .?
121: *
122: * Yes, SDL is supposed to abstract away from the underlying
123: * platform, but we need to know this to be able to map raw keys
124: * and to work around any platform-specific quirks . . .
125: */
126: int get_sdlgfx_type (void)
127: {
128: char name[16] = "";
129: static int driver = SDLGFX_DRIVER_UNKNOWN;
130: static int search_done = 0;
131:
132: if (!search_done) {
133: if (SDL_VideoDriverName (name, sizeof name)) {
134: if (strcmp (name, "x11")==0)
135: driver = SDLGFX_DRIVER_X11;
136: else if (strcmp (name, "dga") == 0)
137: driver = SDLGFX_DRIVER_DGA;
138: else if (strcmp (name, "svgalib") == 0)
139: driver = SDLGFX_DRIVER_SVGALIB;
140: else if (strcmp (name, "fbcon") == 0)
141: driver = SDLGFX_DRIVER_FBCON;
142: else if (strcmp (name, "directfb") == 0)
143: driver = SDLGFX_DRIVER_DIRECTFB;
144: else if (strcmp (name, "Quartz") == 0)
145: driver = SDLGFX_DRIVER_QUARTZ;
146: else if (strcmp (name, "bwindow") == 0)
147: driver = SDLGFX_DRIVER_BWINDOW;
148: else if (strcmp (name, "CGX") == 0)
149: driver = SDLGFX_DRIVER_CYBERGFX;
150: else if (strcmp (name, "OS4") == 0)
151: driver = SDLGFX_DRIVER_AMIGAOS4;
152: }
153: search_done = 1;
1.1 root 154:
1.1.1.4 root 155: DEBUG_LOG ("SDL video driver: %s\n", name);
156: }
157: return driver;
1.1 root 158: }
159:
1.1.1.4 root 160: STATIC_INLINE unsigned long bitsInMask (unsigned long mask)
1.1 root 161: {
1.1.1.4 root 162: /* count bits in mask */
163: unsigned long n = 0;
164: while (mask) {
165: n += mask & 1;
166: mask >>= 1;
167: }
168: return n;
1.1 root 169: }
170:
1.1.1.4 root 171: STATIC_INLINE unsigned long maskShift (unsigned long mask)
1.1 root 172: {
1.1.1.4 root 173: /* determine how far mask is shifted */
174: unsigned long n = 0;
175: while (!(mask & 1)) {
176: n++;
177: mask >>= 1;
178: }
179: return n;
1.1 root 180: }
181:
182: static int get_color (int r, int g, int b, xcolnr *cnp)
183: {
1.1.1.4 root 184: DEBUG_LOG ("Function: get_color\n");
1.1 root 185:
1.1.1.4 root 186: arSDLColors[ncolors].r = r << 4;
187: arSDLColors[ncolors].g = g << 4;
188: arSDLColors[ncolors].b = b << 4;
189: *cnp = ncolors++;
190: return 1;
1.1 root 191: }
192:
193: static int init_colors (void)
194: {
1.1.1.4 root 195: int i;
1.1 root 196:
1.1.1.4 root 197: DEBUG_LOG ("Function: init_colors\n");
1.1 root 198:
1.1.1.4 root 199: if (bitdepth > 8) {
200: red_bits = bitsInMask (display->format->Rmask);
201: green_bits = bitsInMask (display->format->Gmask);
202: blue_bits = bitsInMask (display->format->Bmask);
203: red_shift = maskShift (display->format->Rmask);
204: green_shift = maskShift (display->format->Gmask);
205: blue_shift = maskShift (display->format->Bmask);
206:
207: alloc_colors64k (red_bits, green_bits, blue_bits, red_shift, green_shift, blue_shift);
208: } else {
209: alloc_colors256 (get_color);
210: SDL_SetColors (screen, arSDLColors, 0, 256);
211: }
1.1 root 212:
1.1.1.4 root 213: return 1;
214: }
215:
216:
217: /*
218: * Test whether the screen mode <width>x<height>x<depth> is
219: * available. If not, find a supported screen mode which best
220: * matches.
221: */
222: static int find_best_mode (int *width, int *height, int depth, int *try_fs)
223: {
224: int found = 0;
225:
226: DEBUG_LOG ("Function: find_best_mode(%d,%d,%d)\n", *width, *height, depth);
227:
228: restart:
229: /* First test whether the specified mode is supported */
230: found = SDL_VideoModeOK (*width, *height, depth, *try_fs ? SDL_FULLSCREEN : 0);
231:
1.1.1.5 ! root 232: if (!found && n_fullscreen_modes > 0) {
1.1.1.4 root 233: /* The specified mode wasn't available, so we'll try and find
234: * a supported resolution which best matches it.
235: */
236: int i;
237: write_log ("SDLGFX: Requested mode (%dx%d%d) not available.\n", *width, *height, depth);
238:
1.1.1.5 ! root 239: for (i = 0; i < n_fullscreen_modes; i--) {
! 240: if (gfx_fullscreen_modes[i].w >= *width && gfx_fullscreen_modes[i].h >= *height)
1.1 root 241: break;
242: }
1.1.1.4 root 243:
244: /* If we didn't find a mode, use the largest supported mode */
1.1.1.5 ! root 245: if (i == n_fullscreen_modes)
! 246: i = n_fullscreen_modes - 1;
1.1.1.4 root 247:
1.1.1.5 ! root 248: *width = gfx_fullscreen_modes[i].w;
! 249: *height = gfx_fullscreen_modes[i].h;
! 250: found = 1;
1.1.1.4 root 251:
252: write_log ("SDLGFX: Using mode (%dx%d)\n", *width, *height);
253: }
254: if (!found && *try_fs) {
255: *try_fs = 0;
256: goto restart;
257: }
258: return found;
259: }
260:
261: #ifdef PICASSO96
262: /*
263: * Map an SDL pixel format to a P96 pixel format
264: */
265: static int get_p96_pixel_format (const struct SDL_PixelFormat *fmt)
266: {
267: if (fmt->BitsPerPixel == 8)
268: return RGBFB_CLUT;
269:
270: #ifdef WORDS_BIGENDIAN
271: if (fmt->BitsPerPixel == 24) {
272: if (fmt->Rmask == 0x00FF0000 && fmt->Gmask == 0x0000FF00 && fmt->Bmask == 0x000000FF)
273: return RGBFB_R8G8B8;
274: if (fmt->Rmask == 0x000000FF && fmt->Gmask == 0x0000FF00 && fmt->Bmask == 0x00FF0000)
275: return RGBFB_B8G8R8;
276: } else if (fmt->BitsPerPixel == 32) {
277: if (fmt->Rmask == 0xFF000000 && fmt->Gmask == 0x00FF0000 && fmt->Bmask == 0x0000FF00)
278: return RGBFB_R8G8B8A8;
279: if (fmt->Rmask == 0x00FF0000 && fmt->Gmask == 0x0000FF00 && fmt->Bmask == 0x000000FF)
280: return RGBFB_A8R8G8B8;
281: if (fmt->Bmask == 0x00FF0000 && fmt->Gmask == 0x0000FF00 && fmt->Rmask == 0x000000FF)
282: return RGBFB_A8B8G8R8;
283: if (fmt->Bmask == 0xFF000000 && fmt->Gmask == 0x00FF0000 && fmt->Rmask == 0x0000FF00)
284: return RGBFB_B8G8R8A8;
285: } else if (fmt->BitsPerPixel == 16) {
286: if (get_sdlgfx_type () == SDLGFX_DRIVER_QUARTZ) {
287: /* The MacOS X port of SDL lies about it's default pixel format
288: * for high-colour display. It's always R5G5B5. */
289: return RGBFB_R5G5B5;
290: } else {
291: if (fmt->Rmask == 0xf800 && fmt->Gmask == 0x07e0 && fmt->Bmask == 0x001f)
292: return RGBFB_R5G6B5;
293: if (fmt->Rmask == 0x7C00 && fmt->Gmask == 0x03e0 && fmt->Bmask == 0x001f)
294: return RGBFB_R5G5B5;
1.1 root 295: }
1.1.1.4 root 296: } else if (fmt->BitsPerPixel == 15) {
297: if (fmt->Rmask == 0x7C00 && fmt->Gmask == 0x03e0 && fmt->Bmask == 0x001f)
298: return RGBFB_R5G5B5;
299: }
300: #else
301: if (fmt->BitsPerPixel == 24) {
302: if (fmt->Rmask == 0x00FF0000 && fmt->Gmask == 0x0000FF00 && fmt->Bmask == 0x000000FF)
303: return RGBFB_B8G8R8;
304: if (fmt->Rmask == 0x000000FF && fmt->Gmask == 0x0000FF00 && fmt->Bmask == 0x00FF0000)
305: return RGBFB_R8G8B8;
306: } else if (fmt->BitsPerPixel == 32) {
307: if (fmt->Rmask == 0xFF000000 && fmt->Gmask == 0x00FF0000 && fmt->Bmask == 0x0000FF00)
308: return RGBFB_A8B8G8R8;
309: if (fmt->Rmask == 0x00FF0000 && fmt->Gmask == 0x0000FF00 && fmt->Bmask == 0x000000FF)
310: return RGBFB_B8G8R8A8;
311: if (fmt->Bmask == 0x00FF0000 && fmt->Gmask == 0x0000FF00 && fmt->Rmask == 0x000000FF)
312: return RGBFB_R8G8B8A8;
313: if (fmt->Bmask == 0xFF000000 && fmt->Gmask == 0x00FF0000 && fmt->Rmask == 0x0000FF00)
314: return RGBFB_A8R8G8B8;
315: } else if (fmt->BitsPerPixel == 16) {
316: if (fmt->Rmask == 0xf800 && fmt->Gmask == 0x07e0 && fmt->Bmask == 0x001f)
317: return RGBFB_R5G6B5PC;
318: if (fmt->Rmask == 0x7C00 && fmt->Gmask == 0x03e0 && fmt->Bmask == 0x001f)
319: return RGBFB_R5G5B5PC;
320: } else if (fmt->BitsPerPixel == 15) {
321: if (fmt->Rmask == 0x7C00 && fmt->Gmask == 0x03e0 && fmt->Bmask == 0x001f)
322: return RGBFB_R5G5B5PC;
323: }
324: #endif
325:
326: return RGBFB_NONE;
1.1 root 327: }
1.1.1.4 root 328: #endif
1.1 root 329:
1.1.1.4 root 330: /*
331: * Build list of full-screen screen-modes supported by SDL
332: * with the specified pixel format.
333: *
334: * Returns a count of the number of supported modes, -1 if any mode is supported,
335: * or 0 if there are no modes with this pixel format.
336: */
1.1.1.5 ! root 337: static void find_screen_modes (struct SDL_PixelFormat *vfmt)
1.1.1.4 root 338: {
339: long count = 0;
340: SDL_Rect **modes = SDL_ListModes (vfmt, SDL_FULLSCREEN | SDL_HWSURFACE);
341:
342: if (modes != 0 && modes != (SDL_Rect**)-1) {
343: unsigned int i;
344: int w = -1;
345: int h = -1;
346:
347: /* Filter list of modes SDL gave us and ignore duplicates */
1.1.1.5 ! root 348: for (i = 0; modes[i]; i++)
! 349: if (modes[i]->w != w || modes[i]->h != h) {
! 350: count++;
! 351: h = modes[i]->h;
! 352: w = modes[i]->w;
! 353: }
! 354:
! 355: gfx_fullscreen_modes = malloc (sizeof (struct uae_rect) * count);
! 356: n_fullscreen_modes = count;
! 357:
! 358: w = h = -1;
! 359: for (i = count = 0; count < n_fullscreen_modes; i++) {
1.1.1.4 root 360: if (modes[i]->w != w || modes[i]->h != h) {
1.1.1.5 ! root 361: /* Fill the array in reverse, as SDL gives us a list of
! 362: screenmodes sorted largest to smallest. */
! 363: gfx_fullscreen_modes[n_fullscreen_modes - 1 - count].w = w = modes[i]->w;
! 364: gfx_fullscreen_modes[n_fullscreen_modes - 1 - count].h = h = modes[i]->h;
1.1.1.4 root 365: count++;
366:
367: write_log ("SDLGFX: Found screenmode: %dx%d.\n", w, h);
368: }
369: }
1.1.1.5 ! root 370: }
1.1.1.4 root 371: }
372:
373: /**
374: ** Buffer methods for SDL surfaces that must be locked
375: **/
376:
377: int lockscr (void)
1.1 root 378: {
1.1.1.4 root 379: int success = 0;
1.1 root 380:
1.1.1.4 root 381: if (!SDL_MUSTLOCK (screen))
382: return 1;
383:
384: if (SDL_LockSurface (display) == 0) {
385: gfxvidinfo.bufmem = display->pixels;
386: gfxvidinfo.rowbytes = display->pitch;
387:
388: if (display->pixels != old_pixels) {
389: /* If the address of the pixel data has
390: * changed, recalculate the row maps
391: */
392: init_row_map ();
393: old_pixels = display->pixels;
394: }
395: success = 1;
1.1 root 396: }
1.1.1.4 root 397: return success;
398: }
1.1 root 399:
1.1.1.4 root 400: void unlockscr (void)
401: {
402: if (SDL_MUSTLOCK (screen))
403: SDL_UnlockSurface (display);
1.1 root 404: }
405:
1.1.1.4 root 406: void flush_block (int first_line, int last_line)
407: {
408: // DEBUG_LOG ("Function: flush_block %d %d\n", first_line, last_line);
409:
410: SDL_UpdateRect (display, 0, first_line, current_width, last_line - first_line + 1);
411: }
1.1 root 412:
1.1.1.4 root 413: void flush_screen (int first_line, int last_line)
1.1 root 414: {
1.1.1.4 root 415: if (! (screen->flags & SDL_DOUBLEBUF))
416: return;
1.1 root 417:
1.1.1.4 root 418: SDL_BlitSurface (display,0,screen,0);
1.1 root 419:
1.1.1.4 root 420: SDL_Flip (screen);
421: }
1.1 root 422:
1.1.1.4 root 423: void flush_line (int line)
424: {
1.1 root 425: }
426:
1.1.1.4 root 427: int graphics_setup (void)
428: {
429: int result = 0;
1.1 root 430:
1.1.1.4 root 431: if (SDL_InitSubSystem (SDL_INIT_VIDEO) == 0) {
432: const SDL_version *version = SDL_Linked_Version ();
433: const SDL_VideoInfo *info = SDL_GetVideoInfo ();
434:
435: write_log ("SDLGFX: Initialized.\n");
436: write_log ("SDLGFX: Using SDL version %d.%d.%d.\n", version->major, version->minor, version->patch);
437:
438: /* Find default display depth */
439: bitdepth = info->vfmt->BitsPerPixel;
440: bit_unit = info->vfmt->BytesPerPixel * 8;
441:
442: write_log ("SDLGFX: Display is %d bits deep.\n", bitdepth);
443:
444: /* Build list of screenmodes */
1.1.1.5 ! root 445: find_screen_modes (info->vfmt);
1.1.1.4 root 446:
447: result = 1;
448: } else
449: write_log ("SDLGFX: initialization failed - %s\n", SDL_GetError());
450:
451: return result;
452: }
453:
1.1.1.5 ! root 454: int graphics_subinit (void)
1.1 root 455: {
1.1.1.4 root 456: Uint32 uiSDLVidModFlags = 0;
1.1 root 457:
1.1.1.4 root 458: DEBUG_LOG ("Function: graphics_subinit\n");
1.1 root 459:
1.1.1.4 root 460: if (screen_is_picasso) {
461: // Set height, width for Picasso gfx
462: current_width = picasso_vidinfo.width;
463: current_height = picasso_vidinfo.height;
464: fullscreen = currprefs.gfx_pfullscreen;
465: curr_gfx = 0;
466: } else {
467: // Set height, width for Amiga gfx
468: fullscreen = currprefs.gfx_afullscreen;
469: if (fullscreen)
470: curr_gfx = &currprefs.gfx_f;
471: else
472: curr_gfx = &currprefs.gfx_w;
1.1.1.5 ! root 473:
1.1.1.4 root 474: current_width = curr_gfx->width;
475: current_height = curr_gfx->height;
476: }
477: find_best_mode (¤t_width, ¤t_height, bitdepth, &fullscreen);
478: if (!screen_is_picasso) {
479: gfxvidinfo.width = current_width;
480: gfxvidinfo.height = current_height;
481: }
1.1 root 482:
1.1.1.5 ! root 483: if (!fullscreen && prev_fullscreen) {
! 484: struct uae_rect *biggest = gfx_fullscreen_modes + n_fullscreen_modes - 1;
! 485: /* Try switching back to the previous screenmode. */
! 486: SDL_SetVideoMode (biggest->w, biggest->h, bitdepth, SDL_FULLSCREEN);
! 487: }
! 488:
1.1.1.4 root 489: if (bitdepth == 8)
490: uiSDLVidModFlags |= SDL_HWPALETTE;
491: if (fullscreen) {
492: uiSDLVidModFlags |= SDL_FULLSCREEN | SDL_HWSURFACE;
493: if(!screen_is_picasso && 0 /*currprefs.gfx_vsync */)
494: uiSDLVidModFlags |= SDL_DOUBLEBUF;
495: }
1.1 root 496:
1.1.1.4 root 497: DEBUG_LOG ("Resolution: %d x %d x %d (FS: %d)\n", current_width, current_height, bitdepth, fullscreen);
1.1 root 498:
1.1.1.4 root 499: screen = SDL_SetVideoMode (current_width, current_height, bitdepth, uiSDLVidModFlags);
1.1 root 500:
1.1.1.4 root 501: if (screen == NULL) {
502: #if 0
503: gui_message ("Unable to set video mode: %s\n", SDL_GetError ());
504: #endif
505: return 0;
506: } else {
507: /* Just in case we didn't get exactly what we asked for . . . */
508: fullscreen = ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN);
509: is_hwsurface = ((screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE);
510:
511: /* Are these values what we expected? */
512: # ifdef PICASSO96
513: DEBUG_LOG ("P96 screen? : %d\n", screen_is_picasso);
514: # endif
515: DEBUG_LOG ("Fullscreen? : %d\n", fullscreen);
516: DEBUG_LOG ("Mouse grabbed? : %d\n", mousegrab);
517: DEBUG_LOG ("HW surface? : %d\n", is_hwsurface);
518: DEBUG_LOG ("Must lock? : %d\n", SDL_MUSTLOCK (screen));
519: DEBUG_LOG ("Bytes per Pixel: %d\n", screen->format->BytesPerPixel);
520: DEBUG_LOG ("Bytes per Line : %d\n", screen->pitch);
521:
522: /* Set up buffer methods */
523:
524: if (screen->flags & SDL_DOUBLEBUF) {
525: display = SDL_CreateRGBSurface(SDL_HWSURFACE, screen->w, screen->h, screen->format->BitsPerPixel,
526: screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, 0);
1.1 root 527:
1.1.1.4 root 528: } else {
529: display = screen;
1.1 root 530: }
531:
1.1.1.4 root 532: /* Set UAE window title and icon name */
533: SDL_WM_SetCaption (PACKAGE_NAME, PACKAGE_NAME);
534:
535: /* Mouse is now always grabbed when full-screen - to work around
536: * problems with full-screen mouse input in some SDL implementations */
537: if (fullscreen)
538: SDL_WM_GrabInput (SDL_GRAB_ON);
539: else
540: SDL_WM_GrabInput (mousegrab ? SDL_GRAB_ON : SDL_GRAB_OFF);
541:
542: /* Hide mouse cursor */
543: SDL_ShowCursor (/*currprefs.hide_cursor || */fullscreen || mousegrab ? SDL_DISABLE : SDL_ENABLE);
544:
545: inputdevice_release_all_keys ();
546: reset_hotkeys ();
547:
1.1.1.5 ! root 548: bit_unit = display->format->BytesPerPixel * 8;
! 549:
1.1.1.4 root 550: #ifdef PICASSO96
551: if (!screen_is_picasso) {
552: #endif
553: /* Initialize structure for Amiga video modes */
554: if (is_hwsurface) {
555: SDL_LockSurface (display);
556: gfxvidinfo.bufmem = 0;
557: gfxvidinfo.emergmem = malloc (display->pitch);
558: gfxvidinfo.maxblocklines = 0;
559: SDL_UnlockSurface (display);
560: }
561:
562: if (!is_hwsurface) {
563: gfxvidinfo.bufmem = display->pixels;
564: gfxvidinfo.emergmem = 0;
565: gfxvidinfo.maxblocklines = gfxvidinfo.height;
566: }
567: gfxvidinfo.linemem = 0;
1.1.1.5 ! root 568: gfxvidinfo.pixbytes = bit_unit >> 3;
1.1.1.4 root 569: gfxvidinfo.rowbytes = display->pitch;
570:
1.1 root 571:
1.1.1.4 root 572: SDL_SetColors (display, arSDLColors, 0, 256);
1.1 root 573:
1.1.1.4 root 574: /* Force recalculation of row maps - if we're locking */
575: old_pixels = (void *)-1;
576: #ifdef PICASSO96
577: } else {
578: /* Initialize structure for Picasso96 video modes */
1.1.1.5 ! root 579: picasso_vidinfo.pixbytes = bit_unit >> 3;
1.1.1.4 root 580: picasso_vidinfo.rowbytes = display->pitch;
581: picasso_vidinfo.extra_mem = 1;
582: picasso_vidinfo.depth = bitdepth;
583: picasso_has_invalid_lines = 0;
584: picasso_invalid_start = picasso_vidinfo.height + 1;
585: picasso_invalid_stop = -1;
586:
587: memset (picasso_invalid_lines, 0, sizeof picasso_invalid_lines);
588: }
589: #endif
590: }
1.1 root 591:
592: return 1;
593: }
594:
1.1.1.4 root 595: int graphics_init (void)
1.1 root 596: {
1.1.1.4 root 597: int success = 0;
598:
599: DEBUG_LOG ("Function: graphics_init\n");
600:
601: if (currprefs.color_mode > 5) {
602: write_log ("Bad color mode selected. Using default.\n");
603: currprefs.color_mode = 0;
604: }
605:
606: #ifdef PICASSO96
607: screen_is_picasso = 0;
1.1 root 608: #endif
1.1.1.4 root 609: mousegrab = 0;
610:
1.1.1.5 ! root 611: fixup_prefs_dimensions (&currprefs.gfx_w, gfx_windowed_modes, n_windowed_modes);
! 612: fixup_prefs_dimensions (&currprefs.gfx_f, gfx_fullscreen_modes, n_fullscreen_modes);
1.1 root 613:
1.1.1.4 root 614: if (graphics_subinit ()) {
615: if (init_colors ()) {
616: success = 1;
617: }
618: }
619: return success;
1.1 root 620: }
621:
1.1.1.5 ! root 622: void graphics_subshutdown (int final)
1.1 root 623: {
1.1.1.4 root 624: DEBUG_LOG ("Function: graphics_subshutdown\n");
1.1 root 625:
1.1.1.4 root 626: if (display && display != screen)
627: SDL_FreeSurface (display);
1.1 root 628:
1.1.1.4 root 629: /* XRandR requires that clients sometimes have to retry a request for
630: changing screen size, which SDL doesn't do. Work around the problem
631: by reinitializing SDL. */
632: SDL_QuitSubSystem (SDL_INIT_VIDEO);
633: SDL_InitSubSystem (SDL_INIT_VIDEO);
1.1.1.5 ! root 634:
! 635: prev_fullscreen = fullscreen;
! 636:
! 637: if (final && prev_fullscreen) {
! 638: struct uae_rect *biggest = gfx_fullscreen_modes + n_fullscreen_modes - 1;
1.1.1.4 root 639: /* Try switching back to the previous screenmode. */
1.1.1.5 ! root 640: SDL_SetVideoMode (biggest->w, biggest->h, bitdepth, SDL_FULLSCREEN);
! 641: }
1.1 root 642:
1.1.1.4 root 643: display = screen = 0;
1.1 root 644:
1.1.1.4 root 645: if (gfxvidinfo.emergmem) {
646: free (gfxvidinfo.emergmem);
647: gfxvidinfo.emergmem = 0;
1.1 root 648: }
1.1.1.4 root 649: }
650:
651: void graphics_leave (void)
652: {
653: DEBUG_LOG ("Function: graphics_leave\n");
654:
655: graphics_subshutdown (1);
656: SDL_QuitSubSystem (SDL_INIT_VIDEO);
657: dumpcustom ();
1.1 root 658: }
659:
660: static int refresh_necessary = 0;
661:
662: void handle_events (void)
663: {
664: SDL_Event rEvent;
665:
666: gui_handle_events ();
667:
1.1.1.4 root 668: while (SDL_PollEvent (&rEvent)) {
669: switch (rEvent.type) {
1.1.1.5 ! root 670: case SDL_QUIT:
! 671: DEBUG_LOG ("Event: quit\n");
! 672: uae_quit ();
! 673: break;
! 674:
! 675: case SDL_MOUSEBUTTONDOWN:
! 676: case SDL_MOUSEBUTTONUP: {
! 677: int state = (rEvent.type == SDL_MOUSEBUTTONDOWN);
! 678: int buttonno = -1;
! 679:
! 680: DEBUG_LOG ("Event: mouse button %d %s\n", rEvent.button.button, state ? "down" : "up");
! 681:
! 682: switch (rEvent.button.button) {
! 683: case SDL_BUTTON_LEFT: buttonno = 0; break;
! 684: case SDL_BUTTON_MIDDLE: buttonno = 2; break;
! 685: case SDL_BUTTON_RIGHT: buttonno = 1; break;
1.1.1.4 root 686: #ifdef SDL_BUTTON_WHEELUP
1.1.1.5 ! root 687: case SDL_BUTTON_WHEELUP: if (state) record_key (0x7a << 1); break;
! 688: case SDL_BUTTON_WHEELDOWN: if (state) record_key (0x7b << 1); break;
1.1 root 689: #endif
690: }
1.1.1.5 ! root 691: if (buttonno >= 0)
! 692: setmousebuttonstate (0, buttonno, rEvent.type == SDL_MOUSEBUTTONDOWN ? 1:0);
! 693: break;
! 694: }
1.1.1.4 root 695:
1.1.1.5 ! root 696: case SDL_KEYUP:
! 697: case SDL_KEYDOWN: {
! 698: int state = (rEvent.type == SDL_KEYDOWN);
! 699: int keycode;
! 700: int ievent;
! 701:
! 702: keycode = rEvent.key.keysym.sym;
! 703:
! 704: DEBUG_LOG ("Event: key %d %s\n", keycode, state ? "down" : "up");
! 705:
! 706: if ((ievent = match_hotkey_sequence (keycode, state))) {
! 707: DEBUG_LOG ("Hotkey event: %d\n", ievent);
! 708: handle_hotkey_event (ievent, state);
! 709: } else {
! 710: inputdevice_do_keyboard (keysym2amiga (keycode), state);
1.1 root 711: }
1.1.1.5 ! root 712: break;
! 713: }
1.1.1.4 root 714:
1.1.1.5 ! root 715: case SDL_MOUSEMOTION:
! 716: //DEBUG_LOG ("Event: mouse motion\n");
1.1.1.4 root 717:
1.1.1.5 ! root 718: if (!fullscreen && !mousegrab) {
! 719: setmousestate (0, 0,rEvent.motion.x, 1);
! 720: setmousestate (0, 1,rEvent.motion.y, 1);
! 721: } else {
! 722: setmousestate (0, 0, rEvent.motion.xrel, 0);
! 723: setmousestate (0, 1, rEvent.motion.yrel, 0);
! 724: }
! 725: break;
1.1.1.4 root 726:
1.1.1.5 ! root 727: case SDL_ACTIVEEVENT:
! 728: if (rEvent.active.state & SDL_APPINPUTFOCUS && !rEvent.active.gain) {
! 729: DEBUG_LOG ("Lost input focus\n");
! 730: inputdevice_release_all_keys ();
! 731: reset_hotkeys ();
! 732: }
! 733: break;
1.1.1.4 root 734: } /* end switch() */
735: } /* end while() */
736:
737: #ifdef PICASSO96
738: if (screen_is_picasso && refresh_necessary) {
739: SDL_UpdateRect (screen, 0, 0, picasso_vidinfo.width, picasso_vidinfo.height);
1.1 root 740: refresh_necessary = 0;
741: memset (picasso_invalid_lines, 0, sizeof picasso_invalid_lines);
1.1.1.4 root 742: } else if (screen_is_picasso && picasso_has_invalid_lines) {
1.1 root 743: int i;
744: int strt = -1;
745: picasso_invalid_lines[picasso_vidinfo.height] = 0;
1.1.1.4 root 746: for (i = picasso_invalid_start; i < picasso_invalid_stop + 2; i++) {
747: if (picasso_invalid_lines[i]) {
1.1 root 748: picasso_invalid_lines[i] = 0;
749: if (strt != -1)
750: continue;
751: strt = i;
1.1.1.4 root 752: } else {
1.1 root 753: if (strt == -1)
754: continue;
1.1.1.4 root 755: SDL_UpdateRect (screen, 0, strt, picasso_vidinfo.width, i - strt);
1.1 root 756: strt = -1;
757: }
758: }
759: if (strt != -1)
760: abort ();
761: }
762: picasso_has_invalid_lines = 0;
763: picasso_invalid_start = picasso_vidinfo.height + 1;
764: picasso_invalid_stop = -1;
765: #endif
1.1.1.4 root 766: }
1.1 root 767:
1.1.1.4 root 768: static void switch_keymaps (void)
769: {
770: set_default_hotkeys (get_default_cooked_hotkeys ());
1.1 root 771: }
772:
773: int debuggable (void)
774: {
775: return 1;
776: }
777:
778: int needmousehack (void)
779: {
780: return 1;
781: }
782:
1.1.1.4 root 783: int mousehack_allowed (void)
1.1 root 784: {
1.1.1.4 root 785: return 1;
786: }
1.1 root 787:
1.1.1.4 root 788: void LED (int on)
789: {
1.1 root 790: }
791:
792: #ifdef PICASSO96
793:
794: void DX_Invalidate (int first, int last)
795: {
1.1.1.4 root 796: DEBUG_LOG ("Function: DX_Invalidate %i - %i\n", first, last);
797:
798: if (is_hwsurface)
799: return;
1.1 root 800:
801: if (first > last)
802: return;
803:
804: picasso_has_invalid_lines = 1;
805: if (first < picasso_invalid_start)
806: picasso_invalid_start = first;
807: if (last > picasso_invalid_stop)
808: picasso_invalid_stop = last;
809:
1.1.1.4 root 810: while (first <= last) {
1.1 root 811: picasso_invalid_lines[first] = 1;
812: first++;
813: }
814: }
815:
816: int DX_BitsPerCannon (void)
817: {
818: return 8;
819: }
820:
1.1.1.4 root 821: static int palette_update_start = 256;
822: static int palette_update_end = 0;
1.1 root 823:
824: void DX_SetPalette (int start, int count)
825: {
1.1.1.4 root 826: DEBUG_LOG ("Function: DX_SetPalette_real\n");
1.1 root 827:
828: if (! screen_is_picasso || picasso96_state.RGBFormat != RGBFB_CHUNKY)
829: return;
830:
1.1.1.4 root 831: if (picasso_vidinfo.pixbytes != 1) {
832: /* This is the case when we're emulating a 256 color display. */
833: while (count-- > 0) {
1.1 root 834: int r = picasso96_state.CLUT[start].Red;
835: int g = picasso96_state.CLUT[start].Green;
836: int b = picasso96_state.CLUT[start].Blue;
1.1.1.4 root 837: picasso_vidinfo.clut[start++] =
838: (doMask256 (r, red_bits, red_shift)
839: | doMask256 (g, green_bits, green_shift)
840: | doMask256 (b, blue_bits, blue_shift));
1.1 root 841: }
1.1.1.4 root 842: } else {
843: int i;
844: for (i = start; i < start+count && i < 256; i++) {
845: p96Colors[i].r = picasso96_state.CLUT[i].Red;
846: p96Colors[i].g = picasso96_state.CLUT[i].Green;
847: p96Colors[i].b = picasso96_state.CLUT[i].Blue;
848: }
849: SDL_SetColors (screen, &p96Colors[start], start, count);
1.1 root 850: }
1.1.1.4 root 851: }
1.1 root 852:
853: #if 0
1.1.1.4 root 854: void DX_SetPalette_vsync(void)
855: {
856: if (palette_update_end > palette_update_start) {
857: DX_SetPalette (palette_update_start,
858: palette_update_end - palette_update_start);
859: palette_update_end = 0;
860: palette_update_start = 0;
861: }
862: }
863:
864: int DX_Fill (int dstx, int dsty, int width, int height, uae_u32 color, RGBFTYPE rgbtype)
865: {
866: int result = 0;
867: SDL_Rect rect = {dstx, dsty, width, height};
868:
869: DEBUG_LOG ("DX_Fill (x:%d y:%d w:%d h:%d color=%08x)\n", dstx, dsty, width, height, color);
870:
871: if (SDL_FillRect (screen, &rect, color) == 0) {
872: DX_Invalidate (dsty, dsty + height - 1);
873: result = 1;
1.1 root 874: }
1.1.1.4 root 875: return result;
1.1 root 876: }
877:
1.1.1.4 root 878: int DX_Blit (int srcx, int srcy, int dstx, int dsty, int width, int height, BLIT_OPCODE opcode)
1.1 root 879: {
1.1.1.4 root 880: int result = 0;
881: SDL_Rect src_rect = {srcx, srcy, width, height};
882: SDL_Rect dest_rect = {dstx, dsty, 0, 0};
1.1 root 883:
1.1.1.4 root 884: DEBUG_LOG ("DX_Blit (sx:%d sy:%d dx:%d dy:%d w:%d h:%d op:%d)\n",
885: srcx, srcy, dstx, dsty, width, height, opcode);
886:
887: if (opcode == BLIT_SRC && SDL_BlitSurface (screen, &src_rect, screen, &dest_rect) == 0) {
888: DX_Invalidate (dsty, dsty + height - 1);
889: result = 1;
890: }
891: return result;
892: }
1.1 root 893: #endif
894:
1.1.1.4 root 895: /*
896: * Add a screenmode to the emulated P96 display database
897: */
898: static void add_p96_mode (int width, int height, int emulate_chunky, int *count)
899: {
900: unsigned int i;
901:
902: for (i = 0; i <= (emulate_chunky ? 1 : 0); i++) {
903: if (*count < MAX_PICASSO_MODES) {
904: DisplayModes[*count].res.width = width;
905: DisplayModes[*count].res.height = height;
906: DisplayModes[*count].depth = (i == 1) ? 1 : bit_unit >> 3;
907: DisplayModes[*count].refresh = 75;
908: (*count)++;
909:
910: write_log ("SDLGFX: Added P96 mode: %dx%dx%d\n", width, height, (i == 1) ? 8 : bitdepth);
1.1 root 911: }
912: }
1.1.1.4 root 913: return;
914: }
1.1 root 915:
1.1.1.4 root 916: int DX_FillResolutions (uae_u16 *ppixel_format)
917: {
918: int i;
919: int count = 0;
920: int emulate_chunky = 0;
921:
922: DEBUG_LOG ("Function: DX_FillResolutions\n");
1.1 root 923:
1.1.1.4 root 924: /* Find supported pixel formats */
925: picasso_vidinfo.rgbformat = get_p96_pixel_format (SDL_GetVideoInfo()->vfmt);
1.1 root 926:
927: *ppixel_format = 1 << picasso_vidinfo.rgbformat;
1.1.1.4 root 928: if (bit_unit == 16 || bit_unit == 32) {
1.1 root 929: *ppixel_format |= RGBFF_CHUNKY;
930: emulate_chunky = 1;
931: }
932:
1.1.1.4 root 933: /* Check list of standard P96 screenmodes */
934: for (i = 0; i < MAX_SCREEN_MODES; i++) {
935: if (SDL_VideoModeOK (x_size_table[i], y_size_table[i], bitdepth,
936: SDL_HWSURFACE | SDL_FULLSCREEN)) {
937: add_p96_mode (x_size_table[i], y_size_table[i], emulate_chunky, &count);
938: }
939: }
940:
941: /* Check list of supported SDL screenmodes */
1.1.1.5 ! root 942: for (i = 0; i < n_fullscreen_modes; i++) {
1.1 root 943: int j;
1.1.1.4 root 944: int found = 0;
945: for (j = 0; j < MAX_SCREEN_MODES - 1; j++) {
1.1.1.5 ! root 946: if (gfx_fullscreen_modes[i].w == x_size_table[j] &&
! 947: gfx_fullscreen_modes[i].h == y_size_table[j])
1.1 root 948: {
1.1.1.4 root 949: found = 1;
950: break;
1.1 root 951: }
952: }
1.1.1.4 root 953:
954: /* If SDL mode is not a standard P96 mode (and thus already added to the
955: * list, above) then add it */
956: if (!found)
1.1.1.5 ! root 957: add_p96_mode (gfx_fullscreen_modes[i].w, gfx_fullscreen_modes[i].h,
! 958: emulate_chunky, &count);
1.1 root 959: }
1.1.1.4 root 960:
1.1 root 961: return count;
962: }
963:
964: uae_u8 *gfx_lock_picasso (void)
965: {
1.1.1.4 root 966: DEBUG_LOG ("Function: gfx_lock_picasso\n");
967:
968: if (SDL_MUSTLOCK (screen))
969: SDL_LockSurface (screen);
970: picasso_vidinfo.rowbytes = screen->pitch;
971: return screen->pixels;
1.1 root 972: }
973:
974: void gfx_unlock_picasso (void)
975: {
1.1.1.4 root 976: DEBUG_LOG ("Function: gfx_unlock_picasso\n");
977:
978: if (SDL_MUSTLOCK (screen))
979: SDL_UnlockSurface (screen);
1.1 root 980: }
1.1.1.4 root 981: #endif /* PICASSO96 */
1.1 root 982:
1.1.1.4 root 983: void toggle_fullscreen (void)
984: {
985: changed_prefs.gfx_afullscreen = changed_prefs.gfx_pfullscreen = !fullscreen;
986:
987: DEBUG_LOG ("ToggleFullScreen: %d\n", fullscreen );
988: };
989:
990: void toggle_mousegrab (void)
991: {
992: if (!fullscreen) {
993: if (SDL_WM_GrabInput (SDL_GRAB_QUERY) == SDL_GRAB_OFF) {
994: if (SDL_WM_GrabInput (SDL_GRAB_ON) == SDL_GRAB_ON) {
995: SDL_WarpMouse (0, 0);
996: mousegrab = 1;
997: SDL_ShowCursor (SDL_DISABLE);
998: }
999: } else {
1000: if (SDL_WM_GrabInput (SDL_GRAB_OFF) == SDL_GRAB_OFF) {
1001: mousegrab = 0;
1002: SDL_ShowCursor (SDL_DISABLE);
1003: }
1004: }
1005: }
1006: }
1007:
1008: /*
1009: * Mouse inputdevice functions
1010: */
1011:
1012: /* Hardwire for 3 axes and 3 buttons - although SDL doesn't
1013: * currently support a Z-axis as such. Mousewheel events are supplied
1014: * as buttons 4 and 5
1015: */
1016: #define MAX_BUTTONS 3
1017: #define MAX_AXES 3
1018: #define FIRST_AXIS 0
1019: #define FIRST_BUTTON MAX_AXES
1020:
1021: static int init_mouse (void)
1022: {
1023: return 1;
1024: }
1025:
1026: static void close_mouse (void)
1027: {
1028: return;
1029: }
1030:
1031: static int acquire_mouse (unsigned int num, int flags)
1032: {
1033: /* SDL supports only one mouse */
1034: return 1;
1035: }
1036:
1037: static void unacquire_mouse (unsigned int num)
1038: {
1039: return;
1040: }
1041:
1042: static unsigned int get_mouse_num (void)
1.1 root 1043: {
1044: return 1;
1045: }
1046:
1.1.1.4 root 1047: static const char *get_mouse_name (unsigned int mouse)
1.1 root 1048: {
1.1.1.4 root 1049: return "Default mouse";
1.1 root 1050: }
1051:
1.1.1.4 root 1052: static unsigned int get_mouse_widget_num (unsigned int mouse)
1.1 root 1053: {
1.1.1.4 root 1054: return MAX_AXES + MAX_BUTTONS;
1055: }
1056:
1057: static int get_mouse_widget_first (unsigned int mouse, int type)
1058: {
1059: switch (type) {
1060: case IDEV_WIDGET_BUTTON:
1061: return FIRST_BUTTON;
1062: case IDEV_WIDGET_AXIS:
1063: return FIRST_AXIS;
1.1 root 1064: }
1.1.1.4 root 1065: return -1;
1066: }
1067:
1068: static int get_mouse_widget_type (unsigned int mouse, unsigned int num, char *name, uae_u32 *code)
1069: {
1070: if (num >= MAX_AXES && num < MAX_AXES + MAX_BUTTONS) {
1071: if (name)
1072: sprintf (name, "Button %d", num + 1 + MAX_AXES);
1073: return IDEV_WIDGET_BUTTON;
1074: } else if (num < MAX_AXES) {
1075: if (name)
1076: sprintf (name, "Axis %d", num + 1);
1077: return IDEV_WIDGET_AXIS;
1.1 root 1078: }
1.1.1.4 root 1079: return IDEV_WIDGET_NONE;
1.1 root 1080: }
1081:
1.1.1.4 root 1082: static void read_mouse (void)
1.1 root 1083: {
1.1.1.4 root 1084: /* We handle mouse input in handle_events() */
1.1 root 1085: }
1086:
1.1.1.4 root 1087: struct inputdevice_functions inputdevicefunc_mouse = {
1088: init_mouse,
1089: close_mouse,
1090: acquire_mouse,
1091: unacquire_mouse,
1092: read_mouse,
1093: get_mouse_num,
1094: get_mouse_name,
1095: get_mouse_widget_num,
1096: get_mouse_widget_type,
1097: get_mouse_widget_first
1098: };
1099:
1100: /*
1101: * Keyboard inputdevice functions
1102: */
1103: static unsigned int get_kb_num (void)
1104: {
1105: /* SDL supports only one keyboard */
1106: return 1;
1107: }
1.1 root 1108:
1.1.1.4 root 1109: static const char *get_kb_name (unsigned int kb)
1.1 root 1110: {
1.1.1.4 root 1111: return "Default keyboard";
1112: }
1113:
1114: static unsigned int get_kb_widget_num (unsigned int kb)
1115: {
1116: return 255; // fix me
1117: }
1118:
1119: static int get_kb_widget_first (unsigned int kb, int type)
1120: {
1121: return 0;
1122: }
1123:
1124: static int get_kb_widget_type (unsigned int kb, unsigned int num, char *name, uae_u32 *code)
1125: {
1126: // fix me
1127: *code = num;
1128: return IDEV_WIDGET_KEY;
1129: }
1130:
1131: static int init_kb (void)
1132: {
1133: struct uae_input_device_kbr_default *keymap = 0;
1134:
1135: /* See if we support raw keys on this platform */
1136: if ((keymap = get_default_raw_keymap (get_sdlgfx_type ())) != 0) {
1137: inputdevice_setkeytranslation (keymap);
1138: have_rawkeys = 1;
1.1 root 1139: }
1.1.1.4 root 1140: switch_keymaps ();
1141:
1142: return 1;
1143: }
1144:
1145: static void close_kb (void)
1146: {
1147: }
1148:
1149: static int keyhack (int scancode, int pressed, int num)
1150: {
1151: return scancode;
1.1 root 1152: }
1153:
1.1.1.4 root 1154: static void read_kb (void)
1.1 root 1155: {
1156: }
1157:
1.1.1.4 root 1158: static int acquire_kb (unsigned int num, int flags)
1.1 root 1159: {
1.1.1.4 root 1160: return 1;
1.1 root 1161: }
1162:
1.1.1.4 root 1163: static void unacquire_kb (unsigned int num)
1164: {
1165: }
1166:
1167: struct inputdevice_functions inputdevicefunc_keyboard =
1168: {
1169: init_kb,
1170: close_kb,
1171: acquire_kb,
1172: unacquire_kb,
1173: read_kb,
1174: get_kb_num,
1175: get_kb_name,
1176: get_kb_widget_num,
1177: get_kb_widget_type,
1178: get_kb_widget_first
1179: };
1180:
1181: //static int capslockstate;
1182:
1183: int getcapslockstate (void)
1184: {
1185: // TODO
1186: // return capslockstate;
1187: return 0;
1188: }
1189: void setcapslockstate (int state)
1190: {
1191: // TODO
1192: // capslockstate = state;
1193: }
1194:
1195:
1196: /*
1197: * Default inputdevice config for SDL mouse
1198: */
1199: void input_get_default_mouse (struct uae_input_device *uid)
1200: {
1201: /* SDL supports only one mouse */
1202: uid[0].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_MOUSE1_HORIZ;
1203: uid[0].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_MOUSE1_VERT;
1204: uid[0].eventid[ID_AXIS_OFFSET + 2][0] = INPUTEVENT_MOUSE1_WHEEL;
1205: uid[0].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY1_FIRE_BUTTON;
1206: uid[0].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY1_2ND_BUTTON;
1207: uid[0].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY1_3RD_BUTTON;
1208: uid[0].enabled = 1;
1209: }
1210:
1211: /*
1212: * Handle gfx specific cfgfile options
1213: */
1214:
1.1.1.5 ! root 1215: void target_save_options (FILE *f, const struct uae_prefs *p)
1.1 root 1216: {
1217: }
1218:
1.1.1.5 ! root 1219: int target_parse_option (struct uae_prefs *p, const char *option, const char *value)
1.1 root 1220: {
1221: return 0;
1222: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.