Ejemplo n.º 1
0
static void my_kbd_handlerx (int scancode, int newstate)
{
    int akey = scancode2amiga (scancode);

    assert (scancode >= 0 && scancode < 0x100);
    if (scancode == SCODE_F12) {
	uae_quit ();
    } else if (scancode == SCODE_F11) {
	gui_requested = 1;
    }
    if (keystate[scancode] == newstate)
	return;

    keystate[scancode] = newstate;

    if (akey == -1)
	return;

    if (newstate == KEY_EVENTPRESS) {
	if (akey == AK_inhibit)
	    toggle_inhibit_frame (0);
	else
	    record_key (akey << 1);
    } else
	record_key ((akey << 1) | 1);

    /* "Affengriff" */
    if ((keystate[AK_CTRL] || keystate[AK_RCTRL]) && keystate[AK_LAMI] && keystate[AK_RAMI])
	uae_reset ();
}
Ejemplo n.º 2
0
// apply the remapped button keystroke
void handle_remapped_button_down(int button)
{
	int key = get_key_for_button(button);
	if (!uae4all_keystate[key])
	{
		uae4all_keystate[key] = 1;
		record_key(key << 1);
	}
}
Ejemplo n.º 3
0
void handle_remapped_button_up(int button)
{
	int key = get_key_for_button(button);

	if (uae4all_keystate[key])
	{
		uae4all_keystate[key] = 0;
		record_key((key << 1) | 1);
	}
}
int main(int argc, char** argv) {
                 
      if(argc != 7 ) {
        fprintf(stderr, "ERROR: usage: <host> <port> <service-type> "
		"<key-type-str> <md5-fingerprint> <report-sock-name>\n");
        exit(1);
      }
      
      if(strlen(argv[1]) > (MAX_NAME_LEN + 10)) { 
	fprintf(stderr,"ERROR: DNS name / IP '%s' is too long\n", argv[1]); 
	exit(1); 
      }
      char *dns_name = argv[1], key_buf[KEY_LEN];
      uint32_t port = (uint32_t)atoi(argv[2]);
      if(port > 0xffff) { 
	fprintf(stderr, "ERROR: Invalid port number %d \n", port); 
	exit(1); 
      } 
      uint32_t service_type = (uint32_t) atoi(argv[3]);
      if(service_type != SERVICE_TYPE_SSL && 
	 service_type != SERVICE_TYPE_SSH) { 
	fprintf(stderr,"ERROR: Invalid service-type '%d'\n", 
		service_type); 
	exit(1); 
      } 
      int key_str_len = (KEY_LEN * 3) - 1; 
      if(strlen(argv[5]) != key_str_len) { 
	fprintf(stderr, 
	   "ERROR: Need a semi-colon delimited MD5 "
	   "fingerprint of length %d\n", key_str_len);
	exit(1);  
      }
      int len = hexstr_2_buf(argv[5],key_buf,KEY_LEN); 
      if(len != KEY_LEN) { 
	fprintf(stderr, "ERROR: Failed to parse MD5 fingerprint '%s',"
		" len %d != %d \n", argv[5], len, KEY_LEN); 
	exit(1); 
      }
      uint32_t key_type = str_2_keytype(argv[4]); 
      if(key_type == INVALID_KEY_TYPE) { 
	 fprintf(stderr, "ERROR: Invalid key type '%s'\n", argv[4]); 
         exit(1); 
      } 
      return record_key(dns_name, 0 /*no ip address*/, port, key_buf, KEY_LEN, 
			key_type, "", service_type, argv[6]); 
}
Ejemplo n.º 5
0
void handle_events (void)
{
    SDL_Event rEvent;
    int iAmigaKeyCode;
    int i, j;
    int iIsHotKey = 0;
#ifdef DEBUG_EVENTS
    dbg("Function: handle_events");
#endif


#if defined(MAX_AUTOEVENTS) || defined(AUTOEVENTS)
	{
		static unsigned cuenta=0;
/*
		switch(cuenta&63)
		{
			case 8:
				if ((cuenta<6500)||(cuenta>8000))
					joy1button=1;
				break;
			case 16:
				buttonstate[0]=1; break;
			case 24:
				joy1button=0; break;
			case 28:
				if (cuenta>11000)
					joy1dir=3;
				break;
			case 32:
				buttonstate[0]=0; break;
			case 62:
				joy1dir=0; break;
		}
//		lastmy+=8;
		switch(cuenta&127)
		{
			case 20:
				record_key(0x12); break;
			case 40:
				record_key(0x13); break;
			case 60:
				record_key(0x88); break;
			case 80:
				record_key(0x89); break;
		}
*/
/*
if (cuenta==7700)
{
strcpy(changed_df[0],"prueba2.adz");
real_changed_df[0]=1;
joy1button=1;
}
*/

// Defender of the Crown
 /*
switch(cuenta)
{
case 2600:
lastmx+=80;
break;
case 2610:
buttonstate[0]=1; break;
break;
case 2615:
buttonstate[0]=0; break;
break;
case 4500:
lastmy+=100;
break;
case 4510:
buttonstate[0]=1; break;
break;
case 4515:
buttonstate[0]=0; break;
break;
case 4640:
lastmy-=60;
lastmx+=550;
break;
case 4700:
lastmx+=200;
break;
case 4710:
buttonstate[0]=1; break;
break;
case 4715:
buttonstate[0]=0; break;
break;


}
// printf("%i -> %.8X\n",cuenta,chipmem_checksum());
 */


#if defined(START_DEBUG) && !defined(START_DEBUG_SAVESTATE)
		if (cuenta==START_DEBUG)
		{
#ifdef DEBUG_FILE
			if (!DEBUG_STR_FILE)
				DEBUG_STR_FILE=fopen(DEBUG_FILE,"wt");
#endif
			DEBUG_AHORA=1;
		}
#else
#ifdef START_DEBUG_SAVESTATE
		if (cuenta==START_DEBUG)
			savestate_state = STATE_DOSAVE;
#endif
#endif
#ifdef AUTO_SAVESTATE
		if (cuenta==AUTO_SAVESTATE)
			savestate_state = STATE_DORESTORE;
#endif

#ifdef MAX_AUTOEVENTS
#ifdef DEBUG_EVENTS
		dbgf(" AUTO EVENTS: %i =?= %i\n",cuenta,MAX_AUTOEVENTS);
#endif
		if (cuenta>MAX_AUTOEVENTS)
		{
			int i;
#ifdef DEBUG_FILE
			fclose(DEBUG_STR_FILE);
			SDL_Delay(100);
			for(i=0;i<0x10000;i+=78)
			{
				SDL_FillRect(prSDLScreen, NULL, i);
				SDL_Flip(prSDLScreen);
			}
			SDL_Delay(333);
#endif
			exit(0);
		}
		else
			dbgf("handle_events %i\n",cuenta);
#endif
		cuenta++;
	}
#else
    /* Handle GUI events */
    gui_handle_events ();

#ifdef EMULATED_JOYSTICK
	{
		if ((vkbd_button3==(SDLKey)0)&&(!vkbd_mode))
			buttonstate[0]=emulated_mouse_button1;
		if ((vkbd_button4==(SDLKey)0)&&(!vkbd_mode))
			buttonstate[2]=emulated_mouse_button2;
	}
#endif

    while (SDL_PollEvent(&rEvent))
    {
	switch (rEvent.type)
	{
	case SDL_QUIT:
#ifdef DEBUG_EVENTS
	    dbg("Event: quit");
#endif
	    uae_quit();
	    break;
	    break;
	case SDL_JOYBUTTONDOWN:
	    if (vkbd_mode) break;
	    if ((rEvent.jbutton.button==6) && (vkbd_button2!=(SDLKey)0))
		    rEvent.key.keysym.sym=vkbd_button2;
	    else if ((rEvent.jbutton.button==5) && (vkbd_button3!=(SDLKey)0))
		    rEvent.key.keysym.sym=vkbd_button3;
	    else if ((rEvent.jbutton.button==1) && (vkbd_button4!=(SDLKey)0))
		    rEvent.key.keysym.sym=vkbd_button4;
	    else
	    	break;
        case SDL_KEYDOWN:
#ifdef DEBUG_EVENTS
	    dbg("Event: key down");
#endif
#ifndef DREAMCAST
	    if ((rEvent.key.keysym.sym!=SDLK_F11)&&(rEvent.key.keysym.sym!=SDLK_F12)&&(rEvent.key.keysym.sym!=SDLK_PAGEUP)
#ifdef EMULATED_JOYSTICK
		&&(rEvent.key.keysym.sym!=SDLK_ESCAPE)&&((rEvent.key.keysym.sym!=SDLK_SPACE)||((rEvent.key.keysym.sym==SDLK_SPACE)&&(vkbd_button3!=(SDLKey)0)&&(!vkbd_mode)))&&(rEvent.key.keysym.sym!=SDLK_LCTRL)&&((rEvent.key.keysym.sym!=SDLK_LALT)||((rEvent.key.keysym.sym==SDLK_LALT)&&(vkbd_button2!=(SDLKey)0)&&(!vkbd_mode)))&&(rEvent.key.keysym.sym!=SDLK_RETURN)&&((rEvent.key.keysym.sym!=SDLK_LSHIFT)||((rEvent.key.keysym.sym==SDLK_LSHIFT)&&(vkbd_button4!=(SDLKey)0)&&(!vkbd_mode)))&&(rEvent.key.keysym.sym!=SDLK_TAB)&&(rEvent.key.keysym.sym!=SDLK_BACKSPACE)&&(rEvent.key.keysym.sym!=SDLK_UP)&&(rEvent.key.keysym.sym!=SDLK_DOWN)&&(rEvent.key.keysym.sym!=SDLK_LEFT)&&(rEvent.key.keysym.sym!=SDLK_RIGHT)
#endif
			    )
	    {
		    if ((rEvent.key.keysym.sym==SDLK_LALT)&&(vkbd_button2!=(SDLKey)0)&&(!vkbd_mode))
			    rEvent.key.keysym.sym=vkbd_button2;
		    else
		    if ((rEvent.key.keysym.sym==SDLK_LSHIFT)&&(vkbd_button4!=(SDLKey)0)&&(!vkbd_mode))
			    rEvent.key.keysym.sym=vkbd_button4;
		    else
		    if ((rEvent.key.keysym.sym==SDLK_SPACE)&&(vkbd_button3!=(SDLKey)0)&&(!vkbd_mode))
			    rEvent.key.keysym.sym=vkbd_button3;
#else
	    {
#endif
		iAmigaKeyCode = keycode2amiga(&(rEvent.key.keysym));
		if (iAmigaKeyCode >= 0)
		{
		    if (!uae4all_keystate[iAmigaKeyCode])
		    {
			uae4all_keystate[iAmigaKeyCode] = 1;
			record_key(iAmigaKeyCode << 1);
		    }
		}
	    }
	    break;
	case SDL_JOYBUTTONUP:
	    if (vkbd_mode) break;
	    if ((rEvent.jbutton.button==6) && (vkbd_button2!=(SDLKey)0))
		    rEvent.key.keysym.sym=vkbd_button2;
	    else if ((rEvent.jbutton.button==5) && (vkbd_button3!=(SDLKey)0))
		    rEvent.key.keysym.sym=vkbd_button3;
	    else if ((rEvent.jbutton.button==1) && (vkbd_button4!=(SDLKey)0))
		    rEvent.key.keysym.sym=vkbd_button4;
	    else
	    	break;
	case SDL_KEYUP:
#ifdef DEBUG_EVENTS
	    dbg("Event: key up");
#endif
#ifndef DREAMCAST
	    if ((rEvent.key.keysym.sym!=SDLK_F11)&&(rEvent.key.keysym.sym!=SDLK_F12)&&(rEvent.key.keysym.sym!=SDLK_PAGEUP)
#ifdef EMULATED_JOYSTICK
		&&(rEvent.key.keysym.sym!=SDLK_ESCAPE)&&((rEvent.key.keysym.sym!=SDLK_SPACE)||((rEvent.key.keysym.sym==SDLK_SPACE)&&(vkbd_button3!=(SDLKey)0)&&(!vkbd_mode)))&&(rEvent.key.keysym.sym!=SDLK_LCTRL)&&((rEvent.key.keysym.sym!=SDLK_LALT)||((rEvent.key.keysym.sym==SDLK_LALT)&&(vkbd_button2!=(SDLKey)0)&&(!vkbd_mode)))&&(rEvent.key.keysym.sym!=SDLK_RETURN)&&((rEvent.key.keysym.sym!=SDLK_LSHIFT)||((rEvent.key.keysym.sym==SDLK_LSHIFT)&&(vkbd_button4!=(SDLKey)0)&&(!vkbd_mode)))&&(rEvent.key.keysym.sym!=SDLK_TAB)&&(rEvent.key.keysym.sym!=SDLK_BACKSPACE)&&(rEvent.key.keysym.sym!=SDLK_UP)&&(rEvent.key.keysym.sym!=SDLK_DOWN)&&(rEvent.key.keysym.sym!=SDLK_LEFT)&&(rEvent.key.keysym.sym!=SDLK_RIGHT)
#endif
			    )
	    {
		    if ((rEvent.key.keysym.sym==SDLK_LALT)&&(vkbd_button2!=(SDLKey)0)&&(!vkbd_mode))
			    rEvent.key.keysym.sym=vkbd_button2;
		    else
		    if ((rEvent.key.keysym.sym==SDLK_LSHIFT)&&(vkbd_button4!=(SDLKey)0)&&(!vkbd_mode))
			    rEvent.key.keysym.sym=vkbd_button4;
		    else
		    if ((rEvent.key.keysym.sym==SDLK_SPACE)&&(vkbd_button3!=(SDLKey)0)&&(!vkbd_mode))
			    rEvent.key.keysym.sym=vkbd_button3;
#else
	    {
#endif
		iAmigaKeyCode = keycode2amiga(&(rEvent.key.keysym));
		if (iAmigaKeyCode >= 0)
		{
		    uae4all_keystate[iAmigaKeyCode] = 0;
		    record_key((iAmigaKeyCode << 1) | 1);
		}
	    }
	    break;
	case SDL_MOUSEBUTTONDOWN:
#ifdef DEBUG_EVENTS
	    dbg("Event: mouse button down");
#endif
#ifdef DREAMCAST
	    if (__sdl_dc_emulate_mouse)
	    {
	    	if (vkbd_mode) break;
	    	if (rEvent.button.button==5 ) {
			if (vkbd_button3==(SDLKey)0)
			    buttonstate[0] = 1;
			else 
				break;
		}
	    	else if (rEvent.button.button==1)  {
			if (vkbd_button4==(SDLKey)0)
		 	   buttonstate[2] = 1;
			else
				break;
		}
	    }
	    else
	    	if (rEvent.button.button)
			buttonstate[2]=1;
		else
			buttonstate[0]=1;
#else
	    	buttonstate[(rEvent.button.button-1)%3] = 1;
#endif
	    break;
	case SDL_MOUSEBUTTONUP:
#ifdef DEBUG_EVENTS
	    dbg("Event: mouse button up");
#endif
#ifdef DREAMCAST
	    if (__sdl_dc_emulate_mouse)
	    {
	    	if (vkbd_mode) break;
	    	if (rEvent.button.button==5) {
			if (vkbd_button3==(SDLKey)0)
			    buttonstate[0] = 0;
			else
				break;
		}
	    	else if (rEvent.button.button==1) {
			if (vkbd_button4==(SDLKey)0)
			    buttonstate[2] = 0;
			else
				break;
		}
	    }
	    else
	    	if (rEvent.button.button)
			buttonstate[2]=0;
		else
			buttonstate[0]=0;
				
#else
	    	buttonstate[(rEvent.button.button-1)%3] = 0;
#endif
	    break;
	case SDL_MOUSEMOTION:
#ifdef DEBUG_EVENTS
	    dbg("Event: mouse motion");
#endif
	    lastmx += rEvent.motion.xrel<<1;
	    lastmy += rEvent.motion.yrel<<1;
	    newmousecounters = 1;
	    break;
	}
    }
#endif


    /* Handle UAE reset */
/*
    if ((uae4all_keystate[AK_CTRL] || uae4all_keystate[AK_RCTRL]) && uae4all_keystate[AK_LAMI] && uae4all_keystate[AK_RAMI])
	uae_reset ();
*/
#ifdef DEBUG_EVENTS
    dbg(" handle_events -> terminado");
#endif
}

int check_prefs_changed_gfx (void)
{
	extern int mainMenu_vpos;
	static int last_vpos=0;
	int ret=(last_vpos!=mainMenu_vpos);
	last_vpos=mainMenu_vpos;
	return ret;
}

int debuggable (void)
{
    return 1;
}

int needmousehack (void)
{
    return 1;
}



#if !defined(DREAMCAST) && !defined(DINGOO)
int lockscr (void)
{
#ifdef DEBUG_GFX
    dbg("Function: lockscr");
#endif
    if (SDL_MUSTLOCK(prSDLScreen))
	SDL_LockSurface(prSDLScreen);
    return 1;
}

void unlockscr (void)
{
#ifdef DEBUG_GFX
    dbg("Function: unlockscr");
#endif
    if (SDL_MUSTLOCK(prSDLScreen))
    	SDL_UnlockSurface(prSDLScreen);
}
Ejemplo n.º 6
0
/* there's a problem remaining with the semantics of the '#' key on U.S. keyboards */
static int scancode2amiga (int keycode, int scancode)
{
	static int firstscan=0;
	if (!firstscan)
	{
	    keyboardlayoutid=GetKeyboardLayout(0);
	    keyboardlangid=LOWORD(keyboardlayoutid);
	    firstscan=1;
	}
#if DEBUG_KBD
    write_log ( "keycode = 0x%x, scancode = 0x%x\n", keycode, scancode ); 
#endif

    if(keyboardlangid==MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN))
    {
	if (keystate[AK_CTRL] &&
	    keystate[AK_RALT])
	{
	    switch (keycode & 0xff) 
	    {
	    case 0xdb:
		return AK_BACKSLASH;
	    case 0x51:          //@	     
		record_key ((AK_CTRL << 1)+1);
		return 0x10;
	    case 0xbb:          //~
		record_key ((AK_CTRL << 1)+1);
		return 0x1b;
		
	    }
	}
    }

#define USE_OLD_SHIFT_CODE

    switch (keycode & 0xff) 
    {
#ifndef USE_OLD_SHIFT_CODE
    case VK_SHIFT:
	{
	    SHORT lsh, rsh;
	    lsh = GetKeyState( VK_LSHIFT );
	    rsh = GetKeyState( VK_RSHIFT );
	    if( !keystate[AK_RSH] && (rsh & 0x8000))
		return AK_RSH;
	    if( keystate[AK_RSH] && !(rsh & 0x8000))
		return AK_RSH;
	    if( !keystate[AK_LSH] && (lsh & 0x8000))
		return AK_LSH;
	    if( keystate[AK_LSH] && !(lsh & 0x8000))
		return AK_LSH;
	}
#endif
     case VK_INSERT:
     case VK_LWIN:
	return AK_LAMI;
     case VK_HOME:
     case VK_RWIN:
	return AK_RAMI;
     case VK_MENU:
	 return scancode & KF_EXTENDED ? AK_RALT:AK_LALT;
     case VK_APPS: /* Map Windows "Menu" key to Right-Alt of Amiga, for Stefan Stuntz */
	 return AK_RALT;
     case VK_SCROLL:
	return AK_inhibit;
     case VK_F11:
#if 0
	 if( currprefs.win32_ctrl_F11_is_quit )
	 {
	    if (GetAsyncKeyState (VK_CONTROL)&0x8000)
		uae_quit();
	 }
#endif
	 return AK_BACKSLASH;
     case VK_F12:
	 if (GetAsyncKeyState (VK_CONTROL)&0x8000)
	     return -6;
	 if( shiftpressed() )
	     return -5;
	 else
	     return -2;
	 break;
     case VK_PAUSE:
	return -3;
     case VK_DECIMAL:
	return AK_NPDEL;
     case VK_DIVIDE:
	return AK_NPDIV;
     case VK_MULTIPLY:
	return AK_NPMUL;
     case VK_SUBTRACT:
	return AK_NPSUB;
     case VK_ADD:
	return AK_NPADD;
     case VK_NUMPAD0:
	return AK_NP0;
     case VK_NUMPAD1:
	return AK_NP1;
     case VK_NUMPAD2:
	return AK_NP2;
     case VK_NUMPAD3:
	return AK_NP3;
     case VK_NUMPAD4:
	return AK_NP4;
     case VK_NUMPAD5:
	return AK_NP5;
     case VK_NUMPAD6:
	return AK_NP6;
     case VK_NUMPAD7:
	return AK_NP7;
     case VK_NUMPAD8:
	return AK_NP8;
     case VK_NUMPAD9:
	return AK_NP9;
     case VK_UP:
	return AK_UP;
     case VK_DOWN:
	return AK_DN;
     case VK_LEFT:
	return AK_LF;
     case VK_RIGHT:
	return AK_RT;
     case VK_CONTROL:
	return scancode & KF_EXTENDED ? AK_RCTRL : AK_CTRL;
     case VK_RETURN:
	return scancode & KF_EXTENDED ? AK_ENT : AK_RET;
     case VK_CAPITAL:
	return -4;
     case VK_F1:
	if (helppressed ())
	    return -10 - shiftpressed ();
	return AK_F1;
     case VK_F2:
	if (helppressed ())
	    return -12 - shiftpressed ();
	return AK_F2;
    case VK_F3:
	if (helppressed ())
	    return -14 - shiftpressed ();
	return AK_F3;
    case VK_F4:
	if (helppressed ())
	    return -16 - shiftpressed ();
	return AK_F4;
     case VK_F5:
	return AK_F5;
     case VK_F6:
	return AK_F6;
     case VK_F7:
	return AK_F7;
     case VK_F8:
	return AK_F8;
     case VK_F9:
	return AK_F9;
     case VK_F10:
	return AK_F10;
     case VK_NEXT:
	return AK_HELP;
    }

    switch (scancode) {
     case 0x01:
	return 0x45;
     case 0x29:
	return 0x00;
     case 0x02:
	return 0x01;
     case 0x03:
	return 0x02;
     case 0x04:
	return 0x03;
     case 0x05:
	return 0x04;
     case 0x06:
	return 0x05;
     case 0x07:
	return 0x06;
     case 0x08:
	return 0x07;
     case 0x09:
	return 0x08;
     case 0x0a:
	return 0x09;
     case 0x0b:
	return 0x0a;
     case 0x0c:
	return 0x0b;
     case 0x0d:
	return 0x0c;
     case 0x57: /* This is F11 */
	return AK_BACKSLASH;
     case 0x0e:
	return 0x41;
     case 0x0f:
	return 0x42;
     case 0x10:
	return 0x10;
     case 0x11:
	return 0x11;
     case 0x12:
	return 0x12;
     case 0x13:
	return 0x13;
     case 0x14:
	return 0x14;
     case 0x15:
	return 0x15;
     case 0x16:
	return 0x16;
     case 0x17:
	return 0x17;
     case 0x18:
	return 0x18;
     case 0x19:
	return 0x19;
     case 0x1a:
	return 0x1a;
     case 0x1b:
	return 0x1b;
	/* special handling for caps lock: return 0x63*/
     case 0x3a:
	return 0x62;
     case 0x1e:
	return 0x20;
     case 0x1f:
	return 0x21;
     case 0x20:
	return 0x22;
     case 0x21:
	return 0x23;
     case 0x22:
	return 0x24;
     case 0x23:
	return 0x25;
     case 0x24:
	return 0x26;
     case 0x25:
	return 0x27;
     case 0x26:
	return 0x28;
     case 0x27:
	return AK_SEMICOLON;
     case 0x28:
	return AK_QUOTE;
     case 0x2b: /* This scancode is \ on US keyboards, but # on German ones - figure out which! */
	 if( getascii( keycode & 0xFF, scancode ) == '#' )
	     return AK_NUMBERSIGN;
	 else
	     return AK_BACKSLASH;
	 break;
#ifdef USE_OLD_SHIFT_CODE
     case 0x2a:
	return AK_LSH;
     case 0x36:
	return AK_RSH;
#endif
     case 0x56:
	return AK_LTGT;
     case 0x2c:
	return 0x31;
     case 0x2d:
	return 0x32;
     case 0x2e:
	return 0x33;
     case 0x2f:
	return 0x34;
     case 0x30:
	return 0x35;
     case 0x31:
	return 0x36;
     case 0x32:
	return 0x37;
     case 0x33:
	return 0x38;
     case 0x34:
	return 0x39;
     case 0x35:
	return 0x3a;
     case 0x38:
	return 0x64;
     case 0x39:
	return 0x40;
     case 0x153:
	return 0x46;
     case 0x51:
	return 0x5f;
     case 0x52:
	return AK_LAMI;
     case 0x47:
	return AK_RAMI;
     case 0x4b:
	return 0x4f;
     case 0x50:
	return 0x4d;
     case 0x4d:
	return 0x4e;
     case 0x48:
	return 0x4c;
     case 0x4e:
	return 0x5e;
     case 0x4a:
	return 0x4a;
     case 0x37:
	return 0x5d;
    }

    return -1;
}
Ejemplo n.º 7
0
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;
	    }
	}
    }
}
Ejemplo n.º 8
0
//pnd_nubstate_t t;
void gui_handle_events (void)
{
	printf("gui_handle_events\n");
/*if(blubb<0)
{
	test = pnd_evdev_open(pnd_evdev_nub1);
	printf("nub1 open: %d\n", test);
	test = pnd_evdev_open(pnd_evdev_nub2);
	printf("nub2 open: %d\n", test);
	t.x=1;
	t.y=1;
	printf("nubstate 1: x=%d y=%d\n", t.x, t.y);
}
blubb++;
if(blubb>100 && blubb<0)
{
	pnd_evdev_catchup(1);
	blubb=0;
}
test = pnd_evdev_nub_state(pnd_evdev_nub1, &t);
printf("nubstate 1: x=%d y=%d, returnvalue=%d\n", t.x, t.y, test);
pnd_evdev_nub_state(pnd_evdev_nub2, &t);
printf("nubstate 2: x=%d y=%d\n", t.x, t.y);
*/

#if ! defined (DREAMCAST) && ! defined (GP2X) && ! defined (PSP) && ! defined (GIZMONDO)
	Uint8 *keystate = SDL_GetKeyState(NULL);
	if ( keystate[SDLK_F12] )
		SDL_WM_ToggleFullScreen(prSDLScreen);
	else
	if ( keystate[SDLK_F11] )
#else
#ifdef DREAMCAST
	if (SDL_JoystickGetButton(uae4all_joy0,3) )
#endif
#ifdef GP2X
    if (SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_SELECT))
#endif
#ifdef PSP
	if (SDL_JoystickGetButton(uae4all_joy0, PSP_BUTTON_SELECT))
#endif
#ifdef GIZMONDO
	Uint8 *keystate = SDL_GetKeyState(NULL);
	if ( keystate[SDLK_F1] )
#endif
#endif
#ifdef GP2X
	{
		// hack: always use SDL_SWSURFACE in menus
		//switch_to_sw_sdl();
		goMenu();
		//switch_to_hw_sdl(0);
	}
#else
		goMenu();
#endif

#ifndef PANDORA
#if defined (DREAMCAST) || defined (GP2X) || defined (PSP) || defined (GIZMONDO)
#ifdef DREAMCAST
	if (SDL_JoystickGetAxis (uae4all_joy0, 2))
		if (vkbd_mode)
		{
			vkbd_mode=0;
   			notice_screen_contents_lost();
		}
	if (SDL_JoystickGetAxis (uae4all_joy0, 3))
		vkbd_mode=1;
#else

	if (!gp2xMouseEmuOn && !gp2xButtonRemappingOn)
	{
#ifdef GP2X
		if (SDL_JoystickGetButton (uae4all_joy0, GP2X_BUTTON_L))
#else
#ifdef GIZMONDO
		if (SDL_JoystickGetButton (uae4all_joy0, GIZ_LTRIG))
#else
		if (SDL_JoystickGetButton (uae4all_joy0, PSP_BUTTON_L))
#endif
#endif
		{
			/*if (vkbd_mode)
			{
				vkbd_mode = 0;
				goingVkbd=0;
				notice_screen_contents_lost();
			}
			else*/
				goingSuperThrottle=1;
		}
		else
		{
			if (!nowSuperThrottle)
				goingSuperThrottle=0;
			/*else
				goingVkbd=0;*/
		}

#ifdef GP2X
		if (SDL_JoystickGetButton (uae4all_joy0, GP2X_BUTTON_R))
#else
#ifdef GIZMONDO
		if (SDL_JoystickGetButton (uae4all_joy0, GIZ_RTRIG))
#else
		if (SDL_JoystickGetButton (uae4all_joy0, PSP_BUTTON_R))
#endif
#endif
		{
			if (goingSuperThrottle)
				goSuperThrottle();
			/*else
			{
				if (goingVkbd>4)
					vkbd_mode=1;
				else
					goingVkbd++;
			}*/
		}
		else
		{
			if (nowSuperThrottle)
				leftSuperThrottle();
			/*else
				goingVkbd=0;*/
		}
	}

#endif
#endif

	/*if (vkbd_key)
	{
		if (vkbd_keysave==-1234567)
		{
			SDL_keysym ks;
			ks.sym=vkbd_key;
			vkbd_keysave=keycode2amiga(&ks);
			if (vkbd_keysave >= 0)
			{
				if (!uae4all_keystate[vkbd_keysave])
				{
					uae4all_keystate[vkbd_keysave]=1;
					record_key(vkbd_keysave<<1);
				}
			}
		}
	}
	else
		if (vkbd_keysave!=-1234567)
		{
			if (vkbd_keysave >= 0)
			{
				uae4all_keystate[vkbd_keysave]=0;
				record_key((vkbd_keysave << 1) | 1);
			}
			vkbd_keysave=-1234567;
		}*/
#endif

#ifdef PANDORA
	Uint8 *keystate = SDL_GetKeyState(NULL);
	if(keystate[SDLK_F12])
	{
		if(hwScaled)
			SDL_WM_ToggleFullScreen(prSDLScreen);
		else
			SDL_WM_ToggleFullScreen(prSDLScaleScreen);
	}

if(!vkbd_mode)
{
	//L + R
	if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_R))
	{
		//up
		if(SDL_JoystickGetAxis(uae4all_joy0, 1) < 0)
		{
			moveVertical(1);
			moved_y += 2;
		}
		//down
		else if(SDL_JoystickGetAxis(uae4all_joy0, 1) > 0)
		{
			moveVertical(-1);
			moved_y -= 2;
		}
		//left
		else if(SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
		{
			screenWidth -=10;
			if(screenWidth<200)
				screenWidth = 200;
			update_display();
		}
		//right
		else if(SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
		{
			screenWidth +=10;
			if(screenWidth>800)
				screenWidth = 800;
			update_display();
		}
		//1
		else if(keystate[SDLK_1])
		{
			mainMenu_displayedLines = 200;
			screenWidth = 768;
			presetModeId = 0;
			strcpy(presetMode, "320x200 upscaled");
			update_display();
		}
		//2
		else if(keystate[SDLK_2])
		{
			mainMenu_displayedLines = 216;
			screenWidth = 716;
			presetModeId = 1;
			strcpy(presetMode, "320x216 upscaled");
			update_display();
		}
		//3
		else if(keystate[SDLK_3])
		{
			mainMenu_displayedLines = 240;
			screenWidth = 640;
			presetModeId = 2;
			strcpy(presetMode, "320x240 upscaled");
			update_display();
		}
		//4
		else if(keystate[SDLK_4])
		{
			mainMenu_displayedLines = 256;
			screenWidth = 600;
			presetModeId = 3;
			strcpy(presetMode, "320x256 upscaled");
			update_display();
		}
		//5
		else if(keystate[SDLK_5])
		{
			mainMenu_displayedLines = 262;
			screenWidth = 588;
			presetModeId = 4;
			strcpy(presetMode, "320x262 upscaled");
			update_display();
		}
		//6
		else if(keystate[SDLK_6])
		{
			mainMenu_displayedLines = 270;
			screenWidth = 570;
			presetModeId = 5;
			strcpy(presetMode, "320x270 upscaled");
			update_display();
		}
		//7
		else if(keystate[SDLK_7])
		{
			mainMenu_displayedLines = 200;
			screenWidth = 640;
			presetModeId = 6;
			strcpy(presetMode, "320x200 NTSC");
			update_display();
		}
		//8
		else if(keystate[SDLK_8])
		{
			mainMenu_displayedLines = 200;
			screenWidth = 800;
			presetModeId = 7;
			strcpy(presetMode, "320x200 fullscreen");
			update_display();
		}
	}

	//autofire on/off
	if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_R))
	{
		//(Y) button
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_Y))
		{
			if(!justPressedY)
			{
				//autofire on/off
				switch_autofire = !switch_autofire;
				justPressedY=1;
			}
		}
		else if(justPressedY)
			justPressedY=0;
	}

	if (mainMenu_customControls && !gp2xMouseEmuOn && !gp2xButtonRemappingOn)
	{
		if(mainMenu_custom_dpad == 0)
		{
			//UP
			if(SDL_JoystickGetAxis(uae4all_joy0, 1) < 0)
			{
				if(!justMovedUp)
				{
					if(mainMenu_custom_up == -1) buttonstate[0]=1;
					else if(mainMenu_custom_up == -2) buttonstate[2]=1;
					else if(mainMenu_custom_up > 0)
					{
						getMapping(mainMenu_custom_up);
						uae4all_keystate[customKey] = 1;
						record_key(customKey << 1);
					}
					justMovedUp=1;
				}
			}
			else if(justMovedUp)
			{
				if(mainMenu_custom_up == -1) buttonstate[0]=0;
				else if(mainMenu_custom_up == -2) buttonstate[2]=0;
				else if(mainMenu_custom_up > 0)
				{
					getMapping(mainMenu_custom_up);
					uae4all_keystate[customKey] = 0;
					record_key((customKey << 1) | 1);
				}
				justMovedUp=0;
			}

			//DOWN
			if(SDL_JoystickGetAxis(uae4all_joy0, 1) > 0)
			{
				if(!justMovedDown)
				{
					if(mainMenu_custom_down == -1) buttonstate[0]=1;
					else if(mainMenu_custom_down == -2) buttonstate[2]=1;
					else if(mainMenu_custom_down > 0)
					{
						getMapping(mainMenu_custom_down);
						uae4all_keystate[customKey] = 1;
						record_key(customKey << 1);
					}
					justMovedDown=1;
				}
			}
			else if(justMovedDown)
			{
				if(mainMenu_custom_down == -1) buttonstate[0]=0;
				else if(mainMenu_custom_down == -2) buttonstate[2]=0;
				else if(mainMenu_custom_down > 0)
				{
					getMapping(mainMenu_custom_down);
					uae4all_keystate[customKey] = 0;
					record_key((customKey << 1) | 1);
				}
				justMovedDown=0;
			}

			//LEFT
			if(SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
			{
				if(!justMovedLeft)
				{
					if(mainMenu_custom_left == -1) buttonstate[0]=1;
					else if(mainMenu_custom_left == -2) buttonstate[2]=1;
					else if(mainMenu_custom_left > 0)
					{
						getMapping(mainMenu_custom_left);
						uae4all_keystate[customKey] = 1;
						record_key(customKey << 1);
					}
					justMovedLeft=1;
				}
			}
			else if(justMovedLeft)
			{
				if(mainMenu_custom_left == -1) buttonstate[0]=0;
				else if(mainMenu_custom_left == -2) buttonstate[2]=0;
				else if(mainMenu_custom_left > 0)
				{
					getMapping(mainMenu_custom_left);
					uae4all_keystate[customKey] = 0;
					record_key((customKey << 1) | 1);
				}
				justMovedLeft=0;
			}

 			//RIGHT
			if(SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
			{
				if(!justMovedRight)
				{
					if(mainMenu_custom_right == -1) buttonstate[0]=1;
					else if(mainMenu_custom_right == -2) buttonstate[2]=1;
					else if(mainMenu_custom_right > 0)
					{
						getMapping(mainMenu_custom_right);
						uae4all_keystate[customKey] = 1;
						record_key(customKey << 1);
					}
					justMovedRight=1;
				}
			}
			else if(justMovedRight)
			{
				if(mainMenu_custom_right == -1) buttonstate[0]=0;
				else if(mainMenu_custom_right == -2) buttonstate[2]=0;
				else if(mainMenu_custom_right > 0)
				{
					getMapping(mainMenu_custom_right);
					uae4all_keystate[customKey] = 0;
					record_key((customKey << 1) | 1);
				}
				justMovedRight=0;
			}
		}

		//(A)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_B))
		{
			if(!justPressedA)
			{
				if(mainMenu_custom_A == -1) buttonstate[0]=1;
				else if(mainMenu_custom_A == -2) buttonstate[2]=1;
				else if(mainMenu_custom_A > 0)
				{
					getMapping(mainMenu_custom_A);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedA=1;
			}
		}
		else if(justPressedA)
		{
			if(mainMenu_custom_A == -1) buttonstate[0]=0;
			else if(mainMenu_custom_A == -2) buttonstate[2]=0;
			else if(mainMenu_custom_A > 0)
			{
				getMapping(mainMenu_custom_A);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedA=0;
		}

		//(B)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_A))
		{
			if(!justPressedB)
			{
				if(mainMenu_custom_B == -1) buttonstate[0]=1;
				else if(mainMenu_custom_B == -2) buttonstate[2]=1;
				else if(mainMenu_custom_B > 0)
				{
					getMapping(mainMenu_custom_B);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedB=1;
			}
		}
		else if(justPressedB)
		{
			if(mainMenu_custom_B == -1) buttonstate[0]=0;
			else if(mainMenu_custom_B == -2) buttonstate[2]=0;
			else if(mainMenu_custom_B > 0)
			{
				getMapping(mainMenu_custom_B);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedB=0;
		}

		//(X)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_X))
		{
			if(!justPressedX)
			{
				if(mainMenu_custom_X == -1) buttonstate[0]=1;
				else if(mainMenu_custom_X == -2) buttonstate[2]=1;
				else if(mainMenu_custom_X > 0)
				{
					getMapping(mainMenu_custom_X);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedX=1;
			}
		}
		else if(justPressedX)
		{
			if(mainMenu_custom_X == -1) buttonstate[0]=0;
			else if(mainMenu_custom_X == -2) buttonstate[2]=0;
			else if(mainMenu_custom_X > 0)
			{
				getMapping(mainMenu_custom_X);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedX=0;
		}

		//(Y)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_Y))
		{
			if(!justPressedY)
			{
				if(mainMenu_custom_Y == -1) buttonstate[0]=1;
				else if(mainMenu_custom_Y == -2) buttonstate[2]=1;
				else if(mainMenu_custom_Y > 0)
				{
					getMapping(mainMenu_custom_Y);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedY=1;
			}
		}
		else if(justPressedY)
		{
			if(mainMenu_custom_Y == -1) buttonstate[0]=0;
			else if(mainMenu_custom_Y == -2) buttonstate[2]=0;
			else if(mainMenu_custom_Y > 0)
			{
				getMapping(mainMenu_custom_Y);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedY=0;
		}

		//(L)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L))
		{
			if(!justPressedL)
			{
				if(mainMenu_custom_L == -1) buttonstate[0]=1;
				else if(mainMenu_custom_L == -2) buttonstate[2]=1;
				else if(mainMenu_custom_L > 0)
				{
					getMapping(mainMenu_custom_L);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedL=1;
			}
		}
		else if(justPressedL)
		{
			if(mainMenu_custom_L == -1) buttonstate[0]=0;
			else if(mainMenu_custom_L == -2) buttonstate[2]=0;
			else if(mainMenu_custom_L > 0)
			{
				getMapping(mainMenu_custom_L);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedL=0;
		}

		//(R)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_R))
		{
			if(!justPressedR)
			{
				if(mainMenu_custom_R == -1) buttonstate[0]=1;
				else if(mainMenu_custom_R == -2) buttonstate[2]=1;
				else if(mainMenu_custom_R > 0)
				{
					getMapping(mainMenu_custom_R);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedR=1;
			}
		}
		else if(justPressedR)
		{
			if(mainMenu_custom_R == -1) buttonstate[0]=0;
			else if(mainMenu_custom_R == -2) buttonstate[2]=0;
			else if(mainMenu_custom_R > 0)
			{
				getMapping(mainMenu_custom_R);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedR=0;
		}
	}
	else if(!gp2xMouseEmuOn)
	{
		//DPad = arrow keys in stylus-mode
		if(gp2xButtonRemappingOn)
		{
			//dpad up
			if (SDL_JoystickGetAxis(uae4all_joy0, 1) < 0)
			{
				if(!justMovedUp)
				{
					//left and right mouse-buttons down
					buttonstate[0] = 1;
					buttonstate[2] = 1;
					stylusClickOverride = 1;
					justMovedUp=1;
				}
			}
			else if(justMovedUp)
			{
				//left and right mouse-buttons up
				buttonstate[0] = 0;
				buttonstate[2] = 0;
				stylusClickOverride = 0;
				justMovedUp=0;
			}
			//dpad down
			if (SDL_JoystickGetAxis(uae4all_joy0, 1) > 0)
			{
				if(!justMovedDown)
				{
					//no clicks with stylus now
					stylusClickOverride=1;
					justMovedDown=1;
				}
			}
			else if(justMovedDown)
			{
				//clicks active again
				stylusClickOverride=0;
				justMovedDown=0;
			}
			//dpad left
			if (SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
			{
				if(!justMovedLeft)
				{
					//left mouse-button down
					buttonstate[0] = 1;
					stylusClickOverride = 1;
					justMovedLeft=1;
				}
			}
			else if(justMovedLeft)
			{
				//left mouse-button up
				buttonstate[0] = 0;
				stylusClickOverride = 0;
				justMovedLeft=0;
			}
			//dpad right
			if (SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
			{
				if(!justMovedRight)
				{
					//right mouse-button down
					buttonstate[2] = 1;
					stylusClickOverride = 1;
					justMovedRight=1;
				}
			}
			else if(justMovedRight)
			{
				//right mouse-button up
				buttonstate[2] = 0;
				stylusClickOverride = 0;
				justMovedRight=0;
			}
			//L + up
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && SDL_JoystickGetAxis(uae4all_joy0, 1) < 0)
				stylusAdjustY-=2;
			//L + down
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && SDL_JoystickGetAxis(uae4all_joy0, 1) > 0)
				stylusAdjustY+=2;
			//L + left
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
				stylusAdjustX-=2;
			//L + right
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
				stylusAdjustX+=2;
		}
		//R-trigger in joystick mode
		else if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_R))
		{
			//(A) button
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_A))
			{
				if(!justPressedA)
				{
					//CTRL
					uae4all_keystate[AK_CTRL] = 1;
					record_key(AK_CTRL << 1);
					justPressedA=1;
				}
			}
			else if(justPressedA)
			{
				uae4all_keystate[AK_CTRL] = 0;
				record_key((AK_CTRL << 1) | 1);
				justPressedA=0;
			}
			//(B) button
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_B))
			{
				if(!justPressedB)
				{
					//left ALT
					uae4all_keystate[AK_LALT] = 1;
					record_key(AK_LALT << 1);
					justPressedB=1;
				}
			}
			else if(justPressedB)
			{
				uae4all_keystate[AK_LALT] = 0;
				record_key((AK_LALT << 1) | 1);
				justPressedB=0;
			}
			//(X) button
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_X))
			{
				if(!justPressedX)
				{
					//HELP
					uae4all_keystate[AK_HELP] = 1;
					record_key(AK_HELP << 1);
					justPressedX=1;
				}
			}
			else if(justPressedX)
			{
				//HELP
				uae4all_keystate[AK_HELP] = 0;
				record_key((AK_HELP << 1) | 1);
				justPressedX=0;
			}
		}
		else if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L))
		{
			//(A) button
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_A))
			{
				if(!justPressedA)
				{
					//right mouse-button down
					buttonstate[2] = 1;
					justPressedA=1;
				}
			}
			else if(justPressedA)
			{
				//right mouse-button up
				buttonstate[2] = 0;
				justPressedA=0;
			}
			//(B) button
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_B))
			{
				if(!justPressedB)
				{
					//left mouse-button down
					buttonstate[0] = 1;
					justPressedB=1;
				}
			}
			else if(justPressedB)
			{
				//left mouse-button up
				buttonstate[0] = 0;
				justPressedB=0;
			}
		}
		else
		{
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_Y))
			{
				if(!justPressedY)
				{
					//SPACE
					uae4all_keystate[AK_SPC] = 1;
					record_key(AK_SPC << 1);
					justPressedY=1;
				}
			}
			else if(justPressedY)
			{
				//SPACE
				uae4all_keystate[AK_SPC] = 0;
				record_key((AK_SPC << 1) | 1);
				justPressedY=0;
			}
		}
	}
	else
	{
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_A))
		{
			if(!justPressedA)
			{
				//right mouse-button down
				buttonstate[2] = 1;
				justPressedA=1;
			}
		}
		else if(justPressedA)
		{
			//right mouse-button up
			buttonstate[2] = 0;
			justPressedA=0;
		}
		//(B) button
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_B))
		{
			if(!justPressedB)
			{
				//left mouse-button down
				buttonstate[0] = 1;
				justPressedB=1;
			}
		}
		else if(justPressedB)
		{
			//left mouse-button up
			buttonstate[0] = 0;
			justPressedB=0;
		}
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_Y))
		{
			if(!justPressedY)
			{
				//SPACE
				uae4all_keystate[AK_SPC] = 1;
				record_key(AK_SPC << 1);
				justPressedY=1;
			}
		}
		else if(justPressedY)
		{
			//SPACE
			uae4all_keystate[AK_SPC] = 0;
			record_key((AK_SPC << 1) | 1);
			justPressedY=0;
		}
		if (SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
		{
			if(!justMovedLeft)
			{
				//left ALT
				uae4all_keystate[0x64] = 1;
				record_key(0x64 << 1);
				justMovedLeft=1;
			}
		}
		else if(justMovedLeft)
		{
			//left ALT
			uae4all_keystate[0x64] = 0;
			record_key((0x64 << 1) | 1);
			justMovedLeft=0;
		}
		if (SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
		{
			if(!justMovedRight)
			{
				//left ALT
				uae4all_keystate[0x64] = 1;
				record_key(0x64 << 1);
				justMovedRight=1;
			}
		}
		else if(justMovedRight)
		{
			//left ALT
			uae4all_keystate[0x64] = 0;
			record_key((0x64 << 1) | 1);
			justMovedRight=0;
		}
	}

	if(!mainMenu_customControls && SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_R))
	{
		//R+dpad = arrow keys in joystick mode
		//dpad up
		if (SDL_JoystickGetAxis(uae4all_joy0, 1) < 0)
		{
			if(!justMovedUp)
			{
				//arrow up
				uae4all_keystate[0x4C] = 1;
				record_key(0x4C << 1);
				justMovedUp=1;
			}
		}
		else if(justMovedUp)
		{
			//arrow up
			uae4all_keystate[0x4C] = 0;
			record_key((0x4C << 1) | 1);
			justMovedUp=0;
		}
		//dpad down
		if (SDL_JoystickGetAxis(uae4all_joy0, 1) > 0)
		{
			if(!justMovedDown)
			{
				//arrow down
				uae4all_keystate[0x4D] = 1;
				record_key(0x4D << 1);
				justMovedDown=1;
			}
		}
		else if(justMovedDown)
		{
			//arrow down
			uae4all_keystate[0x4D] = 0;
			record_key((0x4D << 1) | 1);
			justMovedDown=0;
		}
		//dpad left
		if (SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
		{
			if(!justMovedLeft)
			{
				//arrow left
				uae4all_keystate[0x4F] = 1;
				record_key(0x4F << 1);
				justMovedLeft=1;
			}
		}
		else if(justMovedLeft)
		{
			//arrow left
			uae4all_keystate[0x4F] = 0;
			record_key((0x4F << 1) | 1);
			justMovedLeft=0;
		}
		//dpad right
		if (SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
		{
			if(!justMovedRight)
			{
				//arrow right
				uae4all_keystate[0x4E] = 1;
				record_key(0x4E << 1);
				justMovedRight=1;
			}
		}
		else if(justMovedRight)
		{
			//arrow right
			uae4all_keystate[0x4E] = 0;
			record_key((0x4E << 1) | 1);
			justMovedRight=0;
		}
	}

	//L+D: show/hide status ln
	if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && keystate[SDLK_d])
	{
		keystate[SDLK_d]=0;
		mainMenu_showStatus = !mainMenu_showStatus;
	}
}

	//L+K: virtual keyboard
	if (SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && keystate[SDLK_k])
	{
		if(!justLK)
		{
			vkbd_mode = !vkbd_mode;
			justLK=1;
		}
	}
	else if(justLK)
		justLK=0;

#ifndef CYCLONE
	if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && keystate[SDLK_s])
	{
		keystate[SDLK_s]=0;
		savestate_state = STATE_DOSAVE;
	}
	if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && keystate[SDLK_l])
	{
		extern char *savestate_filename;
		FILE *f=fopen(savestate_filename, "rb");
		keystate[SDLK_l]=0;
		if(f)
		{
			fclose(f);
			savestate_state = STATE_DORESTORE;
		}
		else
			gui_set_message("Failed: Savestate not found", 100);
	}
#endif
//if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && keystate[SDLK_1])
//{
//	resChange = 1;
//	gfxHeight	 = 256;
//	prSDLScreen = SDL_SetVideoMode(320, 256, 16, VIDEO_FLAGS);
//	system("export SDL_OMAP_LAYER_SIZE=800x480");
//}
#endif

	if (vkbd_key)
	{
		if (vkbd_keysave==-1234567)
		{
			SDL_keysym ks;
			ks.sym=vkbd_key;
			vkbd_keysave=keycode2amiga(&ks);
			if (vkbd_keysave >= 0)
			{
				if (!uae4all_keystate[vkbd_keysave])
				{
					uae4all_keystate[vkbd_keysave]=1;
					record_key(vkbd_keysave<<1);
				}
			}
		}
	}
	else
		if (vkbd_keysave!=-1234567)
		{
			if (vkbd_keysave >= 0)
			{
				uae4all_keystate[vkbd_keysave]=0;
				record_key((vkbd_keysave << 1) | 1);
			}
			vkbd_keysave=-1234567;
		}
}
Ejemplo n.º 9
0
void handle_events (void)
{
    SDL_Event rEvent;
    int iAmigaKeyCode;
    int i, j;
    int iIsHotKey = 0;
#ifdef DEBUG_EVENTS
    dbg("Function: handle_events");
#endif


#ifdef MAX_AUTOEVENTS
	{
		static unsigned cuenta=0;
// /*
		switch(cuenta&63)
		{
			case 8:
				if ((cuenta<6500)||(cuenta>8000))
					joy1button=1;
				break;
			case 16:
				buttonstate[0]=1; break;
			case 24:
				joy1button=0; break;
			case 28:
				if (cuenta>11000)
					joy1dir=3;
				break;
			case 32:
				buttonstate[0]=0; break;
			case 62:
				joy1dir=0; break;
		}
//		lastmy+=8;
		switch(cuenta&127)
		{
			case 20:
				record_key(0x12); break;
			case 40:
				record_key(0x13); break;
			case 60:
				record_key(0x88); break;
			case 80:
				record_key(0x89); break;
		}
if (cuenta==7700)
{
strcpy(changed_df[0],"prueba2.adz");
real_changed_df[0]=1;
joy1button=1;
}
// */

// Defender of the Crown
 /*
switch(cuenta)
{
case 2600:
lastmx+=80;
break;
case 2610:
buttonstate[0]=1; break;
break;
case 2615:
buttonstate[0]=0; break;
break;
case 4500:
lastmy+=100;
break;
case 4510:
buttonstate[0]=1; break;
break;
case 4515:
buttonstate[0]=0; break;
break;
case 4640:
lastmy-=60;
lastmx+=550;
break;
case 4700:
lastmx+=200;
break;
case 4710:
buttonstate[0]=1; break;
break;
case 4715:
buttonstate[0]=0; break;
break;


}
// printf("%i -> %.8X\n",cuenta,chipmem_checksum());
 */
printf("%i\n",cuenta); fflush(stdout);


#ifdef START_DEBUG
		if (cuenta>START_DEBUG)
			DEBUG_AHORA=1;
#endif
#ifdef DEBUG_EVENTS
		dbgf(" AUTO EVENTS: %i =?= %i\n",cuenta,MAX_AUTOEVENTS);
#endif
		if (cuenta>MAX_AUTOEVENTS)
			exit(0);
		else
			dbgf("handle_events %i\n",cuenta);
		cuenta++;
	}
#else
    /* Handle GUI events */
    gui_handle_events ();

    while (SDL_PollEvent(&rEvent))
    {
	switch (rEvent.type)
	{
	case SDL_QUIT:
#ifdef DEBUG_EVENTS
	    dbg("Event: quit");
#endif
	    uae_quit();
	    break;
	    break;
	case SDL_JOYBUTTONDOWN:
#if defined (GP2X) || defined (PSP) || defined (GIZMONDO)
		if (gp2xButtonRemappingOn && is_overridden_button(rEvent.jbutton.button))
		{
			// handle the buttons as specified
			handle_remapped_button_down(rEvent.jbutton.button);
		}
#ifdef GP2X
		else if (rEvent.jbutton.button==GP2X_BUTTON_A)
#else
#ifdef GIZMONDO
		else if (rEvent.jbutton.button==GIZ_BACK)
#else
		else if (rEvent.jbutton.button==PSP_BUTTON_SQUARE)
#endif
#endif
		{
			// critical: temporary hack to send return and space when the A button
			// is pressed
			if (!uae4all_keystate[AK_RET])
			{
				uae4all_keystate[AK_RET] = 1;
				record_key(AK_RET << 1);
			}
			if (!uae4all_keystate[AK_SPC])
			{
				uae4all_keystate[AK_SPC] = 1;
				record_key(AK_SPC << 1);
			}
		}
#ifdef GP2X
		else if (rEvent.jbutton.button==GP2X_BUTTON_START)
#else
#ifdef GIZMONDO
		else if (rEvent.jbutton.button==GIZ_STOP)
#else
		else if (rEvent.jbutton.button==PSP_BUTTON_START)
#endif
#endif
		{
			if (!vkbd_mode)
			{
				// only do this if the virtual keyboard isn't visible
				
				// state moves thus:
				// joystick mode (with virt keyboard on L and R)
				// mouse mode (with mouse buttons on L and R)
				// if specified:
				// remapping mode (with whatever's been supplied)
				// back to start of state
				if (!hasGp2xButtonRemapping)
				{
					// skip the remapping state
					gp2xMouseEmuOn = !gp2xMouseEmuOn;
				}
				else
				{
					// start condition is gp2xMouseEmuOn = 0, gp2xButtonRemappingOn = 0
					if (!gp2xButtonRemappingOn && !gp2xMouseEmuOn)
					{
						// move to mouse emu mode
						gp2xMouseEmuOn = 1;
						gp2xButtonRemappingOn = 0;
					}
					else if (gp2xMouseEmuOn && !gp2xButtonRemappingOn)
					{
						// move to button remapping mode
						gp2xMouseEmuOn = 0;
						gp2xButtonRemappingOn = 1;
					}
					else if (!gp2xMouseEmuOn && gp2xButtonRemappingOn)
					{
						gp2xMouseEmuOn = 0;
						gp2xButtonRemappingOn = 0;
					}
				}

				show_inputmode = 1;
			}			
		}
		else if (gp2xMouseEmuOn)
		{
#ifdef GP2X
			if (rEvent.jbutton.button==GP2X_BUTTON_L)
				buttonstate[0] = 1;
			
			if (rEvent.jbutton.button==GP2X_BUTTON_R)
				buttonstate[2] = 1;
#else
#ifdef GIZMONDO
			if (rEvent.jbutton.button==GIZ_LTRIG)
				buttonstate[0] = 1;
			
			if (rEvent.jbutton.button==GIZ_RTRIG)
				buttonstate[2] = 1;

#else
			if (rEvent.jbutton.button==PSP_BUTTON_L)
				buttonstate[0] = 1;
			
			if (rEvent.jbutton.button==PSP_BUTTON_R)
				buttonstate[2] = 1;

#endif
#endif
		}
		
		else if ((!gp2xMouseEmuOn) && (!gp2xButtonRemappingOn) && (!vkbd_mode) && (vkbd_button2!=(SDLKey)0))
		{
			if (vkbd_button2)
				rEvent.key.keysym.sym=vkbd_button2;
			else
				break;
		}
#ifdef GP2X
		if (rEvent.jbutton.button==GP2X_BUTTON_VOLUP)
		{
			if (soundVolume <100)
			{
				soundVolume+= 10;
				
				gp2x_set_volume(soundVolume);
			}
			show_volumecontrol = 1;
		}
		else if (rEvent.jbutton.button==GP2X_BUTTON_VOLDOWN)
		{
			int vol;

			if (soundVolume > 0)
			{
				soundVolume-= 10;
				gp2x_set_volume(soundVolume);
			}
			show_volumecontrol = 1;
		}
#endif
#else         
	    if ((rEvent.jbutton.button==6) && (!vkbd_mode) && (vkbd_button2!=(SDLKey)0))
	    {
		    if (vkbd_button2)
			    rEvent.key.keysym.sym=vkbd_button2;
		    else
			    break;
            }
#endif
	    else
	    	break;
        case SDL_KEYDOWN:
#ifdef DEBUG_EVENTS
	    dbg("Event: key down");
#endif
#if !defined (DREAMCAST) && !defined (GP2X)
	    if ((rEvent.key.keysym.sym!=SDLK_F11)&&(rEvent.key.keysym.sym!=SDLK_F12)&&(rEvent.key.keysym.sym!=SDLK_PAGEUP))
#endif
	    {
		iAmigaKeyCode = keycode2amiga(&(rEvent.key.keysym));
		if (iAmigaKeyCode >= 0)
		{
		    if (!uae4all_keystate[iAmigaKeyCode])
		    {
				if (iAmigaKeyCode == AK_P)
				{
					joy0button = 1;
				}
			uae4all_keystate[iAmigaKeyCode] = 1;
			record_key(iAmigaKeyCode << 1);
		    }
		}
	    }
	    break;
	case SDL_JOYBUTTONUP:
#if defined (GP2X) || defined (PSP) || defined (GIZMONDO)
			if (gp2xButtonRemappingOn && is_overridden_button(rEvent.jbutton.button))
			{
				// handle the buttons as specified
				handle_remapped_button_up(rEvent.jbutton.button);
			}
#ifdef GP2X
        	else if (rEvent.jbutton.button==GP2X_BUTTON_A)
#else
#ifdef GIZMONDO
			else if (rEvent.jbutton.button==GIZ_BACK)
#else
			else if (rEvent.jbutton.button==PSP_BUTTON_SQUARE)
#endif
#endif
			{
				// critical: temporary hack to send return and space when the A button
				// is pressed
				uae4all_keystate[AK_RET] = 0;
				record_key((AK_RET << 1) | 1);
				
				uae4all_keystate[AK_SPC] = 0;
				record_key((AK_SPC << 1) | 1);
			}
			else if (gp2xMouseEmuOn)
			{
#ifdef GP2X
				if (rEvent.jbutton.button==GP2X_BUTTON_L)
				{
					buttonstate[0] = 0;
				}
				else if (rEvent.jbutton.button==GP2X_BUTTON_R)
				{
					buttonstate[2] = 0;
				}
#else
#ifdef GIZMONDO
				if (rEvent.jbutton.button==GIZ_LTRIG)
				{
					buttonstate[0] = 0;
				}
				else if (rEvent.jbutton.button==GIZ_RTRIG)
				{
					buttonstate[2] = 0;
				}
#else
				if (rEvent.jbutton.button==PSP_BUTTON_L)
				{
					buttonstate[0] = 0;
				}
				else if (rEvent.jbutton.button==PSP_BUTTON_R)
				{
					buttonstate[2] = 0;
				}
#endif
#endif
			}
#ifdef GP2X
			if (rEvent.jbutton.button==GP2X_BUTTON_VOLDOWN || rEvent.jbutton.button==GP2X_BUTTON_VOLUP)
			{
				show_volumecontrol = 0;
			}
#endif
#ifdef GP2X
			if (rEvent.jbutton.button==GP2X_BUTTON_START)
#else
#ifdef GIZMONDO
			if (rEvent.jbutton.button==GIZ_STOP)
#else
			if (rEvent.jbutton.button==PSP_BUTTON_START)
#endif
#endif
			{
				show_inputmode = 0;
			}

#else         
	    if ((rEvent.jbutton.button==6) && (!vkbd_mode) && (vkbd_button2!=(SDLKey)0))
	    {
		    if (vkbd_button2)
			    rEvent.key.keysym.sym=vkbd_button2;
		    else
			    break;
            }
#endif
	    else
	    	break;
	case SDL_KEYUP:
#ifdef DEBUG_EVENTS
	    dbg("Event: key up");
#endif
#if !defined (DREAMCAST) && !defined (GP2X)
	    if ((rEvent.key.keysym.sym!=SDLK_F11)&&(rEvent.key.keysym.sym!=SDLK_F12)&&(rEvent.key.keysym.sym!=SDLK_PAGEUP))
#endif
	    {
		iAmigaKeyCode = keycode2amiga(&(rEvent.key.keysym));
		if (iAmigaKeyCode >= 0)
		{
			if (iAmigaKeyCode == AK_P)
				{
					joy0button = 0;
				}
		    uae4all_keystate[iAmigaKeyCode] = 0;
		    record_key((iAmigaKeyCode << 1) | 1);
		}
	    }
	    break;
	case SDL_MOUSEBUTTONDOWN:
#ifdef DEBUG_EVENTS
	    dbg("Event: mouse button down");
#endif
#ifdef DREAMCAST
	    if (__sdl_dc_emulate_mouse)
	    {
	    	if (rEvent.button.button==5)
			    buttonstate[0] = 1;
	    	else if (rEvent.button.button==1)
		 	   buttonstate[2] = 1;
	    }
	    else
	    	if (rEvent.button.button)
			buttonstate[2]=1;
		else
			buttonstate[0]=1;
#else
#ifdef ANDROID
		if (right_mouse == 1)
			buttonstate[2] = 1;
		else
			buttonstate[(rEvent.button.button-1)%3] = 1;
#else
	    	buttonstate[(rEvent.button.button-1)%3] = 1;
#endif
#endif
	    break;
	case SDL_MOUSEBUTTONUP:
#ifdef DEBUG_EVENTS
	    dbg("Event: mouse button up");
#endif
#ifdef DREAMCAST
	    if (__sdl_dc_emulate_mouse)
	    {
	    	if (rEvent.button.button==5)
			    buttonstate[0] = 0;
	    	else if (rEvent.button.button==1)
			    buttonstate[2] = 0;
	    }
	    else
	    	if (rEvent.button.button)
			buttonstate[2]=0;
		else
			buttonstate[0]=0;
				
#else
#ifdef ANDROID
		if (right_mouse == 1)
			buttonstate[2] = 0;
		else
			buttonstate[(rEvent.button.button-1)%3] = 0;
#else
	    	buttonstate[(rEvent.button.button-1)%3] = 0;
#endif
#endif
	    break;
	case SDL_MOUSEMOTION:
#ifdef DEBUG_EVENTS
	    dbg("Event: mouse motion");
#endif
	    lastmx += rEvent.motion.xrel<<1;
	    lastmy += rEvent.motion.yrel<<1;
	    newmousecounters = 1;
	    break;
	}
    }
#endif


    /* Handle UAE reset */
/*
    if ((uae4all_keystate[AK_CTRL] || uae4all_keystate[AK_RCTRL]) && uae4all_keystate[AK_LAMI] && uae4all_keystate[AK_RAMI])
	uae_reset ();
*/
#ifdef DEBUG_EVENTS
    dbg(" handle_events -> terminado");
#endif
}