| @@ -350,26 +350,42 @@ xf86EloReadInput(InputInfoPtr pInfo) | | | @@ -350,26 +350,42 @@ xf86EloReadInput(InputInfoPtr pInfo) |
350 | continue; | | 350 | continue; |
351 | | | 351 | |
352 | /* | | 352 | /* |
353 | * Process only ELO_TOUCHs here. | | 353 | * Process only ELO_TOUCHs here. |
354 | */ | | 354 | */ |
355 | if (priv->packet_buf[1] == ELO_TOUCH) { | | 355 | if (priv->packet_buf[1] == ELO_TOUCH) { |
356 | /* | | 356 | /* |
357 | * First stick together the various pieces. | | 357 | * First stick together the various pieces. |
358 | */ | | 358 | */ |
359 | cur_x = WORD_ASSEMBLY(priv->packet_buf[3], priv->packet_buf[4]); | | 359 | cur_x = WORD_ASSEMBLY(priv->packet_buf[3], priv->packet_buf[4]); |
360 | cur_y = WORD_ASSEMBLY(priv->packet_buf[5], priv->packet_buf[6]); | | 360 | cur_y = WORD_ASSEMBLY(priv->packet_buf[5], priv->packet_buf[6]); |
361 | state = priv->packet_buf[2] & 0x07; | | 361 | state = priv->packet_buf[2] & 0x07; |
362 | | | 362 | |
| | | 363 | DBG(5, ErrorF("ELO got: x(%d), y(%d), %s\n", |
| | | 364 | cur_x, cur_y, |
| | | 365 | (state == ELO_PRESS) ? "Press" : |
| | | 366 | ((state == ELO_RELEASE) ? "Release" : "Stream"))); |
| | | 367 | |
| | | 368 | if (priv->min_y > priv->max_y) { |
| | | 369 | /* inverted y axis */ |
| | | 370 | cur_y = priv->max_y - cur_y + priv->min_y; |
| | | 371 | } |
| | | 372 | |
| | | 373 | if (priv->min_x > priv->max_x) { |
| | | 374 | /* inverted x axis */ |
| | | 375 | cur_x = priv->max_x - cur_x + priv->min_x; |
| | | 376 | } |
| | | 377 | |
| | | 378 | |
363 | /* | | 379 | /* |
364 | * Send events. | | 380 | * Send events. |
365 | * | | 381 | * |
366 | * We *must* generate a motion before a button change if pointer | | 382 | * We *must* generate a motion before a button change if pointer |
367 | * location has changed as DIX assumes this. This is why we always | | 383 | * location has changed as DIX assumes this. This is why we always |
368 | * emit a motion, regardless of the kind of packet processed. | | 384 | * emit a motion, regardless of the kind of packet processed. |
369 | */ | | 385 | */ |
370 | xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, cur_x, cur_y); | | 386 | xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, cur_x, cur_y); |
371 | | | 387 | |
372 | /* | | 388 | /* |
373 | * Emit a button press or release. | | 389 | * Emit a button press or release. |
374 | */ | | 390 | */ |
375 | if (state == ELO_PRESS || state == ELO_RELEASE) { | | 391 | if (state == ELO_PRESS || state == ELO_RELEASE) { |
| @@ -666,26 +682,27 @@ xf86EloPtrControl(DeviceIntPtr dev, | | | @@ -666,26 +682,27 @@ xf86EloPtrControl(DeviceIntPtr dev, |
666 | *************************************************************************** | | 682 | *************************************************************************** |
667 | */ | | 683 | */ |
668 | static Bool | | 684 | static Bool |
669 | xf86EloControl(DeviceIntPtr dev, | | 685 | xf86EloControl(DeviceIntPtr dev, |
670 | int mode) | | 686 | int mode) |
671 | { | | 687 | { |
672 | InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate; | | 688 | InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate; |
673 | EloPrivatePtr priv = (EloPrivatePtr)(pInfo->private); | | 689 | EloPrivatePtr priv = (EloPrivatePtr)(pInfo->private); |
674 | unsigned char map[] = { 0, 1 }; | | 690 | unsigned char map[] = { 0, 1 }; |
675 | unsigned char req[ELO_PACKET_SIZE]; | | 691 | unsigned char req[ELO_PACKET_SIZE]; |
676 | unsigned char reply[ELO_PACKET_SIZE]; | | 692 | unsigned char reply[ELO_PACKET_SIZE]; |
677 | Atom btn_label; | | 693 | Atom btn_label; |
678 | Atom axis_labels[2] = { 0, 0 }; | | 694 | Atom axis_labels[2] = { 0, 0 }; |
| | | 695 | int x0, x1, y0, y1; |
679 | | | 696 | |
680 | switch(mode) { | | 697 | switch(mode) { |
681 | | | 698 | |
682 | case DEVICE_INIT: | | 699 | case DEVICE_INIT: |
683 | { | | 700 | { |
684 | DBG(2, ErrorF("Elographics touchscreen init...\n")); | | 701 | DBG(2, ErrorF("Elographics touchscreen init...\n")); |
685 | | | 702 | |
686 | if (priv->screen_no >= screenInfo.numScreens || | | 703 | if (priv->screen_no >= screenInfo.numScreens || |
687 | priv->screen_no < 0) { | | 704 | priv->screen_no < 0) { |
688 | priv->screen_no = 0; | | 705 | priv->screen_no = 0; |
689 | } | | 706 | } |
690 | priv->screen_width = screenInfo.screens[priv->screen_no]->width; | | 707 | priv->screen_width = screenInfo.screens[priv->screen_no]->width; |
691 | priv->screen_height = screenInfo.screens[priv->screen_no]->height; | | 708 | priv->screen_height = screenInfo.screens[priv->screen_no]->height; |
| @@ -709,37 +726,47 @@ xf86EloControl(DeviceIntPtr dev, | | | @@ -709,37 +726,47 @@ xf86EloControl(DeviceIntPtr dev, |
709 | /* | | 726 | /* |
710 | * Device reports motions on 2 axes in absolute coordinates. | | 727 | * Device reports motions on 2 axes in absolute coordinates. |
711 | * Axes min and max values are reported in raw coordinates. | | 728 | * Axes min and max values are reported in raw coordinates. |
712 | * Resolution is computed roughly by the difference between | | 729 | * Resolution is computed roughly by the difference between |
713 | * max and min values scaled from the approximate size of the | | 730 | * max and min values scaled from the approximate size of the |
714 | * screen to fit one meter. | | 731 | * screen to fit one meter. |
715 | */ | | 732 | */ |
716 | if (InitValuatorClassDeviceStruct(dev, 2, axis_labels, | | 733 | if (InitValuatorClassDeviceStruct(dev, 2, axis_labels, |
717 | GetMotionHistorySize(), Absolute) == FALSE) { | | 734 | GetMotionHistorySize(), Absolute) == FALSE) { |
718 | ErrorF("Unable to allocate Elographics touchscreen ValuatorClassDeviceStruct\n"); | | 735 | ErrorF("Unable to allocate Elographics touchscreen ValuatorClassDeviceStruct\n"); |
719 | return !Success; | | 736 | return !Success; |
720 | } | | 737 | } |
721 | else { | | 738 | else { |
| | | 739 | |
| | | 740 | /* Correct the coordinates for possibly inverted axis. |
| | | 741 | Leave priv->variables untouched so we can check for |
| | | 742 | inversion on incoming events. |
| | | 743 | */ |
| | | 744 | y0 = min(priv->min_y, priv->max_y); |
| | | 745 | y1 = max(priv->min_y, priv->max_y); |
| | | 746 | x0 = min(priv->min_x, priv->max_x); |
| | | 747 | x1 = max(priv->min_x, priv->max_x); |
| | | 748 | |
722 | /* I will map coordinates myself */ | | 749 | /* I will map coordinates myself */ |
723 | InitValuatorAxisStruct(dev, 0, | | 750 | InitValuatorAxisStruct(dev, 0, |
724 | axis_labels[0], | | 751 | axis_labels[0], |
725 | priv->min_x, priv->max_x, | | 752 | x0, x1, |
726 | 9500, | | 753 | 9500, |
727 | 0 /* min_res */, | | 754 | 0 /* min_res */, |
728 | 9500 /* max_res */, | | 755 | 9500 /* max_res */, |
729 | Absolute); | | 756 | Absolute); |
730 | InitValuatorAxisStruct(dev, 1, | | 757 | InitValuatorAxisStruct(dev, 1, |
731 | axis_labels[1], | | 758 | axis_labels[1], |
732 | priv->min_y, priv->max_y, | | 759 | y0, y1, |
733 | 10500, | | 760 | 10500, |
734 | 0 /* min_res */, | | 761 | 0 /* min_res */, |
735 | 10500 /* max_res */, | | 762 | 10500 /* max_res */, |
736 | Absolute); | | 763 | Absolute); |
737 | } | | 764 | } |
738 | | | 765 | |
739 | if (InitFocusClassDeviceStruct(dev) == FALSE) { | | 766 | if (InitFocusClassDeviceStruct(dev) == FALSE) { |
740 | ErrorF("Unable to allocate Elographics touchscreen FocusClassDeviceStruct\n"); | | 767 | ErrorF("Unable to allocate Elographics touchscreen FocusClassDeviceStruct\n"); |
741 | } | | 768 | } |
742 | | | 769 | |
743 | /* | | 770 | /* |
744 | * Allocate the motion events buffer. | | 771 | * Allocate the motion events buffer. |
745 | */ | | 772 | */ |
| @@ -838,26 +865,31 @@ xf86EloControl(DeviceIntPtr dev, | | | @@ -838,26 +865,31 @@ xf86EloControl(DeviceIntPtr dev, |
838 | * Close the port and free all the resources. | | 865 | * Close the port and free all the resources. |
839 | */ | | 866 | */ |
840 | case DEVICE_CLOSE: | | 867 | case DEVICE_CLOSE: |
841 | DBG(2, ErrorF("Elographics touchscreen close...\n")); | | 868 | DBG(2, ErrorF("Elographics touchscreen close...\n")); |
842 | dev->public.on = FALSE; | | 869 | dev->public.on = FALSE; |
843 | if (pInfo->fd >= 0) { | | 870 | if (pInfo->fd >= 0) { |
844 | xf86RemoveEnabledDevice(pInfo); | | 871 | xf86RemoveEnabledDevice(pInfo); |
845 | } | | 872 | } |
846 | SYSCALL(close(pInfo->fd)); | | 873 | SYSCALL(close(pInfo->fd)); |
847 | pInfo->fd = -1; | | 874 | pInfo->fd = -1; |
848 | DBG(2, ErrorF("Done\n")); | | 875 | DBG(2, ErrorF("Done\n")); |
849 | return Success; | | 876 | return Success; |
850 | | | 877 | |
| | | 878 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) * 100 + GET_ABI_MINOR(ABI_XINPUT_VERSION) >= 1901 |
| | | 879 | case DEVICE_ABORT: |
| | | 880 | return Success; |
| | | 881 | #endif |
| | | 882 | |
851 | default: | | 883 | default: |
852 | ErrorF("unsupported mode=%d\n", mode); | | 884 | ErrorF("unsupported mode=%d\n", mode); |
853 | return BadValue; | | 885 | return BadValue; |
854 | } | | 886 | } |
855 | } | | 887 | } |
856 | | | 888 | |
857 | /* | | 889 | /* |
858 | *************************************************************************** | | 890 | *************************************************************************** |
859 | * | | 891 | * |
860 | * xf86EloAllocate -- | | 892 | * xf86EloAllocate -- |
861 | * | | 893 | * |
862 | *************************************************************************** | | 894 | *************************************************************************** |
863 | */ | | 895 | */ |