summaryrefslogtreecommitdiff
path: root/static/freebsd/man4/vkbd.4 3.html
blob: ed21f7a7ddae91bc789dbac960eada2f88213d19 (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
<table class="head">
  <tr>
    <td class="head-ltitle">VKBD(4)</td>
    <td class="head-vol">Device Drivers Manual</td>
    <td class="head-rtitle">VKBD(4)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">vkbd</code> &#x2014; <span class="Nd">the virtual
    AT keyboard interface</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="Cd">device vkbd</code></p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The <code class="Nm">vkbd</code> interface is a software loopback
    mechanism that can be loosely described as the virtual AT keyboard analog of
    the <a class="Xr">pty(4)</a>, that is, <code class="Nm">vkbd</code> does for
    virtual AT keyboards what the <a class="Xr">pty(4)</a> driver does for
    terminals.</p>
<p class="Pp">The <code class="Nm">vkbd</code> driver, like the
    <a class="Xr">pty(4)</a> driver, provides two interfaces: a keyboard
    interface like the usual facility it is simulating (a virtual AT keyboard in
    the case of <code class="Nm">vkbd</code>, or a terminal for
    <a class="Xr">pty(4)</a>), and a character-special device
    &#x201C;control&#x201D; interface.</p>
<p class="Pp">The virtual AT keyboards are named <span class="Pa">vkbd0</span>,
    <span class="Pa">vkbd1</span>, etc., one for each control device that has
    been opened.</p>
<p class="Pp">The <code class="Nm">vkbd</code> interface permits opens on the
    special control device <span class="Pa">/dev/vkbdctl</span>. When this
    device is opened, <code class="Nm">vkbd</code> will return a handle for the
    lowest unused <span class="Pa">vkbdctl</span> device (use
    <a class="Xr">devname(3)</a> to determine which).</p>
<p class="Pp">Each virtual AT keyboard supports the usual keyboard interface
    <a class="Xr">ioctl(2)</a>s, and thus can be used with
    <a class="Xr">kbdcontrol(1)</a> like any other keyboard. The control device
    supports exactly the same <a class="Xr">ioctl(2)</a>s as the virtual AT
    keyboard device. Writing AT scan codes to the control device generates an
    input on the virtual AT keyboard, as if the (non-existent) hardware had just
    received it.</p>
<p class="Pp">The virtual AT keyboard control device, normally
    <span class="Pa">/dev/vkbdctl</span>&#x27E8;<var class="Ar">N</var>&#x27E9;,
    is exclusive-open (it cannot be opened if it is already open) and is
    restricted to the super-user. A <a class="Xr">read(2)</a> call will return
    the virtual AT keyboard status structure (defined in
    <code class="In">&lt;<a class="In">dev/vkbd/vkbd_var.h</a>&gt;</code>) if
    one is available; if not, it will either block until one is or return
    <code class="Er">EWOULDBLOCK</code>, depending on whether non-blocking I/O
    has been enabled.</p>
<p class="Pp">A <a class="Xr">write(2)</a> call passes AT scan codes to be
    &#x201C;received&#x201D; from the virtual AT keyboard. Each AT scan code
    must be passed as <var class="Vt">unsigned int</var>. Although AT scan codes
    must be passes as <var class="Vt">unsigned int</var>s, the size of the
    buffer passed to <a class="Xr">write(2)</a> still should be in bytes,
  i.e.,</p>
<div class="Bd Pp Bd-indent Li">
<pre>static unsigned int     codes[] =
{
/*      Make    Break */
        0x1e,   0x9e
};

int
main(void)
{
        int     fd, len;

        fd = open(&quot;/dev/vkbdctl0&quot;, O_RDWR);
        if (fd &lt; 0)
                err(1, &quot;open&quot;);

        /* Note sizeof(codes) - not 2! */
        len = write(fd, codes, sizeof(codes));
        if (len &lt; 0)
                err(1, &quot;write&quot;);

        close(fd);

        return (0);
}</pre>
</div>
<p class="Pp">Write will block if there is not enough space in the input
  queue.</p>
<p class="Pp">The control device also supports <a class="Xr">select(2)</a> for
    read and write.</p>
<p class="Pp">On the last close of the control device, the virtual AT keyboard
    is removed. All queued scan codes are thrown away.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">kbdcontrol(1)</a>, <a class="Xr">atkbdc(4)</a>,
    <a class="Xr">psm(4)</a>, <a class="Xr">syscons(4)</a>,
    <a class="Xr">vt(4)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<p class="Pp">The <code class="Nm">vkbd</code> module was implemented in
    <span class="Ux">FreeBSD 6.0</span>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp"><span class="An">Maksim Yevmenkin</span>
    &lt;<a class="Mt" href="mailto:m_evmenkin@yahoo.com">m_evmenkin@yahoo.com</a>&gt;</p>
</section>
<section class="Sh">
<h1 class="Sh" id="CAVEATS"><a class="permalink" href="#CAVEATS">CAVEATS</a></h1>
<p class="Pp">The <code class="Nm">vkbd</code> interface is a software loopback
    mechanism, and, thus <a class="Xr">ddb(4)</a> will not work with it. Current
    implementation of the <a class="Xr">syscons(4)</a> driver can accept input
    from only one keyboard, even if it is virtual. Thus it is not possible to
    have both wired and virtual keyboard to be active at the same time. It is,
    however, in principal possible to obtain AT scan codes from the different
    sources and write them into the same virtual keyboard. The virtual keyboard
    state synchronization is the user's responsibility.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">August 12, 2004</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>