home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / server / xinput / xstubs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-24  |  9.3 KB  |  276 lines

  1. /* $XConsortium: xstubs.c,v 1.8 91/07/24 15:48:40 rws Exp $ */
  2.  
  3. /************************************************************
  4. Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, California, and the 
  5. Massachusetts Institute of Technology, Cambridge, Massachusetts.
  6.  
  7.             All Rights Reserved
  8.  
  9. Permission to use, copy, modify, and distribute this software and its
  10. documentation for any purpose and without fee is hereby granted,
  11. provided that the above copyright notice appear in all copies and that
  12. both that copyright notice and this permission notice appear in
  13. supporting documentation, and that the names of Hewlett-Packard or MIT not be
  14. used in advertising or publicity pertaining to distribution of the
  15. software without specific, written prior permission.
  16.  
  17. HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  19. HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24.  
  25. ********************************************************/
  26.  
  27. #define     NEED_EVENTS
  28. #include "X.h"
  29. #include "Xproto.h"
  30. #include "inputstr.h"
  31. #include "XI.h"
  32. #include "XIproto.h"
  33.  
  34. /***********************************************************************
  35.  *
  36.  * Caller:    ProcXChangeKeyboardDevice
  37.  *
  38.  * This procedure does the implementation-dependent portion of the work
  39.  * needed to change the keyboard device.
  40.  *
  41.  * The X keyboard device has a FocusRec.  If the device that has been 
  42.  * made into the new X keyboard did not have a FocusRec, 
  43.  * ProcXChangeKeyboardDevice will allocate one for it.
  44.  *
  45.  * If you do not want clients to be able to focus the old X keyboard
  46.  * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
  47.  *
  48.  * If you support input devices with keys that you do not want to be 
  49.  * used as the X keyboard, you need to check for them here and return 
  50.  * a BadDevice error.
  51.  *
  52.  * The default implementation is to do nothing (assume you do want
  53.  * clients to be able to focus the old X keyboard).  The commented-out
  54.  * sample code shows what you might do if you don't want the default.
  55.  *
  56.  */
  57.  
  58. int
  59. ChangeKeyboardDevice (old_dev, new_dev)
  60.     DeviceIntPtr    old_dev;
  61.     DeviceIntPtr    new_dev;
  62.     {
  63.     /***********************************************************************
  64.      DeleteFocusClassDeviceStruct(old_dev);     * defined in xchgptr.c *
  65.     **********************************************************************/
  66.     }
  67.  
  68.  
  69. /***********************************************************************
  70.  *
  71.  * Caller:    ProcXChangePointerDevice
  72.  *
  73.  * This procedure does the implementation-dependent portion of the work
  74.  * needed to change the pointer device.
  75.  *
  76.  * The X pointer device does not have a FocusRec.  If the device that
  77.  * has been made into the new X pointer had a FocusRec, 
  78.  * ProcXChangePointerDevice will free it.
  79.  *
  80.  * If you want clients to be able to focus the old pointer device that
  81.  * has now become accessible through the input extension, you need to 
  82.  * add a FocusRec to it here.
  83.  *
  84.  * The XChangePointerDevice protocol request also allows the client
  85.  * to choose which axes of the new pointer device are used to move 
  86.  * the X cursor in the X- and Y- directions.  If the axes are different
  87.  * than the default ones, you need to keep track of that here.
  88.  *
  89.  * If you support input devices with valuators that you do not want to be 
  90.  * used as the X pointer, you need to check for them here and return a 
  91.  * BadDevice error.
  92.  *
  93.  * The default implementation is to do nothing (assume you don't want
  94.  * clients to be able to focus the old X pointer).  The commented-out
  95.  * sample code shows what you might do if you don't want the default.
  96.  *
  97.  */
  98.  
  99. int
  100. ChangePointerDevice (old_dev, new_dev, x, y)
  101.     DeviceIntPtr    old_dev, new_dev;
  102.     unsigned char    x, y;
  103.     {
  104.     /***********************************************************************
  105.     InitFocusClassDeviceStruct(old_dev);    * allow focusing old ptr*
  106.  
  107.     x_axis = x;                    * keep track of new x-axis*
  108.     y_axis = y;                    * keep track of new y-axis*
  109.     if (x_axis != 0 || y_axis != 1)
  110.     axes_changed = TRUE;            * remember axes have changed*
  111.     else
  112.     axes_changed = FALSE;
  113.     *************************************************************************/
  114.     }
  115.  
  116. /***********************************************************************
  117.  *
  118.  * Caller:    ProcXCloseDevice
  119.  *
  120.  * Take care of implementation-dependent details of closing a device.
  121.  * Some implementations may actually close the device, others may just
  122.  * remove this clients interest in that device.
  123.  *
  124.  * The default implementation is to do nothing (assume all input devices
  125.  * are initialized during X server initialization and kept open).
  126.  *
  127.  */
  128.  
  129. void
  130. CloseInputDevice (d, client)
  131.     DeviceIntPtr d;
  132.     ClientPtr client;
  133.     {
  134.     }
  135.  
  136. /***********************************************************************
  137.  *
  138.  * Caller:    ProcXListInputDevices
  139.  *
  140.  * This is the implementation-dependent routine to initialize an input 
  141.  * device to the point that information about it can be listed.
  142.  * Some implementations open all input devices when the server is first
  143.  * initialized, and never close them.  Other implementations open only
  144.  * the X pointer and keyboard devices during server initialization,
  145.  * and only open other input devices when some client makes an
  146.  * XOpenDevice request.  If some other process has the device open, the
  147.  * server may not be able to get information about the device to list it.
  148.  *
  149.  * This procedure should be used by implementations that do not initialize
  150.  * all input devices at server startup.  It should do device-dependent
  151.  * initialization for any devices not previously initialized, and call
  152.  * AddInputDevice for each of those devices so that a DeviceIntRec will be 
  153.  * created for them.
  154.  *
  155.  * The default implementation is to do nothing (assume all input devices
  156.  * are initialized during X server initialization and kept open).
  157.  * The commented-out sample code shows what you might do if you don't want 
  158.  * the default.
  159.  *
  160.  */
  161.  
  162. void
  163. AddOtherInputDevices ()
  164.     {
  165.     DeviceIntPtr dev;
  166.     DeviceProc deviceProc;
  167.     pointer private;
  168.  
  169.     /**********************************************************************
  170.      for each uninitialized device, do something like: 
  171.  
  172.     dev = (DeviceIntPtr) AddInputDevice(deviceProc, TRUE);
  173.     dev->public.devicePrivate = private;
  174.     RegisterOtherDevice(dev);
  175.     dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
  176.     ************************************************************************/
  177.  
  178.     }
  179.  
  180. /***********************************************************************
  181.  *
  182.  * Caller:    ProcXOpenDevice
  183.  *
  184.  * This is the implementation-dependent routine to open an input device.
  185.  * Some implementations open all input devices when the server is first
  186.  * initialized, and never close them.  Other implementations open only
  187.  * the X pointer and keyboard devices during server initialization,
  188.  * and only open other input devices when some client makes an
  189.  * XOpenDevice request.  This entry point is for the latter type of 
  190.  * implementation.
  191.  *
  192.  * If the physical device is not already open, do it here.  In this case,
  193.  * you need to keep track of the fact that one or more clients has the
  194.  * device open, and physically close it when the last client that has
  195.  * it open does an XCloseDevice.
  196.  *
  197.  * The default implementation is to do nothing (assume all input devices
  198.  * are opened during X server initialization and kept open).
  199.  *
  200.  */
  201.  
  202. void
  203. OpenInputDevice (dev, client, status)
  204.     DeviceIntPtr dev;
  205.     ClientPtr client;
  206.     int *status;
  207.     {
  208.     }
  209.  
  210. /****************************************************************************
  211.  *
  212.  * Caller:    ProcXSetDeviceMode
  213.  *
  214.  * Change the mode of an extension device.
  215.  * This function is used to change the mode of a device from reporting
  216.  * relative motion to reporting absolute positional information, and
  217.  * vice versa.
  218.  * The default implementation below is that no such devices are supported.
  219.  *
  220.  */
  221.  
  222. int
  223. SetDeviceMode (client, dev, mode)
  224.     register    ClientPtr    client;
  225.     DeviceIntPtr dev;
  226.     int        mode;
  227.     {
  228.     return BadMatch;
  229.     }
  230.  
  231. /****************************************************************************
  232.  *
  233.  * Caller:    ProcXSetDeviceValuators
  234.  *
  235.  * Set the value of valuators on an extension input device.
  236.  * This function is used to set the initial value of valuators on
  237.  * those input devices that are capable of reporting either relative
  238.  * motion or an absolute position, and allow an initial position to be set.
  239.  * The default implementation below is that no such devices are supported.
  240.  *
  241.  */
  242.  
  243. int
  244. SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
  245.     register    ClientPtr    client;
  246.     DeviceIntPtr dev;
  247.     int        *valuators;
  248.     int        first_valuator;
  249.     int        num_valuators;
  250.     {
  251.     return BadMatch;
  252.     }
  253.  
  254. /****************************************************************************
  255.  *
  256.  * Caller:    ProcXChangeDeviceControl
  257.  *
  258.  * Change the specified device controls on an extension input device.
  259.  *
  260.  */
  261.  
  262. int
  263. ChangeDeviceControl (client, dev, control)
  264.     register    ClientPtr    client;
  265.     DeviceIntPtr dev;
  266.     xDeviceCtl    *control;
  267.     {
  268.     switch (control->control)
  269.     {
  270.     case DEVICE_RESOLUTION:
  271.         return (BadMatch);
  272.     default:
  273.         return (BadMatch);
  274.     }
  275.     }
  276.