summaryrefslogtreecommitdiff
path: root/misc/estic/files/patch-kbd.cc
blob: 20a8bfea3faf17f3c0027ea8778eb7f622823f51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--- spunk/bsdsrc/kbd.cc.orig	1996-12-10 13:41:06 UTC
+++ spunk/bsdsrc/kbd.cc
@@ -27,7 +27,7 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #ifdef FREEBSD
-#    include <machine/console.h>
+#    include <sys/kbio.h>
 #endif
 
 #include "../machine.h"
@@ -64,7 +64,7 @@ static CharSet		AvailExtKeys;
 
 
 // An array for mapping extended to virtual keys
-const VirtualMapSize = 50;
+const int VirtualMapSize = 50;
 struct { Key EK; Key VK; } VirtualMap [VirtualMapSize];
 static unsigned VirtualMapCount = 0;
 
@@ -192,7 +192,11 @@ static char* KbdGetCap (const char* Cap)
 {
     static char CapBuf [128];
     char* CapPtr = CapBuf;
+#if __FreeBSD_version <= 500000
+    return tgetstr ((char *)Cap, &CapPtr);
+#else
     return tgetstr (Cap, &CapPtr);
+#endif
 }
 
 
@@ -649,10 +653,22 @@ void Keyboard::GetMappedKey (int Wait)
 	    }
 
 	    // Now read in a new chunk of chars.
-	    int Count;
+	    int Count = 0;
 	    do {
-		Count = read (0, &Buf [BufFill], sizeof (Buf) - BufFill - 1);
-		if (Count == 0) {
+		// Timeout is 100ms
+		timeval Timeout;
+		Timeout.tv_usec = 100000;       // 100 ms
+		Timeout.tv_sec  = 0;
+
+		// File descriptor is 0 (stdin)
+		fd_set Desc;
+		FD_ZERO (&Desc);
+		FD_SET (STDIN_FILENO, &Desc);
+
+		// Check input status
+		if (select (STDIN_FILENO+1, &Desc, NULL, NULL, &Timeout) > 0) {
+		    Count = read (STDIN_FILENO, &Buf [BufFill], sizeof (Buf) - BufFill - 1);
+		} else {
 		    // Timeout waiting for a key, allow some idle processing
 		    App->Idle ();
 		}