| 1 |
/************************************************************ |
| 2 |
|
| 3 |
Copyright 2008 Peter Hutterer |
| 4 |
|
| 5 |
Permission to use, copy, modify, distribute, and sell this software and its |
| 6 |
documentation for any purpose is hereby granted without fee, provided that |
| 7 |
the above copyright notice appear in all copies and that both that |
| 8 |
copyright notice and this permission notice appear in supporting |
| 9 |
documentation. |
| 10 |
|
| 11 |
The above copyright notice and this permission notice shall be included in |
| 12 |
all copies or substantial portions of the Software. |
| 13 |
|
| 14 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 |
AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 18 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 19 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 20 |
|
| 21 |
Except as contained in this notice, the name of the author shall not be |
| 22 |
used in advertising or otherwise to promote the sale, use or other dealings |
| 23 |
in this Software without prior written authorization from the author. |
| 24 |
|
| 25 |
*/ |
| 26 |
|
| 27 |
/*********************************************************************** |
| 28 |
* XListDeviceProperties - List an input device's properties. |
| 29 |
*/ |
| 30 |
|
| 31 |
|
| 32 |
#ifdef HAVE_CONFIG_H |
| 33 |
#include <config.h> |
| 34 |
#endif |
| 35 |
|
| 36 |
#include <X11/Xlibint.h> |
| 37 |
#include <X11/extensions/XI.h> |
| 38 |
#include <X11/extensions/XIproto.h> |
| 39 |
#include <X11/extensions/XInput.h> |
| 40 |
#include <X11/extensions/extutil.h> |
| 41 |
#include "XIint.h" |
| 42 |
|
| 43 |
Atom* |
| 44 |
XListDeviceProperties(Display* dpy, XDevice* dev, int *nprops_return) |
| 45 |
{ |
| 46 |
xListDevicePropertiesReq *req; |
| 47 |
xListDevicePropertiesReply rep; |
| 48 |
XExtDisplayInfo *info = XInput_find_display(dpy); |
| 49 |
Atom *props = NULL; |
| 50 |
|
| 51 |
LockDisplay(dpy); |
| 52 |
*nprops_return = 0; |
| 53 |
if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) |
| 54 |
return NULL; |
| 55 |
|
| 56 |
GetReq(ListDeviceProperties, req); |
| 57 |
req->reqType = info->codes->major_opcode; |
| 58 |
req->ReqType = X_ListDeviceProperties; |
| 59 |
req->deviceid = dev->device_id; |
| 60 |
|
| 61 |
if (!_XReply(dpy, (xReply*)&rep, 0, xFalse)) |
| 62 |
goto cleanup; |
| 63 |
|
| 64 |
if (rep.nAtoms) { |
| 65 |
props = (Atom*)Xmalloc(rep.nAtoms * sizeof(Atom)); |
| 66 |
if (!props) |
| 67 |
{ |
| 68 |
_XEatDataWords(dpy, rep.length); |
| 69 |
goto cleanup; |
| 70 |
} |
| 71 |
|
| 72 |
_XRead32(dpy, (long*)props, rep.nAtoms << 2); |
| 73 |
} |
| 74 |
|
| 75 |
*nprops_return = rep.nAtoms; |
| 76 |
|
| 77 |
cleanup: |
| 78 |
UnlockDisplay(dpy); |
| 79 |
SyncHandle(); |
| 80 |
return props; |
| 81 |
} |
| 82 |
|