48 |
|
#define DEBUG 1 |
49 |
|
#include "debug.h" |
50 |
|
|
51 |
< |
#if ENABLE_DGA |
51 |
> |
#if ENABLE_XF86_DGA |
52 |
|
#include <X11/extensions/xf86dga.h> |
53 |
|
#endif |
54 |
|
|
55 |
+ |
#if ENABLE_XF86_VIDMODE |
56 |
+ |
#include <X11/extensions/xf86vmode.h> |
57 |
+ |
#endif |
58 |
+ |
|
59 |
+ |
#if ENABLE_FBDEV_DGA |
60 |
+ |
#include <sys/mman.h> |
61 |
+ |
#endif |
62 |
+ |
|
63 |
+ |
|
64 |
|
|
65 |
|
// Display types |
66 |
|
enum { |
70 |
|
|
71 |
|
|
72 |
|
// Constants |
73 |
< |
const char KEYCODE_FILE_NAME[] = "/usr/local/lib/basilisk_ii_keycodes"; |
73 |
> |
const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes"; |
74 |
> |
const char FBDEVICES_FILE_NAME[] = DATADIR "/fbdevices"; |
75 |
|
|
76 |
|
|
77 |
|
// Global variables |
78 |
< |
static int32 frame_skip; |
78 |
> |
static int32 frame_skip; // Prefs items |
79 |
> |
static int16 mouse_wheel_mode = 1; |
80 |
> |
static int16 mouse_wheel_lines = 3; |
81 |
> |
|
82 |
|
static int display_type = DISPLAY_WINDOW; // See enum above |
83 |
|
static uint8 *the_buffer; // Mac frame buffer |
84 |
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed |
86 |
|
static pthread_t redraw_thread; // Redraw thread |
87 |
|
|
88 |
|
static bool has_dga = false; // Flag: Video DGA capable |
89 |
+ |
static bool has_vidmode = false; // Flag: VidMode extension available |
90 |
|
|
91 |
|
static bool ctrl_down = false; // Flag: Ctrl key pressed |
92 |
+ |
static bool caps_on = false; // Flag: Caps Lock on |
93 |
|
static bool quit_full_screen = false; // Flag: DGA close requested from redraw thread |
94 |
|
static bool emerg_quit = false; // Flag: Ctrl-Esc pressed, emergency quit requested from MacOS thread |
95 |
|
static bool emul_suspended = false; // Flag: Emulator suspended |
129 |
|
static uint8 the_cursor[64]; // Cursor image data |
130 |
|
static bool have_shm = false; // Flag: SHM extensions available |
131 |
|
|
132 |
< |
// Variables for DGA mode |
132 |
> |
// Variables for XF86 DGA mode |
133 |
|
static int current_dga_cmap; // Number (0 or 1) of currently installed DGA colormap |
134 |
|
static Window suspend_win; // "Suspend" window |
135 |
|
static void *fb_save = NULL; // Saved frame buffer for suspend |
121 |
– |
|
136 |
|
static pthread_mutex_t frame_buffer_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to protect frame buffer |
137 |
|
|
138 |
+ |
// Variables for fbdev DGA mode |
139 |
+ |
const char FBDEVICE_FILE_NAME[] = "/dev/fb"; |
140 |
+ |
static int fbdev_fd; |
141 |
+ |
|
142 |
+ |
#if ENABLE_XF86_VIDMODE |
143 |
+ |
// Variables for XF86 VidMode support |
144 |
+ |
static XF86VidModeModeInfo **x_video_modes; // Array of all available modes |
145 |
+ |
static int num_x_video_modes; |
146 |
+ |
#endif |
147 |
+ |
|
148 |
|
|
149 |
|
// Prototypes |
150 |
|
static void *redraw_func(void *arg); |
165 |
|
// Set VideoMonitor according to video mode |
166 |
|
void set_video_monitor(int width, int height, int bytes_per_row, bool native_byte_order) |
167 |
|
{ |
168 |
< |
int layout; |
168 |
> |
int layout = FLAYOUT_DIRECT; |
169 |
|
switch (depth) { |
170 |
|
case 1: |
171 |
|
layout = FLAYOUT_DIRECT; |
256 |
|
XSetWMNormalHints(x_display, the_win, hints); |
257 |
|
XFree((char *)hints); |
258 |
|
} |
259 |
< |
|
259 |
> |
|
260 |
|
// Try to create and attach SHM image |
261 |
|
have_shm = false; |
262 |
|
if (depth != 1 && XShmQueryExtension(x_display)) { |
283 |
|
shmctl(shminfo.shmid, IPC_RMID, 0); |
284 |
|
} |
285 |
|
} |
286 |
< |
|
286 |
> |
|
287 |
|
// Create normal X image if SHM doesn't work ("height + 2" for safety) |
288 |
|
if (!have_shm) { |
289 |
|
int bytes_per_row = width; |
336 |
|
#else |
337 |
|
set_video_monitor(width, height, img->bytes_per_line, img->bitmap_bit_order == LSBFirst); |
338 |
|
#endif |
339 |
+ |
|
340 |
+ |
#if REAL_ADDRESSING |
341 |
+ |
VideoMonitor.mac_frame_base = (uint32)the_buffer; |
342 |
+ |
MacFrameLayout = FLAYOUT_DIRECT; |
343 |
+ |
#else |
344 |
+ |
VideoMonitor.mac_frame_base = MacFrameBaseMac; |
345 |
+ |
#endif |
346 |
+ |
return true; |
347 |
+ |
} |
348 |
+ |
|
349 |
+ |
// Init fbdev DGA display |
350 |
+ |
static bool init_fbdev_dga(char *in_fb_name) |
351 |
+ |
{ |
352 |
+ |
#if ENABLE_FBDEV_DGA |
353 |
+ |
// Find the maximum depth available |
354 |
+ |
int ndepths, max_depth(0); |
355 |
+ |
int *depths = XListDepths(x_display, screen, &ndepths); |
356 |
+ |
if (depths == NULL) { |
357 |
+ |
printf("FATAL: Could not determine the maximal depth available\n"); |
358 |
+ |
return false; |
359 |
+ |
} else { |
360 |
+ |
while (ndepths-- > 0) { |
361 |
+ |
if (depths[ndepths] > max_depth) |
362 |
+ |
max_depth = depths[ndepths]; |
363 |
+ |
} |
364 |
+ |
} |
365 |
+ |
|
366 |
+ |
// Get fbdevices file path from preferences |
367 |
+ |
const char *fbd_path = PrefsFindString("fbdevicefile"); |
368 |
+ |
|
369 |
+ |
// Open fbdevices file |
370 |
+ |
FILE *fp = fopen(fbd_path ? fbd_path : FBDEVICES_FILE_NAME, "r"); |
371 |
+ |
if (fp == NULL) { |
372 |
+ |
char str[256]; |
373 |
+ |
sprintf(str, GetString(STR_NO_FBDEVICE_FILE_ERR), fbd_path ? fbd_path : FBDEVICES_FILE_NAME, strerror(errno)); |
374 |
+ |
ErrorAlert(str); |
375 |
+ |
return false; |
376 |
+ |
} |
377 |
+ |
|
378 |
+ |
int fb_depth; // supported depth |
379 |
+ |
uint32 fb_offset; // offset used for mmap(2) |
380 |
+ |
char fb_name[20]; |
381 |
+ |
char line[256]; |
382 |
+ |
bool device_found = false; |
383 |
+ |
while (fgets(line, 255, fp)) { |
384 |
+ |
// Read line |
385 |
+ |
int len = strlen(line); |
386 |
+ |
if (len == 0) |
387 |
+ |
continue; |
388 |
+ |
line[len - 1] = '\0'; |
389 |
+ |
|
390 |
+ |
// Comments begin with "#" or ";" |
391 |
+ |
if ((line[0] == '#') || (line[0] == ';') || (line[0] == '\0')) |
392 |
+ |
continue; |
393 |
+ |
|
394 |
+ |
if ((sscanf(line, "%19s %d %x", &fb_name, &fb_depth, &fb_offset) == 3) |
395 |
+ |
&& (strcmp(fb_name, in_fb_name) == 0) && (fb_depth == max_depth)) { |
396 |
+ |
device_found = true; |
397 |
+ |
break; |
398 |
+ |
} |
399 |
+ |
} |
400 |
+ |
|
401 |
+ |
// fbdevices file completely read |
402 |
+ |
fclose(fp); |
403 |
+ |
|
404 |
+ |
// Frame buffer name not found ? Then, display warning |
405 |
+ |
if (!device_found) { |
406 |
+ |
char str[256]; |
407 |
+ |
sprintf(str, GetString(STR_FBDEV_NAME_ERR), in_fb_name, max_depth); |
408 |
+ |
ErrorAlert(str); |
409 |
+ |
return false; |
410 |
+ |
} |
411 |
+ |
|
412 |
+ |
int width = DisplayWidth(x_display, screen); |
413 |
+ |
int height = DisplayHeight(x_display, screen); |
414 |
+ |
depth = fb_depth; // max_depth |
415 |
+ |
|
416 |
+ |
// Set relative mouse mode |
417 |
+ |
ADBSetRelMouseMode(false); |
418 |
+ |
|
419 |
+ |
// Create window |
420 |
+ |
XSetWindowAttributes wattr; |
421 |
+ |
wattr.override_redirect = True; |
422 |
+ |
wattr.backing_store = NotUseful; |
423 |
+ |
wattr.background_pixel = white_pixel; |
424 |
+ |
wattr.border_pixel = black_pixel; |
425 |
+ |
wattr.event_mask = eventmask = dga_eventmask; |
426 |
+ |
|
427 |
+ |
XSync(x_display, false); |
428 |
+ |
the_win = XCreateWindow(x_display, rootwin, |
429 |
+ |
0, 0, width, height, |
430 |
+ |
0, xdepth, InputOutput, vis, |
431 |
+ |
CWEventMask|CWBackPixel|CWBorderPixel|CWOverrideRedirect|CWBackingStore, |
432 |
+ |
&wattr); |
433 |
+ |
XSync(x_display, false); |
434 |
+ |
XMapRaised(x_display, the_win); |
435 |
+ |
XSync(x_display, false); |
436 |
+ |
|
437 |
+ |
// Grab mouse and keyboard |
438 |
+ |
XGrabKeyboard(x_display, the_win, True, |
439 |
+ |
GrabModeAsync, GrabModeAsync, CurrentTime); |
440 |
+ |
XGrabPointer(x_display, the_win, True, |
441 |
+ |
PointerMotionMask | ButtonPressMask | ButtonReleaseMask, |
442 |
+ |
GrabModeAsync, GrabModeAsync, the_win, None, CurrentTime); |
443 |
+ |
|
444 |
+ |
// Set colormap |
445 |
+ |
if (depth == 8) { |
446 |
+ |
XSetWindowColormap(x_display, the_win, cmap[0]); |
447 |
+ |
XSetWMColormapWindows(x_display, the_win, &the_win, 1); |
448 |
+ |
} |
449 |
+ |
|
450 |
+ |
// Set VideoMonitor |
451 |
+ |
int bytes_per_row = width; |
452 |
+ |
switch (depth) { |
453 |
+ |
case 1: |
454 |
+ |
bytes_per_row = ((width | 7) & ~7) >> 3; |
455 |
+ |
break; |
456 |
+ |
case 15: |
457 |
+ |
case 16: |
458 |
+ |
bytes_per_row *= 2; |
459 |
+ |
break; |
460 |
+ |
case 24: |
461 |
+ |
case 32: |
462 |
+ |
bytes_per_row *= 4; |
463 |
+ |
break; |
464 |
+ |
} |
465 |
+ |
|
466 |
+ |
if ((the_buffer = (uint8 *) mmap(NULL, height * bytes_per_row, PROT_READ | PROT_WRITE, MAP_PRIVATE, fbdev_fd, fb_offset)) == MAP_FAILED) { |
467 |
+ |
if ((the_buffer = (uint8 *) mmap(NULL, height * bytes_per_row, PROT_READ | PROT_WRITE, MAP_SHARED, fbdev_fd, fb_offset)) == MAP_FAILED) { |
468 |
+ |
char str[256]; |
469 |
+ |
sprintf(str, GetString(STR_FBDEV_MMAP_ERR), strerror(errno)); |
470 |
+ |
ErrorAlert(str); |
471 |
+ |
return false; |
472 |
+ |
} |
473 |
+ |
} |
474 |
+ |
|
475 |
+ |
set_video_monitor(width, height, bytes_per_row, true); |
476 |
|
#if REAL_ADDRESSING |
477 |
|
VideoMonitor.mac_frame_base = (uint32)the_buffer; |
478 |
|
MacFrameLayout = FLAYOUT_DIRECT; |
480 |
|
VideoMonitor.mac_frame_base = MacFrameBaseMac; |
481 |
|
#endif |
482 |
|
return true; |
483 |
+ |
#else |
484 |
+ |
ErrorAlert("Basilisk II has been compiled with fbdev DGA support disabled."); |
485 |
+ |
return false; |
486 |
+ |
#endif |
487 |
|
} |
488 |
|
|
489 |
< |
// Init DGA display |
490 |
< |
static bool init_dga(int width, int height) |
489 |
> |
// Init XF86 DGA display |
490 |
> |
static bool init_xf86_dga(int width, int height) |
491 |
|
{ |
492 |
< |
#if ENABLE_DGA |
492 |
> |
#if ENABLE_XF86_DGA |
493 |
|
// Set relative mouse mode |
494 |
|
ADBSetRelMouseMode(true); |
495 |
|
|
496 |
+ |
#if ENABLE_XF86_VIDMODE |
497 |
+ |
// Switch to best mode |
498 |
+ |
if (has_vidmode) { |
499 |
+ |
int best = 0; |
500 |
+ |
for (int i=1; i<num_x_video_modes; i++) { |
501 |
+ |
if (x_video_modes[i]->hdisplay >= width && x_video_modes[i]->vdisplay >= height && |
502 |
+ |
x_video_modes[i]->hdisplay <= x_video_modes[best]->hdisplay && x_video_modes[i]->vdisplay <= x_video_modes[best]->vdisplay) { |
503 |
+ |
best = i; |
504 |
+ |
} |
505 |
+ |
} |
506 |
+ |
XF86VidModeSwitchToMode(x_display, screen, x_video_modes[best]); |
507 |
+ |
XF86VidModeSetViewPort(x_display, screen, 0, 0); |
508 |
+ |
} |
509 |
+ |
#endif |
510 |
+ |
|
511 |
|
// Create window |
512 |
|
XSetWindowAttributes wattr; |
513 |
|
wattr.event_mask = eventmask = dga_eventmask; |
565 |
|
#endif |
566 |
|
return true; |
567 |
|
#else |
568 |
< |
ErrorAlert("Basilisk II has been compiled with DGA support disabled."); |
568 |
> |
ErrorAlert("Basilisk II has been compiled with XF86 DGA support disabled."); |
569 |
|
return false; |
570 |
|
#endif |
571 |
|
} |
640 |
|
// Init keycode translation |
641 |
|
keycode_init(); |
642 |
|
|
643 |
+ |
// Read prefs |
644 |
+ |
mouse_wheel_mode = PrefsFindInt16("mousewheelmode"); |
645 |
+ |
mouse_wheel_lines = PrefsFindInt16("mousewheellines"); |
646 |
+ |
|
647 |
|
// Find screen and root window |
648 |
|
screen = XDefaultScreen(x_display); |
649 |
|
rootwin = XRootWindow(x_display, screen); |
650 |
< |
|
650 |
> |
|
651 |
|
// Get screen depth |
652 |
|
xdepth = DefaultDepth(x_display, screen); |
653 |
+ |
|
654 |
+ |
#if ENABLE_FBDEV_DGA |
655 |
+ |
// Frame buffer name |
656 |
+ |
char fb_name[20]; |
657 |
+ |
|
658 |
+ |
// Could do fbdev dga ? |
659 |
+ |
if ((fbdev_fd = open(FBDEVICE_FILE_NAME, O_RDWR)) != -1) |
660 |
+ |
has_dga = true; |
661 |
+ |
else |
662 |
+ |
has_dga = false; |
663 |
+ |
#endif |
664 |
|
|
665 |
< |
#if ENABLE_DGA |
665 |
> |
#if ENABLE_XF86_DGA |
666 |
|
// DGA available? |
667 |
< |
int dga_flags = 0; |
668 |
< |
XF86DGAQueryDirectVideo(x_display, screen, &dga_flags); |
669 |
< |
has_dga = dga_flags & XF86DGADirectPresent; |
667 |
> |
int dga_event_base, dga_error_base; |
668 |
> |
if (XF86DGAQueryExtension(x_display, &dga_event_base, &dga_error_base)) { |
669 |
> |
int dga_flags = 0; |
670 |
> |
XF86DGAQueryDirectVideo(x_display, screen, &dga_flags); |
671 |
> |
has_dga = dga_flags & XF86DGADirectPresent; |
672 |
> |
} else |
673 |
> |
has_dga = false; |
674 |
|
#endif |
675 |
|
|
676 |
+ |
#if ENABLE_XF86_VIDMODE |
677 |
+ |
// VidMode available? |
678 |
+ |
int vm_event_base, vm_error_base; |
679 |
+ |
has_vidmode = XF86VidModeQueryExtension(x_display, &vm_event_base, &vm_error_base); |
680 |
+ |
if (has_vidmode) |
681 |
+ |
XF86VidModeGetAllModeLines(x_display, screen, &num_x_video_modes, &x_video_modes); |
682 |
+ |
#endif |
683 |
+ |
|
684 |
|
// Find black and white colors |
685 |
|
XParseColor(x_display, DefaultColormap(x_display, screen), "rgb:00/00/00", &black); |
686 |
|
XAllocColor(x_display, DefaultColormap(x_display, screen), &black); |
746 |
|
if (mode_str) { |
747 |
|
if (sscanf(mode_str, "win/%d/%d", &width, &height) == 2) |
748 |
|
display_type = DISPLAY_WINDOW; |
749 |
< |
else if (has_dga && strcmp(mode_str, "dga") == 0) { |
749 |
> |
#if ENABLE_FBDEV_DGA |
750 |
> |
else if (has_dga && sscanf(mode_str, "dga/%19s", fb_name) == 1) { |
751 |
> |
#else |
752 |
> |
else if (has_dga && sscanf(mode_str, "dga/%d/%d", &width, &height) == 2) { |
753 |
> |
#endif |
754 |
|
display_type = DISPLAY_DGA; |
755 |
+ |
if (width > DisplayWidth(x_display, screen)) |
756 |
+ |
width = DisplayWidth(x_display, screen); |
757 |
+ |
if (height > DisplayHeight(x_display, screen)) |
758 |
+ |
height = DisplayHeight(x_display, screen); |
759 |
+ |
} |
760 |
+ |
if (width <= 0) |
761 |
|
width = DisplayWidth(x_display, screen); |
762 |
+ |
if (height <= 0) |
763 |
|
height = DisplayHeight(x_display, screen); |
546 |
– |
} |
764 |
|
} |
765 |
|
|
766 |
|
// Initialize according to display type |
770 |
|
return false; |
771 |
|
break; |
772 |
|
case DISPLAY_DGA: |
773 |
< |
if (!init_dga(width, height)) |
773 |
> |
#if ENABLE_FBDEV_DGA |
774 |
> |
if (!init_fbdev_dga(fb_name)) |
775 |
> |
#else |
776 |
> |
if (!init_xf86_dga(width, height)) |
777 |
> |
#endif |
778 |
|
return false; |
779 |
|
break; |
780 |
|
} |
824 |
|
if (x_display != NULL) { |
825 |
|
XSync(x_display, false); |
826 |
|
|
827 |
< |
#if ENABLE_DGA |
827 |
> |
#if ENABLE_XF86_DGA |
828 |
|
if (display_type == DISPLAY_DGA) { |
829 |
|
XF86DGADirectVideo(x_display, screen, 0); |
830 |
|
XUngrabPointer(x_display, CurrentTime); |
832 |
|
} |
833 |
|
#endif |
834 |
|
|
835 |
+ |
#if ENABLE_XF86_VIDMODE |
836 |
+ |
if (has_vidmode && display_type == DISPLAY_DGA) |
837 |
+ |
XF86VidModeSwitchToMode(x_display, screen, x_video_modes[0]); |
838 |
+ |
#endif |
839 |
+ |
|
840 |
+ |
#if ENABLE_FBDEV_DGA |
841 |
+ |
if (display_type == DISPLAY_DGA) { |
842 |
+ |
XUngrabPointer(x_display, CurrentTime); |
843 |
+ |
XUngrabKeyboard(x_display, CurrentTime); |
844 |
+ |
close(fbdev_fd); |
845 |
+ |
} |
846 |
+ |
#endif |
847 |
+ |
|
848 |
|
if (the_buffer_copy) { |
849 |
|
free(the_buffer_copy); |
850 |
|
the_buffer_copy = NULL; |
917 |
|
* Suspend/resume emulator |
918 |
|
*/ |
919 |
|
|
920 |
< |
#if ENABLE_DGA |
920 |
> |
#if ENABLE_XF86_DGA || ENABLE_FBDEV_DGA |
921 |
|
static void suspend_emul(void) |
922 |
|
{ |
923 |
|
if (display_type == DISPLAY_DGA) { |
934 |
|
memcpy(fb_save, the_buffer, VideoMonitor.y * VideoMonitor.bytes_per_row); |
935 |
|
|
936 |
|
// Close full screen display |
937 |
+ |
#if ENABLE_XF86_DGA |
938 |
|
XF86DGADirectVideo(x_display, screen, 0); |
939 |
+ |
#endif |
940 |
|
XUngrabPointer(x_display, CurrentTime); |
941 |
|
XUngrabKeyboard(x_display, CurrentTime); |
942 |
|
XUnmapWindow(x_display, the_win); |
950 |
|
wattr.backing_store = Always; |
951 |
|
wattr.backing_planes = xdepth; |
952 |
|
wattr.colormap = DefaultColormap(x_display, screen); |
953 |
+ |
|
954 |
|
XSync(x_display, false); |
955 |
|
suspend_win = XCreateWindow(x_display, rootwin, 0, 0, 512, 1, 0, xdepth, |
956 |
|
InputOutput, vis, CWEventMask | CWBackPixel | CWBorderPixel | |
975 |
|
XSync(x_display, false); |
976 |
|
XGrabKeyboard(x_display, rootwin, 1, GrabModeAsync, GrabModeAsync, CurrentTime); |
977 |
|
XGrabPointer(x_display, rootwin, 1, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime); |
978 |
+ |
#if ENABLE_XF86_DGA |
979 |
|
XF86DGADirectVideo(x_display, screen, XF86DGADirectGraphics | XF86DGADirectKeyb | XF86DGADirectMouse); |
980 |
|
XF86DGASetViewPort(x_display, screen, 0, 0); |
981 |
+ |
#endif |
982 |
|
XSync(x_display, false); |
983 |
|
|
984 |
|
// Restore frame buffer |
987 |
|
free(fb_save); |
988 |
|
fb_save = NULL; |
989 |
|
} |
990 |
+ |
|
991 |
|
if (depth == 8) |
992 |
+ |
#if ENABLE_XF86_DGA |
993 |
|
XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); |
994 |
+ |
#endif |
995 |
|
|
996 |
|
// Unlock frame buffer (and continue MacOS thread) |
997 |
|
pthread_mutex_unlock(&frame_buffer_lock); |
1057 |
|
case XK_period: case XK_greater: return 0x2f; |
1058 |
|
case XK_slash: case XK_question: return 0x2c; |
1059 |
|
|
1060 |
< |
#if ENABLE_DGA |
1060 |
> |
#if ENABLE_XF86_DGA || ENABLE_FBDEV_DGA |
1061 |
|
case XK_Tab: if (ctrl_down) {suspend_emul(); return -1;} else return 0x30; |
1062 |
|
#else |
1063 |
|
case XK_Tab: return 0x30; |
1183 |
|
unsigned int button = ((XButtonEvent *)&event)->button; |
1184 |
|
if (button < 4) |
1185 |
|
ADBMouseDown(button - 1); |
1186 |
+ |
else if (button < 6) { // Wheel mouse |
1187 |
+ |
if (mouse_wheel_mode == 0) { |
1188 |
+ |
int key = (button == 5) ? 0x79 : 0x74; // Page up/down |
1189 |
+ |
ADBKeyDown(key); |
1190 |
+ |
ADBKeyUp(key); |
1191 |
+ |
} else { |
1192 |
+ |
int key = (button == 5) ? 0x3d : 0x3e; // Cursor up/down |
1193 |
+ |
for(int i=0; i<mouse_wheel_lines; i++) { |
1194 |
+ |
ADBKeyDown(key); |
1195 |
+ |
ADBKeyUp(key); |
1196 |
+ |
} |
1197 |
+ |
} |
1198 |
+ |
} |
1199 |
|
break; |
1200 |
|
} |
1201 |
|
case ButtonRelease: { |
1223 |
|
code = event2keycode((XKeyEvent *)&event); |
1224 |
|
if (code != -1) { |
1225 |
|
if (!emul_suspended) { |
1226 |
< |
ADBKeyDown(code); |
1226 |
> |
if (code == 0x39) { // Caps Lock pressed |
1227 |
> |
if (caps_on) { |
1228 |
> |
ADBKeyUp(code); |
1229 |
> |
caps_on = false; |
1230 |
> |
} else { |
1231 |
> |
ADBKeyDown(code); |
1232 |
> |
caps_on = true; |
1233 |
> |
} |
1234 |
> |
} else |
1235 |
> |
ADBKeyDown(code); |
1236 |
|
if (code == 0x36) |
1237 |
|
ctrl_down = true; |
1238 |
|
} else { |
1239 |
< |
#if ENABLE_DGA |
1239 |
> |
#if ENABLE_XF86_DGA || ENABLE_FBDEV_DGA |
1240 |
|
if (code == 0x31) |
1241 |
|
resume_emul(); // Space wakes us up |
1242 |
|
#endif |
1251 |
|
code = keycode_table[((XKeyEvent *)&event)->keycode & 0xff]; |
1252 |
|
} else |
1253 |
|
code = event2keycode((XKeyEvent *)&event); |
1254 |
< |
if (code != -1) { |
1254 |
> |
if (code != -1 && code != 0x39) { // Don't propagate Caps Lock releases |
1255 |
|
ADBKeyUp(code); |
1256 |
|
if (code == 0x36) |
1257 |
|
ctrl_down = false; |
1277 |
|
{ |
1278 |
|
// In classic mode, copy the frame buffer from Mac RAM |
1279 |
|
if (classic_mode) |
1280 |
< |
memcpy(the_buffer, Mac2HostAddr(0x3fa700), VideoMonitor.bytes_per_row * VideoMonitor.y); |
1281 |
< |
|
1280 |
> |
Mac2Host_memcpy(the_buffer, 0x3fa700, VideoMonitor.bytes_per_row * VideoMonitor.y); |
1281 |
> |
|
1282 |
|
// Incremental update code |
1283 |
|
int wide = 0, high = 0, x1, x2, y1, y2, i, j; |
1284 |
|
int bytes_per_row = VideoMonitor.bytes_per_row; |
1397 |
|
|
1398 |
|
// Set new cursor image if it was changed |
1399 |
|
if (memcmp(the_cursor, Mac2HostAddr(0x844), 64)) { |
1400 |
< |
memcpy(the_cursor, Mac2HostAddr(0x844), 64); |
1400 |
> |
Mac2Host_memcpy(the_cursor, 0x844, 64); |
1401 |
|
memcpy(cursor_image->data, the_cursor, 32); |
1402 |
|
memcpy(cursor_mask_image->data, the_cursor+32, 32); |
1403 |
|
XFreeCursor(x_display, mac_cursor); |
1428 |
|
usleep(16667); |
1429 |
|
#endif |
1430 |
|
|
1431 |
< |
#if ENABLE_DGA |
1431 |
> |
#if ENABLE_XF86_DGA |
1432 |
|
// Quit DGA mode if requested |
1433 |
|
if (quit_full_screen) { |
1434 |
|
quit_full_screen = false; |
1442 |
|
} |
1443 |
|
#endif |
1444 |
|
|
1445 |
+ |
#if ENABLE_FBDEV_DGA |
1446 |
+ |
// Quit DGA mode if requested |
1447 |
+ |
if (quit_full_screen) { |
1448 |
+ |
quit_full_screen = false; |
1449 |
+ |
if (display_type == DISPLAY_DGA) { |
1450 |
+ |
XUngrabPointer(x_display, CurrentTime); |
1451 |
+ |
XUngrabKeyboard(x_display, CurrentTime); |
1452 |
+ |
XUnmapWindow(x_display, the_win); |
1453 |
+ |
XSync(x_display, false); |
1454 |
+ |
} |
1455 |
+ |
} |
1456 |
+ |
#endif |
1457 |
|
// Handle X events |
1458 |
|
handle_events(); |
1459 |
|
|
1464 |
|
if (depth == 8) { |
1465 |
|
XStoreColors(x_display, cmap[0], palette, 256); |
1466 |
|
XStoreColors(x_display, cmap[1], palette, 256); |
1467 |
< |
#if ENABLE_DGA |
1467 |
> |
|
1468 |
> |
#if ENABLE_XF86_DGA |
1469 |
|
if (display_type == DISPLAY_DGA) { |
1470 |
|
current_dga_cmap ^= 1; |
1471 |
|
XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); |