mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-17 18:40:02 +00:00
add barebones gamepad controls for input fields and console
This commit is contained in:
parent
705f252ed8
commit
f3e50b5500
@ -1230,7 +1230,7 @@ void Field_KeyDownEvent( field_t *edit, int key )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( key == K_BACKSPACE )
|
if( key == K_BACKSPACE || key == K_X_BUTTON )
|
||||||
{
|
{
|
||||||
if( edit->cursor > 0 )
|
if( edit->cursor > 0 )
|
||||||
{
|
{
|
||||||
@ -1242,7 +1242,7 @@ void Field_KeyDownEvent( field_t *edit, int key )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( key == K_RIGHTARROW )
|
if( key == K_RIGHTARROW || key == K_DPAD_RIGHT )
|
||||||
{
|
{
|
||||||
if( edit->cursor < len ) edit->cursor = Con_UtfMoveRight( edit->buffer, edit->cursor, edit->widthInChars );
|
if( edit->cursor < len ) edit->cursor = Con_UtfMoveRight( edit->buffer, edit->cursor, edit->widthInChars );
|
||||||
if( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len )
|
if( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len )
|
||||||
@ -1250,7 +1250,7 @@ void Field_KeyDownEvent( field_t *edit, int key )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( key == K_LEFTARROW )
|
if( key == K_LEFTARROW || key == K_DPAD_LEFT )
|
||||||
{
|
{
|
||||||
if( edit->cursor > 0 ) edit->cursor = Con_UtfMoveLeft( edit->buffer, edit->cursor );
|
if( edit->cursor > 0 ) edit->cursor = Con_UtfMoveLeft( edit->buffer, edit->cursor );
|
||||||
if( edit->cursor < edit->scroll ) edit->scroll--;
|
if( edit->cursor < edit->scroll ) edit->scroll--;
|
||||||
@ -1547,8 +1547,8 @@ void Key_Console( int key )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// enter finishes the line
|
// enter or A finish the line
|
||||||
if( key == K_ENTER || key == K_KP_ENTER )
|
if( key == K_ENTER || key == K_KP_ENTER || key == K_A_BUTTON )
|
||||||
{
|
{
|
||||||
// backslash text are commands, else chat
|
// backslash text are commands, else chat
|
||||||
if( con.input.buffer[0] == '\\' || con.input.buffer[0] == '/' )
|
if( con.input.buffer[0] == '\\' || con.input.buffer[0] == '/' )
|
||||||
@ -1575,7 +1575,7 @@ void Key_Console( int key )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// command completion
|
// command completion
|
||||||
if( key == K_TAB )
|
if( key == K_TAB || key == K_L2_BUTTON )
|
||||||
{
|
{
|
||||||
Con_CompleteCommand( &con.input );
|
Con_CompleteCommand( &con.input );
|
||||||
Con_Bottom();
|
Con_Bottom();
|
||||||
@ -1638,6 +1638,24 @@ void Key_Console( int key )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if XASH_NSWITCH
|
||||||
|
// enable the OSK with button press
|
||||||
|
if( key == K_Y_BUTTON )
|
||||||
|
{
|
||||||
|
Key_EnableTextInput( true, true );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// exit the console by pressing MINUS
|
||||||
|
if( key == K_BACK_BUTTON )
|
||||||
|
{
|
||||||
|
if( cls.state == ca_active && !cl.background )
|
||||||
|
Key_SetKeyDest( key_game );
|
||||||
|
else UI_SetActiveMenu( true );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// pass to the normal editline routine
|
// pass to the normal editline routine
|
||||||
Field_KeyDownEvent( &con.input, key );
|
Field_KeyDownEvent( &con.input, key );
|
||||||
}
|
}
|
||||||
@ -1653,14 +1671,14 @@ void Key_Message( int key )
|
|||||||
{
|
{
|
||||||
char buffer[MAX_SYSPATH];
|
char buffer[MAX_SYSPATH];
|
||||||
|
|
||||||
if( key == K_ESCAPE )
|
if( key == K_ESCAPE || key == K_BACK_BUTTON )
|
||||||
{
|
{
|
||||||
Key_SetKeyDest( key_game );
|
Key_SetKeyDest( key_game );
|
||||||
Con_ClearField( &con.chat );
|
Con_ClearField( &con.chat );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( key == K_ENTER || key == K_KP_ENTER )
|
if( key == K_ENTER || key == K_KP_ENTER || key == K_A_BUTTON )
|
||||||
{
|
{
|
||||||
if( con.chat.buffer[0] && cls.state == ca_active )
|
if( con.chat.buffer[0] && cls.state == ca_active )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user