1352N/A# Copyright (c) 2013, Oracle
and/or its affiliates. All rights reserved.
1352N/A- * Copyright (c) 2004-2005, 2008-2010, Oracle
and/or its affiliates.
1352N/A+ * Copyright (c) 2004, 2013, Oracle
and/or its affiliates. All rights reserved.
1352N/A * Permission is hereby granted, free of charge, to any person obtaining a
1352N/A * copy of this software and associated documentation files (the "Software"),
1352N/A /* Support for scaling absolute coordinates to screen size in
1352N/A * Solaris 10 updates and beyond */
1352N/A #if !defined(HAVE_ABSOLUTE_MOUSE_SCALING)
1352N/A Ms_screen_resolution absres;
1352N/A OsTimerPtr remove_timer; /* Callback for removal on ENODEV */
1352N/A static VuidMsePtr vuidMouseList = NULL;
1352N/A static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse);
1352N/A static void vuidMouseAdjustFrame(ADJUST_FRAME_ARGS_DECL);
1352N/A+static int CheckRelToAbs(InputInfoPtr pInfo);
1352N/A+static int CheckRelToAbsWalker(di_node_t node, void *arg);
1352N/A static int vuidMouseGeneration = 0;
1352N/A pVuidMse->buffer = (unsigned char *)&pVuidMse->event;
1352N/A pVuidMse->strmod = xf86SetStrOption(pInfo->options, "StreamsModule", NULL);
1352N/A+ pVuidMse->relToAbs = xf86SetIntOption(pInfo->options, "RelToAbs", -1);
1352N/A+ if (pVuidMse->relToAbs == -1)
1352N/A+ pVuidMse->relToAbs = CheckRelToAbs(pInfo);
1352N/A /* Setup the local procs. */
1352N/A pVuidMse->wrapped_device_control = pInfo->device_control;
1352N/A+ * It seems that the mouse that is presented by the Emulex ILOM
1352N/A+ * device (USB 0x430, 0xa101 and USB 0x430, 0xa102) sends relative
1352N/A+ * mouse movements. But relative mouse movements are subject to
1352N/A+ * acceleration. This causes the position indicated on the ILOM
1352N/A+ * window to not match what the Xorg server actually has. This
1352N/A+ * makes the mouse in this environment rather unusable. So, for the
1352N/A+ * Emulex ILOM device, we will change all relative mouse movements
1352N/A+ * into absolute mouse movements, making it appear more like a
1352N/A+ * tablet. This will not be subject to acceleration, and this
1352N/A+ * should keep the ILOM window and Xorg server with the same values
1352N/A+ * for the coordinates of the mouse.
1352N/A+typedef struct reltoabs_match {
1352N/A+/* Sun Microsystems, keyboard / mouse */
1352N/A+/* Sun Microsystems, keyboard / mouse / storage */
1352N/A+CheckRelToAbsWalker(di_node_t node, void *arg)
1352N/A+ reltoabs_match_t *const matchptr = (reltoabs_match_t *)arg;
1352N/A+ for (minor = di_minor_next(node, DI_MINOR_NIL);
1352N/A+ minor = di_minor_next(node, minor)) {
1352N/A+ path = di_devfs_minor_path(minor);
1352N/A+ status = path != NULL && strcmp(path, matchptr -> matchname) == 0;
1352N/A+ if (minor == DI_MINOR_NIL)
1352N/A+ return (DI_WALK_CONTINUE);
1352N/A+ numvalues = di_prop_lookup_strings(DDI_DEV_T_ANY, node,
1352N/A+ "compatible", &stringvalues);
1352N/A+ return (DI_WALK_CONTINUE);
1352N/A+ for (valueon = 0, stringptr = stringvalues; valueon < numvalues;
1352N/A+ valueon++, stringptr += strlen(stringptr) + 1) {
1352N/A+ if (strcmp(stringptr, RELTOABS_MATCH1) == 0) {
1352N/A+ return (DI_WALK_TERMINATE);
1352N/A+ if (strcmp(stringptr, RELTOABS_MATCH2) == 0) {
1352N/A+ return (DI_WALK_TERMINATE);
1352N/A+ return (DI_WALK_CONTINUE);
1352N/A+CheckRelToAbs(InputInfoPtr pInfo)
1352N/A+ reltoabs_match_t reltoabs_match;
1352N/A+ device = xf86CheckStrOption(pInfo->options, "Device", NULL);
1352N/A+ if (lstat(device, &statbuf) == 0 &&
1352N/A+ readstatus = readlink(device, linkname, sizeof(linkname));
1352N/A+ if (readstatus > 0 && readstatus < sizeof(linkname)) {
1352N/A+ if (strncmp(matchname, "../..", sizeof("../..") - 1) == 0)
1352N/A+ matchname += sizeof("../..") - 1;
1352N/A+ if (strncmp(matchname, "/devices", sizeof("/devices") - 1) == 0)
1352N/A+ matchname += sizeof("/devices") - 1;
1352N/A+ node = di_init("/", DINFOCPYALL);
1352N/A+ di_walk_node(node, DI_WALK_CLDFIRST, (void *)&reltoabs_match,
1352N/A vuidFlushAbsEvents(InputInfoPtr pInfo, int absX, int absY,
1352N/A Bool *absXset, Bool *absYset)
1352N/A vuidReadInput(InputInfoPtr pInfo)
1352N/A+ MouseDevPtr pMse = pInfo->private;
1352N/A+ VuidMsePtr pVuidMse = getVuidMsePriv(pInfo);
1352N/A+ int buttons = pMse->lastButtons;
1352N/A int dx = 0, dy = 0, dz = 0, dw = 0;
1352N/A+ unsigned char *pBuf = pVuidMse->buffer;
1352N/A+ int hdisplay = 0, vdisplay = 0;
1352N/A Bool absXset = FALSE, absYset = FALSE;
1352N/A+ int relToAbs = pVuidMse->relToAbs;
1352N/A- pVuidMse = getVuidMsePriv(pInfo);
1352N/A- buttons = pMse->lastButtons;
1352N/A+ ScreenPtr pScreen = miPointerGetScreen(pInfo->dev);
1352N/A+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
1352N/A+ hdisplay = pScr->currentMode->HDisplay;
1352N/A+ vdisplay = pScr->currentMode->VDisplay;
1352N/A n = read(pInfo->fd, pBuf, sizeof(Firm_event));
1352N/A+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
1352N/A+ else if (absX >= hdisplay && hdisplay > 0)
1352N/A+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
1352N/A+ else if (absY >= vdisplay && vdisplay > 0)