예제 #1
0
static void read_kb (void)
{
    int keycode;
    int keyinfo_byte;
    int keyinfo_bit;

    key_info keyInfo;

    get_key_info (&keyInfo);

    if (memcmp (keyInfo.key_states, lastKeyInfo.key_states, sizeof (keyInfo.key_states))) {
	for (keycode = 0; keycode < 0x80; keycode++) {
	    keyinfo_byte = keycode >> 3;
	    keyinfo_bit = 1 << (~keycode & 7);

	    // Key state changed?
	    if ((keyInfo.key_states[keyinfo_byte] & keyinfo_bit) != (lastKeyInfo.key_states[keyinfo_byte] & keyinfo_bit)) {
		int new_state = (keyInfo.key_states[keyinfo_byte] & keyinfo_bit) != 0;
		int ievent;

		if ((ievent = match_hotkey_sequence (keycode, new_state)))
		    handle_hotkey_event (ievent, new_state);
		else
		    inputdevice_translatekeycode (0, keycode, new_state);
	    }
	}
	lastKeyInfo = keyInfo;
    }
}
예제 #2
0
int amiga_send_input_event(int input_event, int state) {
#ifdef DEBUG_SYNC
	write_sync_log("apply action %d state=%d\n", input_event, state);
#endif

    //printf("amiga_send_input_event %d %d\n", input_event, state);
    int isabs = 0;

    if (input_event > INPUTEVENT_PRIVATE_START) {
    	return handle_custom_action(input_event);
    }
    // FIXME: is max = 1 always appropriate?
    int max = 1;

    switch (input_event) {
    case INPUTEVENT_MOUSE1_HORIZ:
    	//printf("INPUTEVENT_MOUSE1_HORIZ\n");
    	mouse_state(0, 0, state, isabs, &max);
        //return 1;
    	break;
    case INPUTEVENT_MOUSE1_VERT:
    	//printf("INPUTEVENT_MOUSE1_VERT\n");
    	mouse_state(0, 1, state, isabs, &max);
        //return 1;
    	break;
    case INPUTEVENT_MOUSE2_HORIZ:
    	//printf("INPUTEVENT_MOUSE2_HORIZ\n");
    	mouse_state(1, 0, state, isabs, &max);
        //return 1;
    	break;
    case INPUTEVENT_MOUSE2_VERT:
    	//printf("INPUTEVENT_MOUSE2_VERT\n");
    	mouse_state(1, 1, state, isabs, &max);
        //return 1;
    	break;
    case INPUTEVENT_KEY_CAPS_LOCK:
        // handled specially because of toggle mode
        // keyboard 0, using input event as scan code (correctly mapped
        // in keymap.cpp)
        inputdevice_translatekeycode(0, INPUTEVENT_KEY_CAPS_LOCK, state);
        return 1;
    }
    int autofire = 0;
    bool canstopplayback = 1;
    bool playbackevent = 0;

    //amiga_configure_port_from_input_event(input_event);
    int result = amiga_handle_input_event (input_event, state, max, autofire,
            canstopplayback, playbackevent);
    if (result != 1) {
        write_log("amiga_handle_input_event(%d, %d, ...) failed with "
                "result %d", input_event, state, result);
    }
    return result;
}
예제 #3
0
//  Poll mouse and keyboard
void handle_events(void)
{
	int be_code,be_byte,be_bit,amiga_code;
	key_info keyInfo;

	if (!lastKeyInfoInitialized)
	{
		get_key_info(&lastKeyInfo);
		lastKeyInfoInitialized = true;
	}

	// Redraw drive LEDs
	/*for (int i=0; i<4; i++)
		DriveLED[i]->SetState(LEDs[i]);*/

	if (gEmulationWindow->UpdateMouseButtons())
	{
		get_key_info(&keyInfo);

		// Keyboard
		if (memcmp(keyInfo.key_states, lastKeyInfo.key_states, sizeof(keyInfo.key_states)))
		{
			for(be_code = 0;be_code < 0x80;be_code++)
			{
				be_byte = be_code >> 3;
				be_bit = 1 << (~be_code & 7);

				// Key state changed?
				if (	(keyInfo.key_states[be_byte] & be_bit)
					!= 	(lastKeyInfo.key_states[be_byte] & be_bit))
				{
					int state = (keyInfo.key_states[be_byte] & be_bit) !=0;
					int ievent;
					if ((ievent = match_hotkey_sequence (be_code, state)))
						handle_hotkey_event (ievent, state);
					else
						inputdevice_translatekeycode (0, be_code, state);
				}
			}
			lastKeyInfo = keyInfo;
		}
	}
예제 #4
0
int amiga_send_input_event(int input_event, int state)
{
    static bool caps_lock_state;

//#ifdef DEBUG_SYNC
    write_sync_log("apply action %d state=%d\n", input_event, state);
//#endif

    if (g_fs_log_input) {
        write_log("amiga_send_input_event %d %d\n", input_event, state);
    }

    if (input_event > INPUTEVENT_PRIVATE_START) {
        return handle_custom_action(input_event, state);
    }

    int max = 1;  /* FIXME: is max = 1 always appropriate? */
    bool magic_mouse = currprefs.input_mouse_untrap & MOUSEUNTRAP_MAGIC;
    if (uae_deterministic_mode()) {
        magic_mouse = false;
    }

    switch (input_event) {
    case INPUTEVENT_MOUSE1_HORIZ:
    case INPUTEVENT_MOUSE1_VERT:
        //printf("magic mouse %d\n", currprefs.input_magic_mouse);
        if (magic_mouse) {
            //printf("magic mouse %d %d\n",
            //       fs_emu_mouse_absolute_x, fs_emu_mouse_absolute_y);
            uae_mousehack_helper(fs_emu_mouse_absolute_x,
                                 fs_emu_mouse_absolute_y);
            return 1;
        }
    case INPUTEVENT_MOUSE1_WHEEL:
    case INPUTEVENT_MOUSE2_HORIZ:
    case INPUTEVENT_MOUSE2_VERT:
        max = 0;
        break;
    case INPUTEVENT_KEY_CAPS_LOCK:
        if (state && !caps_lock_state) {
            caps_lock_state = true;
        } else if (state && caps_lock_state) {
            caps_lock_state = false;
        }
        state = caps_lock_state;
#if 0
        // handled specially because of toggle mode
        // keyboard 0, using input event as scan code (correctly mapped
        // in keymap.cpp)
        inputdevice_translatekeycode(0, INPUTEVENT_KEY_CAPS_LOCK, state);
        return 1;
#endif
    }
    int autofire = 0;

    if (input_event == INPUTEVENT_JOY1_FIRE_BUTTON &&
            g_joystick_port_autofire[0]) {
        autofire = 1;
    } else if (input_event == INPUTEVENT_JOY2_FIRE_BUTTON &&
            g_joystick_port_autofire[1]) {
        autofire = 1;
    } else if (input_event == INPUTEVENT_PAR_JOY1_FIRE_BUTTON &&
            g_joystick_port_autofire[2]) {
        autofire = 1;
    } else if (input_event == INPUTEVENT_PAR_JOY2_FIRE_BUTTON &&
            g_joystick_port_autofire[3]) {
        autofire = 1;
    } else if ((input_event > INPUTEVENT_AUTOFIRE_BEGIN) &&
             (input_event < INPUTEVENT_AUTOFIRE_END)) {
        autofire = 1;
    }
    bool canstopplayback = 1;
    bool playbackevent = 0;

    //amiga_configure_port_from_input_event(input_event);
    int result = amiga_handle_input_event (
        input_event, state, max, autofire, canstopplayback, playbackevent);
    if (input_event >= INPUTEVENT_SPC_START && state == 0 && result == 0) {
        /* SPC / AKS keys do nothing for state 0 */
        result = 1;
    }
    if (result != 1) {
        write_log("amiga_handle_input_event(%d, %d, ...) failed with "
                  "result %d\n", input_event, state, result);
    }
    return result;
}
예제 #5
0
void my_kbd_handler (int keyboard, int scancode, int newstate)
{
	int code = 0;
	int scancode_new;
	static int swapperdrive = 0;

	if (scancode == specialkeycode ())
		return;

	if (scancode == DIK_F11 && currprefs.win32_ctrl_F11_is_quit && ctrlpressed ())
		code = AKS_QUIT;

	scancode_new = scancode;
	if (!specialpressed () && inputdevice_iskeymapped (keyboard, scancode))
		scancode = 0;
	// GUI must be always available
	if (scancode_new == DIK_F12 && currprefs.win32_guikey < 0)
		scancode = scancode_new;
	if (scancode_new == currprefs.win32_guikey && scancode_new != DIK_F12)
		scancode = scancode_new;
	
	//write_log (L"keyboard = %d scancode = 0x%02x state = %d\n", keyboard, scancode, newstate );

	if (newstate == 0 && code == 0) {
		switch (scancode)
		{
			case DIK_SYSRQ:
			screenshot (specialpressed () ? 1 : 0, 1);
			break;
		}
	}


	if (newstate && code == 0) {

		if (scancode == DIK_F12 || scancode == currprefs.win32_guikey) {
			if (ctrlpressed ()) {
				code = AKS_TOGGLEDEFAULTSCREEN;
			} else if (shiftpressed () || specialpressed ()) {
				if (isfullscreen() <= 0) {
					disablecapture ();
					code = AKS_ENTERDEBUGGER;
				}
			} else {
				code = AKS_ENTERGUI;
			}
		}

		switch (scancode)
		{
		case DIK_F1:
		case DIK_F2:
		case DIK_F3:
		case DIK_F4:
			if (specialpressed ()) {
				if (ctrlpressed ()) {
				} else {
					if (shiftpressed ())
						code = AKS_EFLOPPY0 + (scancode - DIK_F1);
					else
						code = AKS_FLOPPY0 + (scancode - DIK_F1);
				}
			}
			break;
		case DIK_F5:
#if 0
			{
				disk_prevnext (0, -1);
				return;
				//crap++;
				//write_log (L"%d\n", crap);
			}
#endif
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_STATESAVEDIALOG;
				else
					code = AKS_STATERESTOREDIALOG;
			}
			break;
		case DIK_1:
		case DIK_2:
		case DIK_3:
		case DIK_4:
		case DIK_5:
		case DIK_6:
		case DIK_7:
		case DIK_8:
		case DIK_9:
		case DIK_0:
			if (specialpressed ()) {
				int num = scancode - DIK_1;
				if (shiftpressed ())
					num += 10;
				if (ctrlpressed ()) {
					swapperdrive = num;
					if (swapperdrive > 3)
						swapperdrive = 0;
				} else {
					int i;
					for (i = 0; i < 4; i++) {
						if (!_tcscmp (currprefs.floppyslots[i].df, currprefs.dfxlist[num]))
							changed_prefs.floppyslots[i].df[0] = 0;
					}
					_tcscpy (changed_prefs.floppyslots[swapperdrive].df, currprefs.dfxlist[num]);
					config_changed = 1;
				}
			}
			break;
		case DIK_NUMPAD0:
		case DIK_NUMPAD1:
		case DIK_NUMPAD2:
		case DIK_NUMPAD3:
		case DIK_NUMPAD4:
		case DIK_NUMPAD5:
		case DIK_NUMPAD6:
		case DIK_NUMPAD7:
		case DIK_NUMPAD8:
		case DIK_NUMPAD9:
		case DIK_NUMPADPERIOD:
			if (specialpressed ()) {
				int i = 0, v = -1;
				while (np[i] >= 0) {
					v = np[i + 1];
					if (np[i] == scancode)
						break;
					i += 2;
				}
				if (v >= 0)
					code = AKS_STATESAVEQUICK + v * 2 + ((shiftpressed () || ctrlpressed ()) ? 0 : 1);
			}
			break;
		case DIK_PAUSE:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_IRQ7;
				else
					code = AKS_WARP;
			} else {
				code = AKS_PAUSE;
			}
			break;
		case DIK_SCROLL:
			code = AKS_INHIBITSCREEN;
			break;
		case DIK_NUMPADMINUS:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_DECREASEREFRESHRATE;
				else if (ctrlpressed ())
					code = AKS_MVOLDOWN;
				else
					code = AKS_VOLDOWN;
			}
			break;
		case DIK_NUMPADPLUS:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_INCREASEREFRESHRATE;
				else if (ctrlpressed ())
					code = AKS_MVOLUP;
				else
					code = AKS_VOLUP;
			}
			break;
		case DIK_NUMPADSTAR:
			if (specialpressed ()) {
				if (ctrlpressed ())
					code = AKS_MVOLMUTE;
				else
					code = AKS_VOLMUTE;
			}
			break;
		case DIK_NUMPADSLASH:
			if (specialpressed ())
				code = AKS_STATEREWIND;
			break;
		}
	}

	if (code) {
		inputdevice_add_inputcode (code, 1);
		return;
	}

	scancode = scancode_new;
	if (!specialpressed () && newstate) {
		if (scancode == DIK_CAPITAL) {
			host_capslockstate = host_capslockstate ? 0 : 1;
			capslockstate = host_capslockstate;
		}
		if (scancode == DIK_NUMLOCK) {
			host_numlockstate = host_numlockstate ? 0 : 1;
			capslockstate = host_numlockstate;
		}
		if (scancode == DIK_SCROLL) {
			host_scrolllockstate = host_scrolllockstate ? 0 : 1;
			capslockstate = host_scrolllockstate;
		}
	}
	if (specialpressed ())
		return;

	inputdevice_translatekeycode (keyboard, scancode, newstate);
}
예제 #6
0
bool my_kbd_handler (int keyboard, int scancode, int newstate)
{
	int code = 0;
	int scancode_new;
	bool amode = currprefs.input_keyboard_type == 0;
	bool special = false;
	static int swapperdrive = 0;

#if 0
	if (scancode == specialkeycode ()) {
		inputdevice_checkqualifierkeycode (keyboard, scancode, newstate);
		return;
	}
#endif
#if 0
	if (scancode == DIK_F1) {
		if (newstate) {
			extern int paska;
			paska++;
		}
		return;
	}
	if (scancode == DIK_F2) {
		if (newstate) {
			extern int paska;
			paska--;
		}
		return;
	}
#endif

	if (amode && scancode == DIK_F11 && currprefs.win32_ctrl_F11_is_quit && ctrlpressed ())
		code = AKS_QUIT;

	if (scancode == DIK_F9 && specialpressed ()) {
		if (newstate)
			toggle_rtg (-1);
		return true;
	}

	scancode_new = scancode;
	if (!specialpressed () && inputdevice_iskeymapped (keyboard, scancode))
		scancode = 0;
	
	if (newstate) {
		int defaultguikey = amode ? DIK_F12 : DIK_NUMLOCK;
		if (currprefs.win32_guikey >= 0x100) {
			if (scancode_new == DIK_F12)
				return true;
		} else if (currprefs.win32_guikey >= 0) {
			if (scancode_new == defaultguikey && currprefs.win32_guikey != scancode_new) {
				scancode = 0;
				if (specialpressed () && ctrlpressed() && shiftpressed() && altpressed ())
					inputdevice_add_inputcode (AKS_ENTERGUI, 1);
			} else if (scancode_new == currprefs.win32_guikey ) {
				inputdevice_add_inputcode (AKS_ENTERGUI, 1);
				scancode = 0;
			}
		} else if (!specialpressed () && !ctrlpressed() && !shiftpressed() && !altpressed () && scancode_new == defaultguikey) {
			inputdevice_add_inputcode (AKS_ENTERGUI, 1);
			scancode = 0;
		}
	}

	//write_log (_T("keyboard = %d scancode = 0x%02x state = %d\n"), keyboard, scancode, newstate );

	if (newstate && code == 0 && amode) {

		switch (scancode)
		{
#if 0
		case DIK_F1:
		case DIK_F2:
		case DIK_F3:
		case DIK_F4:
			if (specialpressed ()) {
				if (ctrlpressed ()) {
				} else {
					if (shiftpressed ())
						code = AKS_EFLOPPY0 + (scancode - DIK_F1);
					else
						code = AKS_FLOPPY0 + (scancode - DIK_F1);
				}
			}
			special = true;
			break;
		case DIK_F5:
#if 0
			{
				disk_prevnext (0, -1);
				return;
				//crap++;
				//write_log (_T("%d\n"), crap);
			}
#endif
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_STATESAVEDIALOG;
				else
					code = AKS_STATERESTOREDIALOG;
			}
			special = true;
			break;
#endif

		case DIK_1:
		case DIK_2:
		case DIK_3:
		case DIK_4:
		case DIK_5:
		case DIK_6:
		case DIK_7:
		case DIK_8:
		case DIK_9:
		case DIK_0:
			if (specialpressed ()) {
				int num = scancode - DIK_1;
				if (shiftpressed ())
					num += 10;
				if (ctrlpressed ()) {
					swapperdrive = num;
					if (swapperdrive > 3)
						swapperdrive = 0;
				} else {
					int i;
					for (i = 0; i < 4; i++) {
						if (!_tcscmp (currprefs.floppyslots[i].df, currprefs.dfxlist[num]))
							changed_prefs.floppyslots[i].df[0] = 0;
					}
					_tcscpy (changed_prefs.floppyslots[swapperdrive].df, currprefs.dfxlist[num]);
					set_config_changed ();
				}
				special = true;
			}
			break;
		case DIK_NUMPAD0:
		case DIK_NUMPAD1:
		case DIK_NUMPAD2:
		case DIK_NUMPAD3:
		case DIK_NUMPAD4:
		case DIK_NUMPAD5:
		case DIK_NUMPAD6:
		case DIK_NUMPAD7:
		case DIK_NUMPAD8:
		case DIK_NUMPAD9:
		case DIK_NUMPADPERIOD:
			if (specialpressed ()) {
				int i = 0, v = -1;
				while (np[i] >= 0) {
					v = np[i + 1];
					if (np[i] == scancode)
						break;
					i += 2;
				}
				if (v >= 0)
					code = AKS_STATESAVEQUICK + v * 2 + ((shiftpressed () || ctrlpressed ()) ? 0 : 1);
				special = true;
			}
			break;
#if 0
		case DIK_PAUSE:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_IRQ7;
				else
					code = AKS_WARP;
			} else {
				code = AKS_PAUSE;
			}
			special = true;
			break;
#if 0
		case DIK_SCROLL:
			code = AKS_INHIBITSCREEN;
			break;
#endif
		case DIK_NUMPADMINUS:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_DECREASEREFRESHRATE;
				else if (ctrlpressed ())
					code = AKS_MVOLDOWN;
				else
					code = AKS_VOLDOWN;
			}
			special = true;
			break;
		case DIK_NUMPADPLUS:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_INCREASEREFRESHRATE;
				else if (ctrlpressed ())
					code = AKS_MVOLUP;
				else
					code = AKS_VOLUP;
			}
			special = true;
			break;
		case DIK_NUMPADSTAR:
			if (specialpressed ()) {
				if (ctrlpressed ())
					code = AKS_MVOLMUTE;
				else
					code = AKS_VOLMUTE;
			}
			special = true;
			break;
		case DIK_NUMPADSLASH:
			if (specialpressed ())
				code = AKS_STATEREWIND;
			special = true;
			break;
#endif
		}
	}

	if (code) {
		inputdevice_add_inputcode (code, 1);
		return true;
	}


	scancode = scancode_new;
	if (!specialpressed () && newstate) {
		if (scancode == DIK_CAPITAL) {
			host_capslockstate = host_capslockstate ? 0 : 1;
			capslockstate = host_capslockstate;
		}
		if (scancode == DIK_NUMLOCK) {
			host_numlockstate = host_numlockstate ? 0 : 1;
			capslockstate = host_numlockstate;
		}
		if (scancode == DIK_SCROLL) {
			host_scrolllockstate = host_scrolllockstate ? 0 : 1;
			capslockstate = host_scrolllockstate;
		}
	}

	if (special) {
		inputdevice_checkqualifierkeycode (keyboard, scancode, newstate);
		return true;
	}

	return inputdevice_translatekeycode (keyboard, scancode, newstate) != 0;
}
예제 #7
0
파일: xwin.c 프로젝트: CrashSerious/PiUAE
void handle_events (void)
{
    for (;;) {
	XEvent event;
#if 0
	if (! XCheckMaskEvent (display, eventmask, &event))
	    break;
#endif
	if (! XPending (display))
	    break;

	XNextEvent (display, &event);

	switch (event.type) {
	 case KeyPress:
	 case KeyRelease: {
	    int state = (event.type == KeyPress);

	    if (currprefs.map_raw_keys) {
		unsigned int keycode = ((XKeyEvent *)&event)->keycode;
		unsigned int ievent;

		if ((ievent = match_hotkey_sequence (keycode, state)))
		    handle_hotkey_event (ievent, state);
		else
		    inputdevice_translatekeycode (0, keycode, state);
	    } else {
		KeySym keysym;
		int index = 0;
		int ievent, amiga_keycode;
		do {
		    keysym = XLookupKeysym ((XKeyEvent *)&event, index);
		    if ((ievent = match_hotkey_sequence (keysym, state))) {
			handle_hotkey_event (ievent, state);
			break;
		    } else
			if ((amiga_keycode = xkeysym2amiga (keysym)) >= 0) {
			    inputdevice_do_keyboard (amiga_keycode, state);
			    break;
			}
		    index++;
		} while (keysym != NoSymbol);
	    }
	    break;
	 }
	 case ButtonPress:
	 case ButtonRelease: {
	    int state = (event.type == ButtonPress);
	    int buttonno = -1;
	    switch ((int)((XButtonEvent *)&event)->button) {
		case 1:  buttonno = 0; break;
		case 2:  buttonno = 2; break;
		case 3:  buttonno = 1; break;
		/* buttons 4 and 5 report mousewheel events */
		case 4:  if (state) record_key (0x7a << 1); break;
		case 5:  if (state) record_key (0x7b << 1); break;
	    }
            if (buttonno >=0)
		setmousebuttonstate(0, buttonno, state);
	    break;
	 }
	 case MotionNotify:
	    if (dgamode) {
		int tx = ((XMotionEvent *)&event)->x_root;
		int ty = ((XMotionEvent *)&event)->y_root;
		setmousestate (0, 0, tx, 0);
		setmousestate (0, 1, ty, 0);
	    } else if (grabbed) {
		int realmove = 0;
		int tx, ty,ttx,tty;

		tx = ((XMotionEvent *)&event)->x;
		ty = ((XMotionEvent *)&event)->y;

		if (! event.xmotion.send_event) {
		    setmousestate( 0,0,tx-oldx,0);
		    setmousestate( 0,1,ty-oldy,0);
		    realmove = 1;
#undef ABS
#define ABS(a) (((a)<0) ? -(a) : (a) )
		    if (ABS(current_width / 2 - tx) > 3 * current_width / 8
			|| ABS(current_height / 2 - ty) > 3 * current_height / 8)
		    {
#undef ABS
			XEvent event;
			ttx = current_width / 2;
			tty = current_height / 2;
			event.type = MotionNotify;
			event.xmotion.display = display;
			event.xmotion.window = mywin;
			event.xmotion.x = ttx;
			event.xmotion.y = tty;
			XSendEvent (display, mywin, False,
				    PointerMotionMask, &event);
			XWarpPointer (display, None, mywin, 0, 0, 0, 0, ttx, tty);
		    }
		} else {
		    tx=event.xmotion.x;
		    ty=event.xmotion.y;
		}
		oldx = tx;
		oldy = ty;
	    } else if (inwindow) {
		int tx = ((XMotionEvent *)&event)->x;
		int ty = ((XMotionEvent *)&event)->y;
		setmousestate(0,0,tx,1);
		setmousestate(0,1,ty,1);
		if (! cursorOn && !currprefs.hide_cursor) {
		    XDefineCursor(display, mywin, xhairCursor);
		    cursorOn = 1;
		}
		gettimeofday(&lastMotionTime, NULL);
	    }
	    break;
	 case EnterNotify:
	    {
		int tx = ((XCrossingEvent *)&event)->x;
		int ty = ((XCrossingEvent *)&event)->y;
		setmousestate(0,0,tx,1);
		setmousestate(0,1,ty,1);
	    }
	    inwindow = 1;
	    break;
	 case LeaveNotify:
	    inwindow = 0;
	    break;
	 case FocusIn:
	    if (! autorepeatoff)
		XAutoRepeatOff (display);
	    autorepeatoff = 1;
	    break;
	 case FocusOut:
	    if (autorepeatoff)
		XAutoRepeatOn (display);
	    autorepeatoff = 0;
	    inputdevice_release_all_keys ();
	    break;
	 case Expose:
	    refresh_necessary = 1;
	    break;
         case ClientMessage:
            if (((Atom)event.xclient.data.l[0]) == delete_win) {
		uae_stop ();
            }
            break;
	}
    }

#if defined PICASSO96
    if (! dgamode) {
	if (screen_is_picasso && refresh_necessary) {
	    DO_PUTIMAGE (pic_dinfo.ximg, 0, 0, 0, 0,
			 picasso_vidinfo.width, picasso_vidinfo.height);
	    XFlush (display);
	    refresh_necessary = 0;
	    memset (picasso_invalid_lines, 0, sizeof picasso_invalid_lines);
	} else if (screen_is_picasso && picasso_has_invalid_lines) {
	    int i;
	    int strt = -1;

	    picasso_invalid_lines[picasso_vidinfo.height] = 0;
	    for (i = picasso_invalid_start; i < picasso_invalid_stop + 2; i++) {
		if (picasso_invalid_lines[i]) {
		    picasso_invalid_lines[i] = 0;
		    if (strt != -1)
			continue;
		    strt = i;
		} else {
		    if (strt == -1)
			continue;
		    DO_PUTIMAGE (pic_dinfo.ximg, 0, strt, 0, strt,
				 picasso_vidinfo.width, i - strt);
		    strt = -1;
		}
	    }
	    XFlush (display);
	    if (strt != -1)
		abort ();
	}
    }
    picasso_has_invalid_lines = 0;
    picasso_invalid_start = picasso_vidinfo.height + 1;
    picasso_invalid_stop = -1;
#endif

    if (! dgamode) {
	if (! screen_is_picasso && refresh_necessary) {
	    DO_PUTIMAGE (ami_dinfo.ximg, 0, 0, 0, 0, current_width, current_height);
	    refresh_necessary = 0;
	}
	if (cursorOn && !currprefs.hide_cursor) {
	    struct timeval now;
	    int diff;
	    gettimeofday(&now, NULL);
	    diff = (now.tv_sec - lastMotionTime.tv_sec) * 1000000 +
		(now.tv_usec - lastMotionTime.tv_usec);
	    if (diff > 1000000) {
		XDefineCursor (display, mywin, blankCursor);
		cursorOn = 0;
	    }
	}
    }
}