コード例 #1
0
ファイル: keys.c プロジェクト: ewirch/qfusion
/*
* Key_CharEvent
* 
* Called by the system between frames for key down events for standard characters
* Should NOT be called during an interrupt!
*/
void Key_CharEvent( int key, qwchar charkey )
{
	if( Key_IsToggleConsole( key ) )
		return;

	if( charkey == ( qwchar )alt_color_escape )
		charkey = Q_COLOR_ESCAPE;

	switch( cls.key_dest )
	{
	case key_message:
		Con_MessageCharEvent( charkey );
		break;
	case key_menu:
		CL_UIModule_CharEvent( charkey );
		break;
	case key_game:
	case key_console:
		Con_CharEvent( charkey );
		break;
	case key_delegate:
		Key_DelegateCallCharDel( charkey );
		break;
	default:
		Com_Error( ERR_FATAL, "Bad cls.key_dest" );
	}
}
コード例 #2
0
ファイル: events.c プロジェクト: gitter-badger/xash3d
void SDLash_InputEvent(SDL_TextInputEvent input)
{
    int i;
    // Pass characters one by one to Con_CharEvent
    for(i = 0; input.text[i]; ++i)
    {
        Con_CharEvent( (int)input.text[i] );
        if( cls.key_dest == key_menu )
            UI_CharEvent ( (int)input.text[i] );
    }
}
コード例 #3
0
/*
===================
CL_CharEvent

Normal keyboard characters, already shifted / capslocked / etc
===================
*/
void CL_CharEvent( int key )
{
	// the console key should never be used as a char
	if( key == '`' || key == '~' ) return;

	if( cls.key_dest == key_console && !Con_Visible( ))
	{
		if((char)key == '¸' || (char)key == '¨' )
			return; // don't pass '¸' when we open the console 
	}

	// distribute the key down event to the apropriate handler
	if( cls.key_dest == key_console || cls.key_dest == key_message )
	{
		Con_CharEvent( key );
	}
	else if( cls.key_dest == key_menu )
	{
		UI_CharEvent( key );
	}
}
コード例 #4
0
ファイル: events.c プロジェクト: DavidKnight247/xash3d
void SDLash_InputEvent(SDL_TextInputEvent input)
{
	int i = 0;
	for(i = 0; input.text[i]; ++i)
		Con_CharEvent((int)input.text[i]);
}
コード例 #5
0
ファイル: android_nosdl.c プロジェクト: nekonomicon/xash3d
/*
========================
Android_RunEvents

Execute all events from queue
========================
*/
void Android_RunEvents()
{
	int i;

	// enter events read
	Android_Lock();
	pthread_mutex_unlock( &events.framemutex );

	for( i = 0; i < events.count; i++ )
	{
		switch( events.queue[i].type )
		{
		case event_touch_down:
		case event_touch_up:
		case event_touch_move:
			IN_TouchEvent( events.queue[i].type, events.queue[i].arg,
						   events.queue[i].touch.x, events.queue[i].touch.y,
						   events.queue[i].touch.dx, events.queue[i].touch.dy );
			break;

		case event_key_down:
			Key_Event( events.queue[i].arg, true );
			break;
		case event_key_up:
			Key_Event( events.queue[i].arg, false );
			break;

		case event_set_pause:
			// destroy EGL surface when hiding application
			if( !events.queue[i].arg )
			{
				host.state = HOST_FRAME;
				S_Activate( true );
				(*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.toggleEGL, 1 );
				Android_UpdateSurface();
				Android_SwapInterval( Cvar_VariableInteger( "gl_swapinterval" ) );
			}
			if( events.queue[i].arg )
			{
				host.state = HOST_NOFOCUS;
				S_Activate( false );
				(*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.toggleEGL, 0 );
				negl.valid = false;
			}
			break;

		case event_resize:
			// reinitialize EGL and change engine screen size
			if( host.state == HOST_NORMAL && ( scr_width->integer != jni.width || scr_height->integer != jni.height ) )
			{
				(*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.toggleEGL, 0 );
				(*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.toggleEGL, 1 );
				Android_UpdateSurface();
				Android_SwapInterval( Cvar_VariableInteger( "gl_swapinterval" ) );
				VID_SetMode();
			}
			break;
		case event_joyadd:
			Joy_AddEvent( events.queue[i].arg );
			break;
		case event_joyremove:
			Joy_RemoveEvent( events.queue[i].arg );
			break;
		case event_joyball:
			Joy_BallMotionEvent( events.queue[i].arg, events.queue[i].ball.ball,
								 events.queue[i].ball.xrel, events.queue[i].ball.yrel );
			break;
		case event_joyhat:
			Joy_HatMotionEvent( events.queue[i].arg, events.queue[i].hat.hat, events.queue[i].hat.key );
			break;
		case event_joyaxis:
			Joy_AxisMotionEvent( events.queue[i].arg, events.queue[i].axis.axis, events.queue[i].axis.val );
			break;
		case event_joybutton:
			Joy_ButtonEvent( events.queue[i].arg, events.queue[i].button.button, (byte)events.queue[i].button.down );
			break;
		}
	}

	events.count = 0; // no more events

	// text input handled separately to allow unicode symbols
	for( i = 0; events.inputtext[i]; i++ )
	{
		int ch;

		// if engine does not use utf-8, we need to convert it to preferred encoding
		if( !Q_stricmp( cl_charset->string, "utf-8" ) )
			ch = (unsigned char)events.inputtext[i];
		else
			ch = Con_UtfProcessCharForce( (unsigned char)events.inputtext[i] );

		if( !ch )
			continue;

		// otherwise just push it by char, text render will decode unicode strings
		Con_CharEvent( ch );
		if( cls.key_dest == key_menu )
			UI_CharEvent ( ch );
	}
	events.inputtext[0] = 0; // no more text

	//end events read
	Android_Unlock();
	pthread_mutex_lock( &events.framemutex );
}