X11 Recognize source device of event





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I have a specific problem - I would like to recognize source device of input events in my program.
Let's assume, that I have two identical touchscreens attached to usb ports. My program is grabbing XButtonPressedEvent, XButtonReleaseEvent etc. but I would like to behave differently between events generated by first device and events generated by second device. I would like to match any of event fields to devices descriptor, devices xinput id, devices system id, or anything else identifying device.



Is it possible to implement?



If so I would appreciate any hints of how to do this.



Best Regards, PG!










share|improve this question























  • What is displayed on the screens? If they are not mirrored, wouldn't you be able to tell them apart by the coordinates? Please explain the setup and what you want to achieve in more detail.

    – danzel
    Apr 3 at 14:58











  • To be more precisely I would like to modify xinput_calibrator that would give me as an output calibration matrix and identifier of device for many identical touchscreens. The assumptions are, that touchscreens are completely decalibrated, so recognition based on coordinates is not a solution.

    – Piotr Golda
    Apr 4 at 8:14




















1















I have a specific problem - I would like to recognize source device of input events in my program.
Let's assume, that I have two identical touchscreens attached to usb ports. My program is grabbing XButtonPressedEvent, XButtonReleaseEvent etc. but I would like to behave differently between events generated by first device and events generated by second device. I would like to match any of event fields to devices descriptor, devices xinput id, devices system id, or anything else identifying device.



Is it possible to implement?



If so I would appreciate any hints of how to do this.



Best Regards, PG!










share|improve this question























  • What is displayed on the screens? If they are not mirrored, wouldn't you be able to tell them apart by the coordinates? Please explain the setup and what you want to achieve in more detail.

    – danzel
    Apr 3 at 14:58











  • To be more precisely I would like to modify xinput_calibrator that would give me as an output calibration matrix and identifier of device for many identical touchscreens. The assumptions are, that touchscreens are completely decalibrated, so recognition based on coordinates is not a solution.

    – Piotr Golda
    Apr 4 at 8:14
















1












1








1








I have a specific problem - I would like to recognize source device of input events in my program.
Let's assume, that I have two identical touchscreens attached to usb ports. My program is grabbing XButtonPressedEvent, XButtonReleaseEvent etc. but I would like to behave differently between events generated by first device and events generated by second device. I would like to match any of event fields to devices descriptor, devices xinput id, devices system id, or anything else identifying device.



Is it possible to implement?



If so I would appreciate any hints of how to do this.



Best Regards, PG!










share|improve this question














I have a specific problem - I would like to recognize source device of input events in my program.
Let's assume, that I have two identical touchscreens attached to usb ports. My program is grabbing XButtonPressedEvent, XButtonReleaseEvent etc. but I would like to behave differently between events generated by first device and events generated by second device. I would like to match any of event fields to devices descriptor, devices xinput id, devices system id, or anything else identifying device.



Is it possible to implement?



If so I would appreciate any hints of how to do this.



Best Regards, PG!







xorg input-devices events






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 3 at 13:57









Piotr GoldaPiotr Golda

61




61













  • What is displayed on the screens? If they are not mirrored, wouldn't you be able to tell them apart by the coordinates? Please explain the setup and what you want to achieve in more detail.

    – danzel
    Apr 3 at 14:58











  • To be more precisely I would like to modify xinput_calibrator that would give me as an output calibration matrix and identifier of device for many identical touchscreens. The assumptions are, that touchscreens are completely decalibrated, so recognition based on coordinates is not a solution.

    – Piotr Golda
    Apr 4 at 8:14





















  • What is displayed on the screens? If they are not mirrored, wouldn't you be able to tell them apart by the coordinates? Please explain the setup and what you want to achieve in more detail.

    – danzel
    Apr 3 at 14:58











  • To be more precisely I would like to modify xinput_calibrator that would give me as an output calibration matrix and identifier of device for many identical touchscreens. The assumptions are, that touchscreens are completely decalibrated, so recognition based on coordinates is not a solution.

    – Piotr Golda
    Apr 4 at 8:14



















What is displayed on the screens? If they are not mirrored, wouldn't you be able to tell them apart by the coordinates? Please explain the setup and what you want to achieve in more detail.

– danzel
Apr 3 at 14:58





What is displayed on the screens? If they are not mirrored, wouldn't you be able to tell them apart by the coordinates? Please explain the setup and what you want to achieve in more detail.

– danzel
Apr 3 at 14:58













To be more precisely I would like to modify xinput_calibrator that would give me as an output calibration matrix and identifier of device for many identical touchscreens. The assumptions are, that touchscreens are completely decalibrated, so recognition based on coordinates is not a solution.

– Piotr Golda
Apr 4 at 8:14







To be more precisely I would like to modify xinput_calibrator that would give me as an output calibration matrix and identifier of device for many identical touchscreens. The assumptions are, that touchscreens are completely decalibrated, so recognition based on coordinates is not a solution.

– Piotr Golda
Apr 4 at 8:14












1 Answer
1






active

oldest

votes


















0














It seems that this is not supported with the old XInput extension. You'll need to use XInput2 which reports the device id for each button press. The original author posted a series on his blog explaining some important aspects (part1,part2,part3) and a few complete code examples are available here. Since the xinput command line utility supports both extensions, you can look at its source code, especially test_xi2.c, to get an idea how to use XInput2.



xinput_calibrator uses the old XInput version (see here). While you could try using XInput2 in parallel, YMMV because there are certain limitations regarding interoperability of the two versions as described here.



However, since xinput_calibrator is known to do poor calculation of the transformation matrix, someone wrote a small python3 script (xcal) to calibrate touch screens. It is a lot simpler than xinput_calibrator and thus may be easier to adapt to your needs. Additonally, the python3-xlib library (available in ubuntu's repositories) does use XInput2 by default (if it is available), and therefore each button press event will contain the source device id.






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1130940%2fx11-recognize-source-device-of-event%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It seems that this is not supported with the old XInput extension. You'll need to use XInput2 which reports the device id for each button press. The original author posted a series on his blog explaining some important aspects (part1,part2,part3) and a few complete code examples are available here. Since the xinput command line utility supports both extensions, you can look at its source code, especially test_xi2.c, to get an idea how to use XInput2.



    xinput_calibrator uses the old XInput version (see here). While you could try using XInput2 in parallel, YMMV because there are certain limitations regarding interoperability of the two versions as described here.



    However, since xinput_calibrator is known to do poor calculation of the transformation matrix, someone wrote a small python3 script (xcal) to calibrate touch screens. It is a lot simpler than xinput_calibrator and thus may be easier to adapt to your needs. Additonally, the python3-xlib library (available in ubuntu's repositories) does use XInput2 by default (if it is available), and therefore each button press event will contain the source device id.






    share|improve this answer




























      0














      It seems that this is not supported with the old XInput extension. You'll need to use XInput2 which reports the device id for each button press. The original author posted a series on his blog explaining some important aspects (part1,part2,part3) and a few complete code examples are available here. Since the xinput command line utility supports both extensions, you can look at its source code, especially test_xi2.c, to get an idea how to use XInput2.



      xinput_calibrator uses the old XInput version (see here). While you could try using XInput2 in parallel, YMMV because there are certain limitations regarding interoperability of the two versions as described here.



      However, since xinput_calibrator is known to do poor calculation of the transformation matrix, someone wrote a small python3 script (xcal) to calibrate touch screens. It is a lot simpler than xinput_calibrator and thus may be easier to adapt to your needs. Additonally, the python3-xlib library (available in ubuntu's repositories) does use XInput2 by default (if it is available), and therefore each button press event will contain the source device id.






      share|improve this answer


























        0












        0








        0







        It seems that this is not supported with the old XInput extension. You'll need to use XInput2 which reports the device id for each button press. The original author posted a series on his blog explaining some important aspects (part1,part2,part3) and a few complete code examples are available here. Since the xinput command line utility supports both extensions, you can look at its source code, especially test_xi2.c, to get an idea how to use XInput2.



        xinput_calibrator uses the old XInput version (see here). While you could try using XInput2 in parallel, YMMV because there are certain limitations regarding interoperability of the two versions as described here.



        However, since xinput_calibrator is known to do poor calculation of the transformation matrix, someone wrote a small python3 script (xcal) to calibrate touch screens. It is a lot simpler than xinput_calibrator and thus may be easier to adapt to your needs. Additonally, the python3-xlib library (available in ubuntu's repositories) does use XInput2 by default (if it is available), and therefore each button press event will contain the source device id.






        share|improve this answer













        It seems that this is not supported with the old XInput extension. You'll need to use XInput2 which reports the device id for each button press. The original author posted a series on his blog explaining some important aspects (part1,part2,part3) and a few complete code examples are available here. Since the xinput command line utility supports both extensions, you can look at its source code, especially test_xi2.c, to get an idea how to use XInput2.



        xinput_calibrator uses the old XInput version (see here). While you could try using XInput2 in parallel, YMMV because there are certain limitations regarding interoperability of the two versions as described here.



        However, since xinput_calibrator is known to do poor calculation of the transformation matrix, someone wrote a small python3 script (xcal) to calibrate touch screens. It is a lot simpler than xinput_calibrator and thus may be easier to adapt to your needs. Additonally, the python3-xlib library (available in ubuntu's repositories) does use XInput2 by default (if it is available), and therefore each button press event will contain the source device id.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 9 at 9:55









        danzeldanzel

        2,200717




        2,200717






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1130940%2fx11-recognize-source-device-of-event%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            數位音樂下載

            When can things happen in Etherscan, such as the picture below?

            格利澤436b