Skip to content

Commit

Permalink
Input.2
Browse files Browse the repository at this point in the history
  • Loading branch information
John Greb authored and John Greb committed Jul 30, 2012
1 parent dbff58b commit 0fdb3d8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 50 deletions.
27 changes: 19 additions & 8 deletions src/unix/es_input.c
Expand Up @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#include "../renderer/tr_local.h"
#include "../client/client.h"
#include "sys_local.h"
//#include "sys_local.h"
#include "../ui/keycodes.h"

// q3rev.cpp : Defines the entry point for the application.
Expand Down Expand Up @@ -273,30 +273,41 @@ IN_TranslateSDLToQ3Key
*/
static keyNum_t IN_TranslateCharToQ3Key( char c )
{

if ( c >= 'a' && c <= 'z' )
return ( c );
if ( c >= 'A' && c <= 'Z' )
return ( c - 'A' + 'a' );
switch (c) {
case ';': return K_LEFTARROW;
case '#': return K_RIGHTARROW;
case '\'': return K_DOWNARROW;
case '[': return K_UPARROW;
case ' ': return K_SPACE;
case 27: return K_ESCAPE;
case 128: return K_BACKSPACE;
case '9': return K_COMMAND;
// case ';': return K_LEFTARROW;
// case '#': return K_RIGHTARROW;
// case '\'': return K_DOWNARROW;
// case '[': return K_UPARROW;
case 10: return K_ENTER;
}

return c;
return 0;
}


void IN_ProcessEvents( void );
/*
===============
IN_ProcessEvents
===============
*/
static void IN_ProcessEvents( void )
void IN_ProcessEvents( void )
{
while (kbhit()) {
char c = fgetc(stdin);

int key = IN_TranslateCharToQ3Key(c);

Sys_QueEvent( 0, SE_CHAR, c, 0, 0, NULL );
//Sys_QueEvent( 0, SE_CHAR, c, 0, 0, NULL );

if( key ) {
Sys_QueEvent( 0, SE_KEY, key, qtrue, 0, NULL );
Expand Down
6 changes: 0 additions & 6 deletions src/unix/linux_joystick.c
Expand Up @@ -56,12 +56,6 @@ static int joy_lastx = 0;
static int joy_lasty = 0;
static int joy_lastz = 0;

// bk001130 - from linux_glimp.c
extern cvar_t * in_joystick;
extern cvar_t * in_joystickDebug;
extern cvar_t * joy_threshold;


/**********************************************/
/* Joystick routines. */
/**********************************************/
Expand Down
46 changes: 13 additions & 33 deletions src/unix/pi_glimp.c
Expand Up @@ -80,11 +80,12 @@ typedef enum

glwstate_t glw_state;

static qboolean mouse_avail;
/*
static qboolean mouse_active;
static int mwx, mwy;
static int mx = 0, my = 0;
static int mouseResetTime = 0;
#define KEY_MASK ( KeyPressMask | KeyReleaseMask )
#define MOUSE_MASK ( ButtonPressMask | ButtonReleaseMask | \
PointerMotionMask | ButtonMotionMask )
Expand All @@ -97,11 +98,11 @@ static cvar_t *in_joystick;
static cvar_t *in_joystickDebug;
static cvar_t *joy_threshold;
qboolean dgamouse = qfalse;
static int win_x, win_y;
static int mouse_accel_numerator;
static int mouse_accel_denominator;
static int mouse_threshold;
*/

static const char *Q_stristr( const char *s, const char *find ) {
register char c, sc;
Expand Down Expand Up @@ -138,27 +139,9 @@ static qboolean X11_PendingInput( void ) {
static void HandleEvents( void ) {
}
void IN_ActivateMouse( void ) {
/*
if ( !mouse_avail || !dpy || !win ) {
return;
}
*/
if ( !mouse_active ) {
install_grabs();
mouse_active = qtrue;
}
}

void IN_DeactivateMouse( void ) {
/*
if ( !mouse_avail || !dpy || !win ) {
return;
}
*/
if ( mouse_active ) {
uninstall_grabs();
mouse_active = qfalse;
}
}

static qboolean signalcaught = qfalse;;
Expand Down Expand Up @@ -332,27 +315,23 @@ void GLimp_WakeRenderer( void *data ) {}

/* Mouse/Joystick */
void IN_Init( void ) {
in_mouse = Cvar_Get( "in_mouse", "0", CVAR_ARCHIVE );
in_dgamouse = 0;
in_joystick = Cvar_Get( "in_joystick", "1", CVAR_ARCHIVE | CVAR_LATCH );
in_joystickDebug = Cvar_Get( "in_debugjoystick", "0", CVAR_TEMP );
joy_threshold = Cvar_Get( "joy_threshold", "0.15", CVAR_ARCHIVE ); // FIXME: in_joythreshold
if ( in_mouse->value ) {
mouse_avail = qtrue;
} else {
mouse_avail = qfalse;
}

nonblock(1);//Q3 tty keyboard on

IN_StartupJoystick();
}

void IN_Shutdown( void ) {
mouse_avail = qfalse;

nonblock(0);//Q3 tty keyboard off

// close joystick !
}

void IN_Frame( void ) {

/* IN_JoyMove(); - moved to emulate mouse */
IN_ActivateMouse();
IN_ProcessEvents( );//Q3 keyboard
/* IN_MouseMove(); */
}

void GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned char blue[256] ) {
Expand All @@ -362,5 +341,6 @@ void IN_Activate( void ) {
}

void Sys_SendKeyEvents( void ) {
/* IN_ProcessEvents( )*/
}

7 changes: 4 additions & 3 deletions src/unix/unix_main.c
Expand Up @@ -376,7 +376,8 @@ void Sys_ConsoleInputInit() {
signal( SIGTTOU, SIG_IGN );

// FIXME TTimo initialize this in Sys_Init or something?
ttycon = Cvar_Get( "ttycon", "1", 0 );
ttycon = 0;//Cvar_Get( "ttycon", "1", 0 );
/* ttycon disabled*/
if ( ttycon && ttycon->value ) {
if ( isatty( STDIN_FILENO ) != 1 ) {
Com_Printf( "stdin is not a tty, tty console mode failed\n" );
Expand Down Expand Up @@ -1014,6 +1015,7 @@ sysEvent_t Sys_GetEvent( void ) {
Sys_SendKeyEvents();

// check for console commands
/*
s = Sys_ConsoleInput();
if ( s ) {
char *b;
Expand All @@ -1024,7 +1026,7 @@ sysEvent_t Sys_GetEvent( void ) {
strcpy( b, s );
Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );
}

*/
// check for other input devices
IN_Frame();

Expand Down Expand Up @@ -1276,7 +1278,6 @@ int main( int argc, char* argv[] ) {

Com_Init( cmdline );
NET_Init();

Sys_ConsoleInputInit();

fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) | FNDELAY );
Expand Down

0 comments on commit 0fdb3d8

Please sign in to comment.