- implemented idle hack for the term gui (patch by H. Johansson)

This commit is contained in:
Volker Ruppert 2005-06-17 18:37:51 +00:00
parent 5ab6c3d607
commit 3d9495bb45
2 changed files with 42 additions and 5 deletions

View File

@ -210,8 +210,8 @@
#define BX_HAVE_MKTIME 0
// This turns on Roland Mainz's idle hack. Presently it is specific to the X11
// gui. If people try to enable it elsewhere, give a compile error after the
// gui definition so that they don't waste their time trying.
// and term gui. If people try to enable it elsewhere, give a compile error
// after the gui definition so that they don't waste their time trying.
#define BX_USE_IDLE_HACK 0
// Minimum Emulated IPS.
@ -442,8 +442,8 @@
// Roland Mainz's idle hack is presently specific to X11. If people try to
// enable it elsewhere, give a compile error so that they don't waste their
// time trying.
#if (BX_USE_IDLE_HACK && !BX_WITH_X11)
# error IDLE_HACK will only work with the X11 gui. Correct configure args and retry.
#if (BX_USE_IDLE_HACK && !BX_WITH_X11 && !BX_WITH_TERM)
# error IDLE_HACK will only work with the X11 or term gui. Correct configure args and retry.
#endif
#define WORDS_BIGENDIAN 0

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: term.cc,v 1.32 2004-06-26 07:06:23 sshwarts Exp $
// $Id: term.cc,v 1.33 2005-06-17 18:37:51 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2000 MandrakeSoft S.A.
@ -46,6 +46,9 @@ class bx_term_gui_c : public bx_gui_c {
public:
bx_term_gui_c (void) {}
DECLARE_GUI_VIRTUAL_METHODS()
#if BX_USE_IDLE_HACK
virtual void sim_is_idle(void);
#endif
virtual Bit32u get_sighandler_mask ();
// called when registered signal arrives
@ -841,4 +844,38 @@ bx_term_gui_c::exit(void)
bx_term_gui_c::mouse_enabled_changed_specific (bx_bool val)
{
}
#if BX_USE_IDLE_HACK
void bx_term_gui_c::sim_is_idle () {
int res;
fd_set readfds;
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 1000; /* 1/1000 s */
FD_ZERO(&readfds);
FD_SET(0, &readfds); // Wait for input
res = select(1, &readfds, NULL, NULL, &timeout);
switch(res)
{
case -1: /* select() error - should not happen */
// This can happen when we have a alarm running, lets return
// perror("sim_is_idle: select() failure\n");
//fprintf (stderr,"Interrupted...\n");
//handle_events();
return;
case 0: /* timeout */
// fprintf (stderr,"Timeout...\n");
//handle_events();
return;
}
//fprintf (stderr,"Input...\n");
//handle_events();
}
#endif
#endif /* if BX_WITH_TERM */