aboutsummaryrefslogtreecommitdiffhomepage
path: root/input_common.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2011-12-26 21:05:25 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2011-12-26 21:05:25 -0800
commit04856aded0ef416c4ff6e4468e30276dde525ec9 (patch)
treeeb7874d5dddc8e78f54470e0ad5f44369e158f9b /input_common.cpp
parenta9c238a1fcdc4c6e8ca7aaba36d60958885b1b3c (diff)
IO port
Diffstat (limited to 'input_common.cpp')
-rw-r--r--input_common.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/input_common.cpp b/input_common.cpp
index e51ea6a9..0e1fb40b 100644
--- a/input_common.cpp
+++ b/input_common.cpp
@@ -25,6 +25,7 @@ Implementation file for the low level input library
#include "wutil.h"
#include "input_common.h"
#include "env_universal.h"
+#include "iothread.h"
/**
Time in milliseconds to wait for another byte to be available for
@@ -69,21 +70,27 @@ static wint_t readb()
do
{
- fd_set fd;
- int fd_max=1;
+ fd_set fdset;
+ int fd_max=0;
+ int ioport = iothread_port();
int res;
- FD_ZERO( &fd );
- FD_SET( 0, &fd );
+ FD_ZERO( &fdset );
+ FD_SET( 0, &fdset );
if( env_universal_server.fd > 0 )
{
- FD_SET( env_universal_server.fd, &fd );
- fd_max = env_universal_server.fd+1;
+ FD_SET( env_universal_server.fd, &fdset );
+ if (fd_max < env_universal_server.fd) fd_max = env_universal_server.fd;
}
+ if (ioport > 0) {
+ FD_SET( ioport, &fdset );
+ if (fd_max < ioport) fd_max = ioport;
+ }
+
do_loop = 0;
- res = select( fd_max, &fd, 0, 0, 0 );
+ res = select( fd_max + 1, &fdset, 0, 0, 0 );
if( res==-1 )
{
switch( errno )
@@ -122,7 +129,7 @@ static wint_t readb()
{
if( env_universal_server.fd > 0 )
{
- if( FD_ISSET( env_universal_server.fd, &fd ) )
+ if( FD_ISSET( env_universal_server.fd, &fdset ) )
{
debug( 3, L"Wake up on universal variable event" );
env_universal_read_all();
@@ -134,7 +141,17 @@ static wint_t readb()
}
}
}
- if( FD_ISSET( 0, &fd ) )
+
+ if ( ioport > 0 )
+ {
+ if (FD_ISSET(ioport, &fdset) )
+ {
+ iothread_service_completion();
+ }
+ do_loop = 1;
+ }
+
+ if( FD_ISSET( 0, &fdset ) )
{
if( read_blocked( 0, arr, 1 ) != 1 )
{
@@ -152,7 +169,6 @@ static wint_t readb()
return arr[0];
}
-
wchar_t input_common_readch( int timed )
{
if( lookahead_count == 0 )