View | Details | Raw Unified | Return to bug 144682
Collapse All | Expand All

(-)src/mouse.c (-28 / +69 lines)
Lines 543-560 MouseCommonOptions(InputInfoPtr pInfo) Link Here
543
	xfree(s);
543
	xfree(s);
544
    }
544
    }
545
545
546
    s = xf86SetStrOption(pInfo->options, "ZAxisMapping", "4 5 6 7");
546
    s = xf86SetStrOption(pInfo->options, "ZAxisMapping", "4 5");
547
    if (s) {
547
    if (s) {
548
	int b1 = 0, b2 = 0, b3 = 0, b4 = 0;
548
	int b1 = 0, b2 = 0, b3 = 0, b4 = 0;
549
	char *msg = NULL;
549
	char *msg = NULL;
550
550
551
	pMse->negativeZ = pMse->positiveZ = MSE_NOAXISMAP;
552
	pMse->negativeW = pMse->positiveW = MSE_NOAXISMAP;
551
	if (!xf86NameCmp(s, "x")) {
553
	if (!xf86NameCmp(s, "x")) {
552
	    pMse->negativeZ = pMse->positiveZ = MSE_MAPTOX;
554
	    pMse->negativeZ = pMse->positiveZ = MSE_MAPTOX;
553
	    pMse->negativeW = pMse->positiveW = MSE_MAPTOX;
554
	    msg = xstrdup("X axis");
555
	    msg = xstrdup("X axis");
555
	} else if (!xf86NameCmp(s, "y")) {
556
	} else if (!xf86NameCmp(s, "y")) {
556
	    pMse->negativeZ = pMse->positiveZ = MSE_MAPTOY;
557
	    pMse->negativeZ = pMse->positiveZ = MSE_MAPTOY;
557
	    pMse->negativeW = pMse->positiveW = MSE_MAPTOY;
558
	    msg = xstrdup("Y axis");
558
	    msg = xstrdup("Y axis");
559
	} else if (sscanf(s, "%d %d %d %d", &b1, &b2, &b3, &b4) >= 2 &&
559
	} else if (sscanf(s, "%d %d %d %d", &b1, &b2, &b3, &b4) >= 2 &&
560
		 b1 > 0 && b1 <= MSE_MAXBUTTONS &&
560
		 b1 > 0 && b1 <= MSE_MAXBUTTONS &&
Lines 562-569 MouseCommonOptions(InputInfoPtr pInfo) Link Here
562
	    msg = xstrdup("buttons XX and YY");
562
	    msg = xstrdup("buttons XX and YY");
563
	    if (msg)
563
	    if (msg)
564
		sprintf(msg, "buttons %d and %d", b1, b2);
564
		sprintf(msg, "buttons %d and %d", b1, b2);
565
	    pMse->negativeZ = pMse->negativeW = 1 << (b1-1);
565
	    pMse->negativeZ = 1 << (b1-1);
566
	    pMse->positiveZ = pMse->positiveW = 1 << (b2-1);
566
	    pMse->positiveZ = 1 << (b2-1);
567
	    if (b3 > 0 && b3 <= MSE_MAXBUTTONS &&
567
	    if (b3 > 0 && b3 <= MSE_MAXBUTTONS &&
568
		b4 > 0 && b4 <= MSE_MAXBUTTONS) {
568
		b4 > 0 && b4 <= MSE_MAXBUTTONS) {
569
		if (msg)
569
		if (msg)
Lines 578-586 MouseCommonOptions(InputInfoPtr pInfo) Link Here
578
	    if (b2 > pMse->buttons) pMse->buttons = b2;
578
	    if (b2 > pMse->buttons) pMse->buttons = b2;
579
	    if (b3 > pMse->buttons) pMse->buttons = b3;
579
	    if (b3 > pMse->buttons) pMse->buttons = b3;
580
	    if (b4 > pMse->buttons) pMse->buttons = b4;
580
	    if (b4 > pMse->buttons) pMse->buttons = b4;
581
	} else {
582
	    pMse->negativeZ = pMse->positiveZ = MSE_NOZMAP;
583
	    pMse->negativeW = pMse->positiveW = MSE_NOZMAP;
584
	}
581
	}
585
	if (msg) {
582
	if (msg) {
586
	    xf86Msg(X_CONFIG, "%s: ZAxisMapping: %s\n", pInfo->name, msg);
583
	    xf86Msg(X_CONFIG, "%s: ZAxisMapping: %s\n", pInfo->name, msg);
Lines 1506-1512 MouseReadInput(InputInfoPtr pInfo) Link Here
1506
		      (pBuf[3] & 0x20) >> 1;        /* button 5 */
1503
		      (pBuf[3] & 0x20) >> 1;        /* button 5 */
1507
	    dx = (pBuf[0] & 0x10) ?    pBuf[1]-256  :  pBuf[1];
1504
	    dx = (pBuf[0] & 0x10) ?    pBuf[1]-256  :  pBuf[1];
1508
	    dy = (pBuf[0] & 0x20) ?  -(pBuf[2]-256) : -pBuf[2];
1505
	    dy = (pBuf[0] & 0x20) ?  -(pBuf[2]-256) : -pBuf[2];
1509
	    dz = (pBuf[3] & 0x08) ? (pBuf[3] & 0x0f) - 16 : (pBuf[3] & 0x0f);
1506
	    if (pMse->negativeW != MSE_NOAXISMAP) {
1507
		switch (pBuf[3] & 0x0f) {
1508
		case 0x00:          break;
1509
		case 0x01: dz =  1; break;
1510
		case 0x02: dw =  1; break;
1511
		case 0x0e: dw = -1; break;
1512
		case 0x0f: dz = -1; break;
1513
		default:
1514
		    xf86Msg(X_INFO,
1515
			    "Mouse autoprobe: Disabling secondary wheel\n");
1516
		    pMse->negativeW = pMse->positiveW = MSE_NOAXISMAP;
1517
		}
1518
	    }
1519
	    if (pMse->negativeW == MSE_NOAXISMAP)
1520
	        dz = (pBuf[3]&0x08) ? (pBuf[3]&0x0f) - 16 : (pBuf[3]&0x0f);
1510
	    break;
1521
	    break;
1511
1522
1512
	case PROT_MMPS2:	/* MouseMan+ PS/2 */
1523
	case PROT_MMPS2:	/* MouseMan+ PS/2 */
Lines 2332-2338 MousePostEvent(InputInfoPtr pInfo, int t Link Here
2332
	       int dx, int dy, int dz, int dw)
2343
	       int dx, int dy, int dz, int dw)
2333
{
2344
{
2334
    MouseDevPtr pMse;
2345
    MouseDevPtr pMse;
2335
    int zbutton = 0;
2346
    int zbutton = 0, wbutton = 0, zbuttoncount = 0, wbuttoncount = 0;
2336
    int i, b, buttons = 0;
2347
    int i, b, buttons = 0;
2337
2348
2338
    pMse = pInfo->private;
2349
    pMse = pInfo->private;
Lines 2353-2358 MousePostEvent(InputInfoPtr pInfo, int t Link Here
2353
    /* XXX Could this go in the conversion_proc? */
2364
    /* XXX Could this go in the conversion_proc? */
2354
    switch (pMse->negativeZ) {
2365
    switch (pMse->negativeZ) {
2355
    case MSE_NOZMAP:	/* do nothing */
2366
    case MSE_NOZMAP:	/* do nothing */
2367
	dz = 0;
2356
	break;
2368
	break;
2357
    case MSE_MAPTOX:
2369
    case MSE_MAPTOX:
2358
	if (dz != 0) {
2370
	if (dz != 0) {
Lines 2367-2386 MousePostEvent(InputInfoPtr pInfo, int t Link Here
2367
	}
2379
	}
2368
	break;
2380
	break;
2369
    default:	/* buttons */
2381
    default:	/* buttons */
2370
	buttons &= ~(pMse->negativeZ | pMse->positiveZ
2382
	buttons &= ~(pMse->negativeZ | pMse->positiveZ);
2371
		   | pMse->negativeW | pMse->positiveW);
2383
	if (dz < 0) {
2372
	if (dw < 0 || dz < -1)
2373
	    zbutton = pMse->negativeW;
2374
	else if (dz < 0)
2375
	    zbutton = pMse->negativeZ;
2384
	    zbutton = pMse->negativeZ;
2376
	else if (dw > 0 || dz > 1)
2385
	    zbuttoncount = -dz;
2377
	    zbutton = pMse->positiveW;
2386
	} else if (dz > 0) {
2378
	else if (dz > 0)
2379
	    zbutton = pMse->positiveZ;
2387
	    zbutton = pMse->positiveZ;
2380
	buttons |= zbutton;
2388
	    zbuttoncount = dz;
2389
	}
2381
	dz = 0;
2390
	dz = 0;
2382
	break;
2391
	break;
2383
    }
2392
    }
2393
    switch (pMse->negativeW) {
2394
    case MSE_NOZMAP:	/* do nothing */
2395
	dw = 0;
2396
	break;
2397
    case MSE_MAPTOX:
2398
	if (dw != 0) {
2399
	    dx = dw;
2400
	    dw = 0;
2401
	}
2402
	break;
2403
    case MSE_MAPTOY:
2404
	if (dw != 0) {
2405
	    dy = dw;
2406
	    dw = 0;
2407
	}
2408
	break;
2409
    default:	/* buttons */
2410
	buttons &= ~(pMse->negativeW | pMse->positiveW);
2411
	if (dw < 0) {
2412
	    wbutton = pMse->negativeW;
2413
	    wbuttoncount = -dw;
2414
	} else if (dw > 0) {
2415
	    wbutton = pMse->positiveW;
2416
	    wbuttoncount = dw;
2417
	}
2418
	dw = 0;
2419
	break;
2420
    }
2421
2384
2422
2385
    /* Apply angle offset */
2423
    /* Apply angle offset */
2386
    if (pMse->angleOffset != 0) {
2424
    if (pMse->angleOffset != 0) {
Lines 2397-2412 MousePostEvent(InputInfoPtr pInfo, int t Link Here
2397
	dx = dy;
2435
	dx = dy;
2398
	dy = tmp;
2436
	dy = tmp;
2399
    }
2437
    }
2400
    MouseDoPostEvent(pInfo, buttons, dx, dy);
2401
2438
2402
    /*
2439
    /* If mouse wheel movement has to be mapped on a button, we need to
2403
     * If dz has been mapped to a button `down' event, we need to cook up
2440
     * loop for button press and release events. */
2404
     * a corresponding button `up' event.
2441
    do {
2405
     */
2442
        MouseDoPostEvent(pInfo, buttons | zbutton | wbutton, dx, dy);
2406
    if (zbutton) {
2443
	dx = dy = 0;
2407
	buttons &= ~zbutton;
2444
	if (zbutton || wbutton)
2408
	MouseDoPostEvent(pInfo, buttons, 0, 0);
2445
	    MouseDoPostEvent(pInfo, buttons, 0, 0);
2409
    }
2446
	if (--zbuttoncount <= 0)
2447
	    zbutton = 0;
2448
	if (--wbuttoncount <= 0)
2449
	    wbutton = 0;
2450
    } while (zbutton || wbutton);
2410
2451
2411
    pMse->lastButtons = truebuttons;
2452
    pMse->lastButtons = truebuttons;
2412
}
2453
}
(-)man/mouse.man (-2 / +4 lines)
Lines 138-144 emulation mode. Button number Link Here
138
.I N1
138
.I N1
139
is mapped to the negative Y axis motion and button number
139
is mapped to the negative Y axis motion and button number
140
.I N2
140
.I N2
141
is mapped to the positive Y axis motion.  Default: "4 5".
141
is mapped to the positive Y axis motion.  Default: no mapping.
142
.TP 7
142
.TP 7
143
.BI "Option \*qZAxisMapping\*q \*qX\*q"
143
.BI "Option \*qZAxisMapping\*q \*qX\*q"
144
.TP 7
144
.TP 7
Lines 161-167 of the second wheel mapped respectively Link Here
161
.I N3
161
.I N3
162
and
162
and
163
.IR N4 .
163
.IR N4 .
164
Default: "4 5 6 7".
164
Note that the protocols for mice with one and two wheels can be different
165
and the driver may not be able to autodetect it.
166
Default: "4 5".
165
.TP 7
167
.TP 7
166
.BI "Option \*qButtonMapping\*q \*q" "N1 N2 [...]" \*q
168
.BI "Option \*qButtonMapping\*q \*q" "N1 N2 [...]" \*q
167
Specifies how physical mouse buttons are mapped to logical buttons.
169
Specifies how physical mouse buttons are mapped to logical buttons.

Return to bug 144682