Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble with touchscreen coordinate offset on Windows #996

Open
vitoo opened this issue Nov 3, 2023 · 3 comments
Open

Trouble with touchscreen coordinate offset on Windows #996

vitoo opened this issue Nov 3, 2023 · 3 comments

Comments

@vitoo
Copy link

vitoo commented Nov 3, 2023

Hello,

It's not a bug, i just need help to understand what i am doing wrong.
i use a home made web browser spice client to connect to KVM (version 7) virtual machine
I send touchscreen coordinate (mono or multi touch depending on the device i use) with virtio_input_send to a virtio-touchscreen-pci device present on the machine

On windows 10, i installed the virtio driver version : virtio-win-0.1.229 (found on fedora)
I can see the "touchscreen device" (ecran tactile in french) in windows devices :

image

Here is the coordinate gap that happen :

touchscreen_offset.online-video-cutter.com.mp4

How i send the coordinate to the driver :

static void _mts_touch_down(MTSState* mts_state , int tracking_id , int x , int y , int pressure) {
    /* Get first available slot for the new pointer. */
    const int slot_index = _get_available_touch_index();

    /* Make sure there is a place for the pointer. */
    if (slot_index >= 0) {
        /* Initialize pointer's entry. */
        mts_state->tracked_ptr_num++;
        mts_state->tracked_touches[slot_index].tracking_id = tracking_id;
        mts_state->tracked_touches[slot_index].x = x;
        mts_state->tracked_touches[slot_index].y = y;
        mts_state->tracked_touches[slot_index].pressure = pressure;

        if (slot_index != mts_state->current_slot) {
            mt_virtio_input_send(EV_ABS , LINUX_ABS_MT_SLOT , slot_index);
            mts_state->current_slot = slot_index;
        }
        mt_virtio_input_send(EV_ABS , LINUX_ABS_MT_TRACKING_ID , slot_index);
        mt_virtio_input_send(EV_ABS , LINUX_ABS_MT_POSITION_X , x);
        mt_virtio_input_send(EV_ABS , LINUX_ABS_MT_POSITION_Y , y);
        mt_virtio_input_send(EV_ABS , LINUX_ABS_MT_TOOL_TYPE , MT_TOOL_FINGER);
        mt_virtio_input_send(EV_ABS , LINUX_ABS_MT_PRESSURE , pressure);
        mt_virtio_input_send(EV_ABS , LINUX_ABS_MT_ORIENTATION , 0);
        mt_virtio_input_send(EV_ABS , LINUX_ABS_MT_TOUCH_MAJOR , MTS_TOUCH_AXIS_DEFAULT);
        mt_virtio_input_send(EV_ABS , LINUX_ABS_MT_TOUCH_MINOR , MTS_TOUCH_AXIS_DEFAULT);
    }
    else {
        // DEBUG_INFO("MTS touch count is exceeded.");
        return;
    }
}
/* ----------------------------------------------------------------- */
// Send VirtIO input atomic events
/* ----------------------------------------------------------------- */
int mt_virtio_input_send(unsigned short type , unsigned short code , unsigned int value) {
    if (type != EV_ABS && type != EV_KEY && type != EV_SYN && type != EV_SW) {
        return 0;
    }

    // DEBUG_INFO("android_virtio_input_send: pointer %d active %d",(int)(s_virtio_input_multi_touch!=NULL),s_virtio_input_multi_touch->active);
    if (s_virtio_input_multi_touch) {
        virtio_input_event event;
        event.type = type;
        event.code = code;
        event.value = value;
        // DEBUG_INFO("android_virtio_input_send: type = %d, code = %d, value = %d" , type , code , value);
        virtio_input_send(s_virtio_input_multi_touch , &event);
    }
    return 1;
}

The coordinate were correct on qemu version 5, but only in resolution 720p or under, on qemu 7 there is this offset issue in every resolution

If you have any idea of what i am doing wrong, maybe you can help me
Can i find driver logs somewhere? maybe i can add log to the driver and build it ?
Thanks a lot !

@YanVugenfirer
Copy link
Collaborator

@kostyanf14 @ybendito - guys, do you know how to help?

@vitoo
Copy link
Author

vitoo commented Nov 28, 2023

@ivellioscolin maybe you have an idea ? As you worked on the multi-touch

thanks

@ivellioscolin
Copy link
Contributor

@ivellioscolin maybe you have an idea ? As you worked on the multi-touch

thanks

There're several places you may want to check:

  • What's returned from GetAbsAxisInfo.
  • logical/physical min/max, unit, unit exponent on linux host side, if you operate the touch on host.
  • If DPI scaling not 100% on you Windows, how you app handles DPI?
  • Also you could debug in this way:
    • Set same resolution on host (as you did in the guest), move your touch finger to certain place (like bottom, right), see how the descriptor reported.
    • Do the same in guest.
    • Compare the value with the reported to Windows, see if can find any clue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants