121e67964Smrg/************************************************************ 221e67964Smrg 321e67964SmrgCopyright 2008 Peter Hutterer 421e67964Smrg 521e67964SmrgPermission to use, copy, modify, distribute, and sell this software and its 621e67964Smrgdocumentation for any purpose is hereby granted without fee, provided that 721e67964Smrgthe above copyright notice appear in all copies and that both that 821e67964Smrgcopyright notice and this permission notice appear in supporting 921e67964Smrgdocumentation. 1021e67964Smrg 1121e67964SmrgThe above copyright notice and this permission notice shall be included in 1221e67964Smrgall copies or substantial portions of the Software. 1321e67964Smrg 1421e67964SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1521e67964SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1621e67964SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1721e67964SmrgAUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 1821e67964SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1921e67964SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2021e67964Smrg 2121e67964SmrgExcept as contained in this notice, the name of the author shall not be 2221e67964Smrgused in advertising or otherwise to promote the sale, use or other dealings 2321e67964Smrgin this Software without prior written authorization from the author. 2421e67964Smrg 2521e67964Smrg*/ 2621e67964Smrg 2721e67964Smrg/*********************************************************************** 2821e67964Smrg * XListDeviceProperties - List an input device's properties. 2921e67964Smrg */ 3021e67964Smrg 3121e67964Smrg 3221e67964Smrg#ifdef HAVE_CONFIG_H 3321e67964Smrg#include <config.h> 3421e67964Smrg#endif 3521e67964Smrg 3621e67964Smrg#include <X11/Xlibint.h> 3721e67964Smrg#include <X11/extensions/XI.h> 3821e67964Smrg#include <X11/extensions/XIproto.h> 3921e67964Smrg#include <X11/extensions/XInput.h> 4021e67964Smrg#include <X11/extensions/extutil.h> 4121e67964Smrg#include "XIint.h" 4221e67964Smrg 4321e67964SmrgAtom* 4421e67964SmrgXListDeviceProperties(Display* dpy, XDevice* dev, int *nprops_return) 4521e67964Smrg{ 4621e67964Smrg xListDevicePropertiesReq *req; 4721e67964Smrg xListDevicePropertiesReply rep; 4821e67964Smrg XExtDisplayInfo *info = XInput_find_display(dpy); 4921e67964Smrg Atom *props = NULL; 5021e67964Smrg 5121e67964Smrg LockDisplay(dpy); 5221e67964Smrg *nprops_return = 0; 5321e67964Smrg if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) 5444584a44Smrg return NULL; 5521e67964Smrg 5621e67964Smrg GetReq(ListDeviceProperties, req); 5721e67964Smrg req->reqType = info->codes->major_opcode; 5821e67964Smrg req->ReqType = X_ListDeviceProperties; 5921e67964Smrg req->deviceid = dev->device_id; 6021e67964Smrg 6121e67964Smrg if (!_XReply(dpy, (xReply*)&rep, 0, xFalse)) 6221e67964Smrg goto cleanup; 6321e67964Smrg 6421e67964Smrg if (rep.nAtoms) { 6521e67964Smrg props = (Atom*)Xmalloc(rep.nAtoms * sizeof(Atom)); 6621e67964Smrg if (!props) 6721e67964Smrg { 6806c34b88Smrg _XEatDataWords(dpy, rep.length); 6921e67964Smrg goto cleanup; 7021e67964Smrg } 7121e67964Smrg 72f1ee322dSmrg _XRead32(dpy, (long*)props, rep.nAtoms << 2); 7321e67964Smrg } 7421e67964Smrg 7521e67964Smrg *nprops_return = rep.nAtoms; 7621e67964Smrg 7721e67964Smrgcleanup: 7821e67964Smrg UnlockDisplay(dpy); 7921e67964Smrg SyncHandle(); 8021e67964Smrg return props; 8121e67964Smrg} 8221e67964Smrg 83