summaryrefslogtreecommitdiff
path: root/misc/cuecat/patches/patch-ab
blob: 7fd7bc6c13b6357b41ed45f813c10eae2b997eee (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
$NetBSD: patch-ab,v 1.1.1.1 2001/02/13 13:55:42 wiz Exp $

--- read_cuecat.c.orig	Wed Sep 20 22:13:46 2000
+++ read_cuecat.c
@@ -4,8 +4,8 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <linux/kd.h>
-#include <linux/serial.h>
+#include <sys/time.h>
+#include <dev/wscons/wsconsio.h>
 #include <sys/ioctl.h>
 #include "cuecat_lib.h"
 #include "cuecat_at2xt.h"
@@ -24,8 +24,6 @@
 int previous_kbd_mode;
 struct termios old_term_settings;
 struct termios new_term_settings;
-struct serial_struct old_serinfo;
-struct serial_struct new_serinfo;
 char serial_dev_filename[FILENAME_MAX]=DEFAULT_SERIAL_DEV_FILE;
 char serial;
 char help;
@@ -55,6 +53,7 @@
   char barcode_type[CUECAT_BARCODE_TYPE_LEN+1];
   char barcode[256];
   int user_abort=0;
+  int ioctl_arg;
 
   /* Parse the command line parameters */
   if((invalid_parameter=parse_cmdline(argc,argv)))
@@ -83,7 +82,7 @@
   }
 
   /* Get a console or serial port descriptor */
-  fd=getfd();
+  fd=0;
 
   /* Did the user want to use a serial pod ? */
   if(!serial)
@@ -92,9 +91,9 @@
     printf("Press ESC to end the program ...\n\n");
 
     /* Get the current state of the keyboard */
-    if (ioctl(fd, KDGKBMODE, &previous_kbd_mode))
+    if (ioctl(fd, WSKBDIO_GETMODE, &previous_kbd_mode))
     {
-      perror("KDGKBMODE");
+      perror("WSKBDIO_GETMODE");
       close(fd);
       exit(1);
     }
@@ -103,11 +102,9 @@
     printf("The keyboard was in ");
     switch(previous_kbd_mode)
     {
-      case K_RAW:       printf("raw")      ;break;
-      case K_XLATE:     printf("xlate")    ;break;
-      case K_MEDIUMRAW: printf("mediumraw");break;
-      case K_UNICODE:   printf("unicode")  ;break;
-      default:          printf("unknown")  ;break;
+    case WSKBD_TRANSLATED: printf("translated"); break;
+    case WSKBD_RAW: printf("raw"); break;
+    default: printf("unknown(%d)",previous_kbd_mode); break;
     }
     printf(" state.\n\n");
 
@@ -139,9 +136,10 @@
       close(fd);
       exit(1);
     }
-    if (ioctl(fd,KDSKBMODE,K_RAW))
+    ioctl_arg = WSKBD_RAW;
+    if (ioctl(fd,WSKBDIO_SETMODE,&ioctl_arg))
     {
-      perror("KDSKBMODE");
+      perror("WSKBDIO_SETMODE");
       close(fd);
       exit(1);
     }
@@ -151,13 +149,6 @@
     /* Give a quick word of advise */
     printf("Press CTRL-C to end the program ...\n\n");
 
-    /* Get the current state of the serial port */
-    if(ioctl(fd,TIOCGSERIAL,&old_serinfo))
-    {
-      perror("TIOCGSERIAL");
-      close(fd);
-      exit(1);
-    }
     if(tcgetattr(fd,&old_term_settings)==-1)
     {
       perror("tcgetattr");
@@ -165,28 +156,12 @@
       exit(1);
     }
 
-    new_serinfo=old_serinfo;
     new_term_settings=old_term_settings;
 
     /* Setup the signal handler to trap any signal that might kill us before
        we can restore the serial port as it was before */
     setup_signal_handlers();
 
-    /* set SPD_CUST and divisor */
-    new_serinfo.flags&=~ASYNC_SPD_MASK;
-    new_serinfo.flags|=ASYNC_SPD_CUST;
-
-    /* we measured the cuecat's baudrate  to be about 8000 the closest we can
-       get to this with a basebaud of 115200 is to use a divisor of 14 */
-    new_serinfo.custom_divisor=14;
-
-    if (ioctl(fd,TIOCSSERIAL,&new_serinfo))
-    {
-      perror("TIOCSSERIAL");
-      close(fd);
-      exit(1);
-    }
-
     cfmakeraw(&new_term_settings);
     cfsetospeed(&new_term_settings, B38400);
 
@@ -268,9 +243,9 @@
 /* Restore the keyboard and console as they where when we started */
 void restore_console()
 {
-  if(ioctl(fd,KDSKBMODE,previous_kbd_mode))
+  if(ioctl(fd,WSKBDIO_SETMODE,&previous_kbd_mode))
   {
-    perror("KDSKBMODE");
+    perror("WSKBDIO_SETMODE");
     close(fd);
     exit(1);
   }
@@ -288,12 +263,6 @@
 /* Restore the keyboard and console as they where when we started */
 void restore_serial_port()
 {
-  if(ioctl(fd,TIOCSSERIAL,&old_serinfo)==-1)
-  {
-    perror("TIOCSSERIAL");
-    close(fd);
-    exit(1);
-  }
   close(fd);
 }
 
@@ -361,8 +330,11 @@
   char arg;
 
   arg=0;
+  return 1;
+#if 0
   return(ioctl(fd,KDGKBTYPE,&arg)==0
          && ((arg==KB_101) || (arg==KB_84)));
+#endif
 }