<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<!-- lifted from troff+man by doclifter -->
<refentry id='xckmpingman'>
<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium -->

<!--  Permission is hereby granted, free of charge, to any person obtaining -->
<!--  a copy of this software and associated documentation files (the -->
<!--  "Software"), to deal in the Software without restriction, including -->
<!--  without limitation the rights to use, copy, modify, merge, publish, -->
<!--  distribute, sublicense, and/or sell copies of the Software, and to -->
<!--  permit persons to whom the Software is furnished to do so, subject to -->
<!--  the following conditions: -->

<!--  The above copyright notice and this permission notice shall be included -->
<!--  in all copies or substantial portions of the Software. -->

<!--  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -->
<!--  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -->
<!--  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -->
<!--  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR -->
<!--  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -->
<!--  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -->
<!--  OTHER DEALINGS IN THE SOFTWARE. -->

<!--  Except as contained in this notice, the name of the X Consortium shall -->
<!--  not be used in advertising or otherwise to promote the sale, use or -->
<!--  other dealings in this Software without prior written authorization -->
<!--  from the X Consortium. -->

<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by -->
<!--  Digital Equipment Corporation -->

<!--  Portions Copyright \(co 1990, 1991 by -->
<!--  Tektronix, Inc. -->

<!--  Permission to use, copy, modify and distribute this documentation for -->
<!--  any purpose and without fee is hereby granted, provided that the above -->
<!--  copyright notice appears in all copies and that both that copyright notice -->
<!--  and this permission notice appear in all copies, and that the names of -->
<!--  Digital and Tektronix not be used in in advertising or publicity pertaining -->
<!--  to this documentation without specific, written prior permission. -->
<!--  Digital and Tektronix makes no representations about the suitability -->
<!--  of this documentation for any purpose. -->
<!--  It is provided ``as is'' without express or implied warranty. -->
<!--   -->
<!--  $XFree86: xc/doc/man/X11/XCKMping.man,v 1.5 2003/11/23 05:40:33 dawes Exp $ -->

<!-- .na -->
<!-- FD listing suppressed (not used) -->
<!-- FN listing suppressed (not used) -->
<!-- IN listing suppressed (not used) -->
<!-- C{ listing suppressed (not used) -->
<!-- C} listing suppressed (not used) -->
<!-- Pn listing suppressed (not used) -->
<!-- hN listing suppressed (not used) -->
<!-- NT listing suppressed (not used) -->
<!-- .		\" Note End \-\- doug kraft 3/85 -->
<!-- NE listing suppressed (not used) -->
<!-- .ny0 -->
<refmeta>
<refentrytitle>XChangeKeyboardMapping</refentrytitle>
<manvolnum>3X11</manvolnum>
<refmiscinfo class='date'>__xorgversion__</refmiscinfo>
<refmiscinfo class='source'>XLIB FUNCTIONS</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>XChangeKeyboardMapping</refname>
<refname>XGetKeyboardMapping</refname>
<refname>XDisplayKeycodes</refname>
<refname>XSetModifierMapping</refname>
<refname>XGetModifierMapping</refname>
<refname>XNewModifiermap</refname>
<refname>XInsertModifiermapEntry</refname>
<refname>XDeleteModifiermapEntry</refname>
<refname>XFreeModifierMap XModifierKeymap</refname>
<refpurpose>manipulate keyboard encoding and keyboard encoding structure</refpurpose>
</refnamediv>
<!-- body begins here -->

<refsect1 id='syntax'><title>SYNTAX</title>

<para>int XChangeKeyboardMapping(&hairsp;Display *<emphasis remap='I'>display</emphasis>, int <emphasis remap='I'>first_keycode</emphasis>,
int <emphasis remap='I'>keysyms_per_keycode</emphasis>, KeySym *<emphasis remap='I'>keysyms</emphasis>, int <emphasis remap='I'>num_codes</emphasis>&hairsp;);</para> 

<para>KeySym *XGetKeyboardMapping(&hairsp;Display *<emphasis remap='I'>display</emphasis>, KeyCode
<emphasis remap='I'>first_keycode</emphasis>, int <emphasis remap='I'>keycode_count</emphasis>, int
*<emphasis remap='I'>keysyms_per_keycode_return</emphasis>&hairsp;);</para> 

<para>int XDisplayKeycodes&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, int
*<emphasis remap='I'>min_keycodes_return</emphasis>&hairsp;, int *<emphasis remap='I'>max_keycodes_return</emphasis>&hairsp;);</para> 

<para>int XSetModifierMapping(&hairsp;Display *<emphasis remap='I'>display</emphasis>, XModifierKeymap
*<emphasis remap='I'>modmap</emphasis>&hairsp;);</para> 

<para>XModifierKeymap *XGetModifierMapping(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;);</para> 

<para>XModifierKeymap *XNewModifiermap(&hairsp;int <emphasis remap='I'>max_keys_per_mod</emphasis>&hairsp;);</para> 

<para>XModifierKeymap *XInsertModifiermapEntry&hairsp;(&hairsp;XModifierKeymap *<emphasis remap='I'>modmap</emphasis>,
KeyCode <emphasis remap='I'>keycode_entry</emphasis>, int <emphasis remap='I'>modifier</emphasis>&hairsp;);</para> 

<para>XModifierKeymap *XDeleteModifiermapEntry&hairsp;(&hairsp;XModifierKeymap *<emphasis remap='I'>modmap</emphasis>,
KeyCode <emphasis remap='I'>keycode_entry</emphasis>, int <emphasis remap='I'>modifier</emphasis>&hairsp;);</para> 

<para>int XFreeModifiermap(&hairsp;XModifierKeymap *<emphasis remap='I'>modmap</emphasis>&hairsp;);</para> 
</refsect1>

<refsect1 id='arguments'><title>ARGUMENTS</title>
<variablelist remap='IP'>
  <varlistentry>
  <term><emphasis remap='I'>display</emphasis></term>
  <listitem>
<para>Specifies the connection to the X server.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>first_keycode</emphasis></term>
  <listitem>
<para>Specifies the first KeyCode that is to be changed or returned.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>keycode_count</emphasis></term>
  <listitem>
<para>Specifies the number of KeyCodes that are to be returned.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>keycode_entry</emphasis></term>
  <listitem>
<para>Specifies the KeyCode.</para> 
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>keysyms</emphasis></term>
  <listitem>
<para>Specifies an array of KeySyms.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>keysyms_per_keycode</emphasis></term>
  <listitem>
<para>Specifies the number of KeySyms per KeyCode.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>keysyms_per_keycode_return</emphasis></term>
  <listitem>
<para>Returns the number of KeySyms per KeyCode.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>max_keys_per_mod</emphasis></term>
  <listitem>
<para>Specifies the number of KeyCode entries preallocated to the modifiers
in the map.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>max_keycodes_return</emphasis></term>
  <listitem>
<para>Returns the maximum number of KeyCodes.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>min_keycodes_return</emphasis></term>
  <listitem>
<para>Returns the minimum number of KeyCodes.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>modifier</emphasis></term>
  <listitem>
<para>Specifies the modifier.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>modmap</emphasis></term>
  <listitem>
<para>Specifies the 
<emphasis remap='I'>&hairsp;XModifierKeymap&hairsp;</emphasis>
structure.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>num_codes</emphasis></term>
  <listitem>
<para>Specifies the number of KeyCodes that are to be changed.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='description'><title>DESCRIPTION</title>
<para>The
<emphasis remap='I'>&hairsp;XChangeKeyboardMapping&hairsp;</emphasis>
function defines the symbols for the specified number of KeyCodes
starting with first_keycode.
The symbols for KeyCodes outside this range remain unchanged.  
The number of elements in keysyms must be:</para>

<literallayout remap='.nf'>
<!-- .D   -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
num_codes * keysyms_per_keycode
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>The specified first_keycode must be greater than or equal to min_keycode 
returned by
<emphasis remap='I'>&hairsp;XDisplayKeycodes&hairsp;</emphasis>,
or a 
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>
error results.
In addition, the following expression must be less than or equal to 
max_keycode as returned by
<emphasis remap='I'>&hairsp;XDisplayKeycodes&hairsp;</emphasis>,
or a
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>
error results:</para>

<literallayout remap='.nf'>
<!-- .D   -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
first_keycode + num_codes - 1
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>KeySym number N, counting from zero, for KeyCode K has the following index
in keysyms, counting from zero:</para> 

<literallayout remap='.nf'>
<!-- .D   -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
(K - first_keycode) * keysyms_per_keycode + N
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>The specified keysyms_per_keycode can be chosen arbitrarily by the client
to be large enough to hold all desired symbols. 
A special KeySym value of 
<emphasis remap='I'>&hairsp;NoSymbol&hairsp;</emphasis>
should be used to fill in unused elements 
for individual KeyCodes.  
It is legal for 
<emphasis remap='I'>&hairsp;NoSymbol&hairsp;</emphasis>
to appear in nontrailing positions
of the effective list for a KeyCode.
<emphasis remap='I'>&hairsp;XChangeKeyboardMapping&hairsp;</emphasis>
generates a 
<emphasis remap='I'>&hairsp;MappingNotify&hairsp;</emphasis>
event.</para>

<para>There is no requirement that the X server interpret this mapping. 
It is merely stored for reading and writing by clients.</para>

<para><emphasis remap='I'>&hairsp;XChangeKeyboardMapping&hairsp;</emphasis>
can generate
<emphasis remap='I'>&hairsp;BadAlloc&hairsp;</emphasis>
and
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>
errors.</para>

<para>The
<emphasis remap='I'>&hairsp;XGetKeyboardMapping&hairsp;</emphasis>
function returns the symbols for the specified number of KeyCodes
starting with first_keycode.
The value specified in first_keycode must be greater than 
or equal to min_keycode as returned by
<emphasis remap='I'>&hairsp;XDisplayKeycodes&hairsp;</emphasis>,
or a
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>
error results.
In addition, the following expression must be less than or equal 
to max_keycode as returned by
<emphasis remap='I'>&hairsp;XDisplayKeycodes&hairsp;</emphasis>:</para>

<literallayout remap='.nf'>
<!-- .D   -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
first_keycode + keycode_count - 1
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>If this is not the case, a 
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>
error results. 
The number of elements in the KeySyms list is:</para>

<literallayout remap='.nf'>
<!-- .D   -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
keycode_count * keysyms_per_keycode_return
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>KeySym number N, counting from zero, for KeyCode K has the following index
in the list, counting from zero:</para> 
<literallayout remap='.nf'>
<!-- .D   -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
(K - first_code) * keysyms_per_code_return + N
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>The X server arbitrarily chooses the keysyms_per_keycode_return value 
to be large enough to report all requested symbols. 
A special KeySym value of 
<emphasis remap='I'>&hairsp;NoSymbol&hairsp;</emphasis>
is used to fill in unused elements for
individual KeyCodes.
To free the storage returned by 
<emphasis remap='I'>&hairsp;XGetKeyboardMapping&hairsp;</emphasis>,
use
<emphasis remap='I'>&hairsp;XFree&hairsp;</emphasis>.</para>

<para><emphasis remap='I'>&hairsp;XGetKeyboardMapping&hairsp;</emphasis>
can generate a
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>
error.</para>

<para>The
<emphasis remap='I'>&hairsp;XDisplayKeycodes&hairsp;</emphasis>
function returns the min-keycodes and max-keycodes supported by the
specified display.
The minimum number of KeyCodes returned is never less than 8,
and the maximum number of KeyCodes returned is never greater than 255.
Not all KeyCodes in this range are required to have corresponding keys.</para>

<para>The
<emphasis remap='I'>&hairsp;XSetModifierMapping&hairsp;</emphasis>
function specifies the KeyCodes of the keys (if any) that are to be used 
as modifiers.
If it succeeds,
the X server generates a
<emphasis remap='I'>&hairsp;MappingNotify&hairsp;</emphasis>
event, and
<emphasis remap='I'>&hairsp;XSetModifierMapping&hairsp;</emphasis>
returns
<emphasis remap='I'>&hairsp;MappingSuccess&hairsp;</emphasis>.
X permits at most 8 modifier keys.
If more than 8 are specified in the
<emphasis remap='I'>&hairsp;XModifierKeymap&hairsp;</emphasis>
structure, a
<emphasis remap='I'>&hairsp;BadLength&hairsp;</emphasis>
error results.</para>

<para>The modifiermap member of the 
<emphasis remap='I'>&hairsp;XModifierKeymap&hairsp;</emphasis>
structure contains 8 sets of max_keypermod KeyCodes, 
one for each modifier in the order 
<emphasis remap='I'>&hairsp;Shift&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;Lock&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;Control&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;Mod1&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;Mod2&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;Mod3&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;Mod4&hairsp;</emphasis>,
and 
<emphasis remap='I'>&hairsp;Mod5&hairsp;</emphasis>.
Only nonzero KeyCodes have meaning in each set, 
and zero KeyCodes are ignored.
In addition, all of the nonzero KeyCodes must be in the range specified by 
min_keycode and max_keycode in the 
<emphasis remap='I'>&hairsp;Display&hairsp;</emphasis>
structure,
or a 
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>
error results.</para>

<para>An X server can impose restrictions on how modifiers can be changed, 
for example,
if certain keys do not generate up transitions in hardware,
if auto-repeat cannot be disabled on certain keys,
or if multiple modifier keys are not supported.  
If some such restriction is violated, 
the status reply is
<emphasis remap='I'>&hairsp;MappingFailed&hairsp;</emphasis>,
and none of the modifiers are changed.
If the new KeyCodes specified for a modifier differ from those
currently defined and any (current or new) keys for that modifier are
in the logically down state, 
<emphasis remap='I'>&hairsp;XSetModifierMapping&hairsp;</emphasis>
returns
<emphasis remap='I'>&hairsp;MappingBusy&hairsp;</emphasis>,
and none of the modifiers is changed.</para>

<para><emphasis remap='I'>&hairsp;XSetModifierMapping&hairsp;</emphasis>
can generate
<emphasis remap='I'>&hairsp;BadAlloc&hairsp;</emphasis>
and 
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>
errors.</para>

<para>The
<emphasis remap='I'>&hairsp;XGetModifierMapping&hairsp;</emphasis>
function returns a pointer to a newly created
<emphasis remap='I'>&hairsp;XModifierKeymap&hairsp;</emphasis>
structure that contains the keys being used as modifiers.
The structure should be freed after use by calling
<emphasis remap='I'>&hairsp;XFreeModifiermap&hairsp;</emphasis>.
If only zero values appear in the set for any modifier, 
that modifier is disabled.</para>

<para>The
<emphasis remap='I'>&hairsp;XNewModifiermap&hairsp;</emphasis>
function returns a pointer to
<emphasis remap='I'>&hairsp;XModifierKeymap&hairsp;</emphasis>
structure for later use.</para>

<para>The
<emphasis remap='I'>&hairsp;XInsertModifiermapEntry&hairsp;</emphasis>
function adds the specified KeyCode to the set that controls the specified
modifier and returns the resulting
<emphasis remap='I'>&hairsp;XModifierKeymap&hairsp;</emphasis>
structure (expanded as needed).</para>

<para>The
<emphasis remap='I'>&hairsp;XDeleteModifiermapEntry&hairsp;</emphasis>
function deletes the specified KeyCode from the set that controls the
specified modifier and returns a pointer to the resulting
<emphasis remap='I'>&hairsp;XModifierKeymap&hairsp;</emphasis>
structure.</para>

<para>The
<emphasis remap='I'>&hairsp;XFreeModifiermap&hairsp;</emphasis>
function frees the specified
<emphasis remap='I'>&hairsp;XModifierKeymap&hairsp;</emphasis>
structure.</para>
</refsect1>

<refsect1 id='structures'><title>STRUCTURES</title>
<para>The
<emphasis remap='I'>&hairsp;XModifierKeymap&hairsp;</emphasis>
structure contains:</para>

<literallayout remap='.nf'>
<!-- .0D  0 -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
<!-- .TA .5i 2.5i -->
<!-- .ta .5i 2.5i -->
typedef struct {
	int max_keypermod;	/&lowast; This server's max number of keys per modifier */
	KeyCode *modifiermap;	/&lowast; An 8 by max_keypermod array of the modifiers */
} XModifierKeymap;
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->
</refsect1>

<refsect1 id='diagnostics'><title>DIAGNOSTICS</title>
<variablelist remap='TP'>
  <varlistentry>
  <term><emphasis remap='I'>&hairsp;BadAlloc&hairsp;</emphasis></term>
  <listitem>
<para>The server failed to allocate the requested resource or server memory.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis></term>
  <listitem>
<para>Some numeric value falls outside the range of values accepted by the request.
Unless a specific range is specified for an argument, the full range defined
by the argument's type is accepted.  Any argument defined as a set of
alternatives can generate this error.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='see_also'><title>SEE ALSO</title>
<para>XFree(3X11),
XSetPointerMapping(3X11) 
<!-- .br -->
<userinput>Xlib - C Language X Interface</userinput></para>
</refsect1>
</refentry>

