setbmap.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /************************************************************
  2. Copyright 1989, 1998 The Open Group
  3. Permission to use, copy, modify, distribute, and sell this software and its
  4. documentation for any purpose is hereby granted without fee, provided that
  5. the above copyright notice appear in all copies and that both that
  6. copyright notice and this permission notice appear in supporting
  7. documentation.
  8. The above copyright notice and this permission notice shall be included in
  9. all copies or substantial portions of the Software.
  10. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  14. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. Except as contained in this notice, the name of The Open Group shall not be
  17. used in advertising or otherwise to promote the sale, use or other dealings
  18. in this Software without prior written authorization from The Open Group.
  19. Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
  20. All Rights Reserved
  21. Permission to use, copy, modify, and distribute this software and its
  22. documentation for any purpose and without fee is hereby granted,
  23. provided that the above copyright notice appear in all copies and that
  24. both that copyright notice and this permission notice appear in
  25. supporting documentation, and that the name of Hewlett-Packard not be
  26. used in advertising or publicity pertaining to distribution of the
  27. software without specific, written prior permission.
  28. HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  29. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  30. HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  31. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  32. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  33. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  34. SOFTWARE.
  35. ********************************************************/
  36. /***********************************************************************
  37. *
  38. * Request to change the button mapping of an extension device.
  39. *
  40. */
  41. #ifdef HAVE_DIX_CONFIG_H
  42. #include <dix-config.h>
  43. #endif
  44. #include "inputstr.h" /* DeviceIntPtr */
  45. #include <X11/extensions/XI.h>
  46. #include <X11/extensions/XIproto.h>
  47. #include "exevents.h"
  48. #include "exglobals.h"
  49. #include "setbmap.h"
  50. /***********************************************************************
  51. *
  52. * This procedure changes the button mapping.
  53. *
  54. */
  55. int
  56. SProcXSetDeviceButtonMapping(ClientPtr client)
  57. {
  58. REQUEST(xSetDeviceButtonMappingReq);
  59. swaps(&stuff->length);
  60. return (ProcXSetDeviceButtonMapping(client));
  61. }
  62. /***********************************************************************
  63. *
  64. * This procedure lists the input devices available to the server.
  65. *
  66. */
  67. int
  68. ProcXSetDeviceButtonMapping(ClientPtr client)
  69. {
  70. int ret;
  71. xSetDeviceButtonMappingReply rep;
  72. DeviceIntPtr dev;
  73. REQUEST(xSetDeviceButtonMappingReq);
  74. REQUEST_AT_LEAST_SIZE(xSetDeviceButtonMappingReq);
  75. if (stuff->length !=
  76. bytes_to_int32(sizeof(xSetDeviceButtonMappingReq) + stuff->map_length))
  77. return BadLength;
  78. ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
  79. if (ret != Success)
  80. return ret;
  81. rep = (xSetDeviceButtonMappingReply) {
  82. .repType = X_Reply,
  83. .RepType = X_SetDeviceButtonMapping,
  84. .sequenceNumber = client->sequence,
  85. .length = 0,
  86. .status = MappingSuccess
  87. };
  88. ret =
  89. ApplyPointerMapping(dev, (CARD8 *) &stuff[1], stuff->map_length,
  90. client);
  91. if (ret == -1)
  92. return BadValue;
  93. else if (ret == MappingBusy)
  94. rep.status = ret;
  95. else if (ret != Success)
  96. return ret;
  97. WriteReplyToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep);
  98. return Success;
  99. }
  100. /***********************************************************************
  101. *
  102. * This procedure writes the reply for the XSetDeviceButtonMapping function,
  103. * if the client and server have a different byte ordering.
  104. *
  105. */
  106. void
  107. SRepXSetDeviceButtonMapping(ClientPtr client, int size,
  108. xSetDeviceButtonMappingReply * rep)
  109. {
  110. swaps(&rep->sequenceNumber);
  111. swapl(&rep->length);
  112. WriteToClient(client, size, rep);
  113. }