bedtime
Posts: 64
Joined: Thu Dec 13, 2018 6:02 pm

Re: [how to] enable long touch as right click

Wed May 08, 2019 12:14 pm

MeneerJansen wrote:
Wed Apr 10, 2019 6:55 pm
The shell script from @bedtime gives the following error on my Raspbian 9.8 Stretch machine in Xfce:

Code: Select all

usage: xinput query-state <device name>
/home/pi/bin/rclk.sh: 30: [: =: unexpected operator
:?:
Sorry about that. Haven't used that script in a long time...

If it's a touchscreen device, you can try replacing the line:

Code: Select all

MOUSE_ID=$(xinput --list | grep -i -m 1 'mouse' | grep -o 'id=[0-9]\+' | grep -o '[0-9]\+')
with

Code: Select all

MOUSE_ID=$(xinput --list | grep -i -m 1 'FT5406' | grep -o 'id=[0-9]\+' | grep -o '[0-9]\+')



C program to find the device of a touchscreen:

printevent.c:

Code: Select all

/*
    gcc -Wall -O3  printevent.c -o printevent 
*/

#include<stdio.h>

__inline void fast_memcpyS(char *str, const char *str2, int start, int len)
{
    for( ;len > -1; )
    {
        str[len + start] = str2[len];
        --len;
    }
}

__inline int fast_memcmp(const char *str, const char *str2, int len)
{
    while(str[len] == str2[len] && --len);

    return len;
}

void get_device() 
{
    char data[120], s[32];
    int ret;
    FILE * const file = fopen( "/proc/bus/input/devices", "r");

    do
        ret = fscanf(file, "%*2s %s %*[^\n]\n", data);
    while(fast_memcmp(data, "Name=\"FT5406", 12) != 0 && ret != EOF);

    fscanf(file, "%*[^\n]\n%*[^\n]\n%*[^\n]\n%*2s %*15s %6s", data);

    fast_memcpyS(s, "/dev/input/", 0, 11);
    fast_memcpyS(s, data, 11, 6);

    puts(s);

    fclose(file);
}

int main() {

    get_device();

    return 0;

}

User avatar
MeneerJansen
Posts: 20
Joined: Sat May 14, 2016 1:51 pm

Re: [how to] enable long touch as right click

Wed May 08, 2019 6:45 pm

Solved it by adding this to /etc/X11/xorg.conf.d/99-calibration.conf:

Code: Select all

   # Right mouse button is long press with pen:
   Option "EmulateThirdButton" "1"
   Option "EmulateThirdButtonTimeout" "750"
   Option "EmulateThirdButtonMoveThreshold" "30"
[edit 16-6-2019] It must be added in the section called "InputClass".
Last edited by MeneerJansen on Sun Jun 16, 2019 2:54 pm, edited 1 time in total.

Asymic
Posts: 1
Joined: Sun Jun 16, 2019 8:28 am

Re: [how to] enable long touch as right click

Sun Jun 16, 2019 8:39 am

Please can someone expand on the last post, quoting "solved it".

Is this all I have to do to get a long touch on Jessie?

I am quite new to Pi. The line "Solved it by adding this to /etc/X11/xorg.conf.d/99-calibration.conf: " is a little confusing to me.

I take it that this is the path:- "/etc/X11/xorg.conf.d/" and this is a file name:- "99-calibration.conf"

If that is the case, and this is a new file, How does Pi know to read it?

Thank you.

User avatar
MeneerJansen
Posts: 20
Joined: Sat May 14, 2016 1:51 pm

Re: [how to] enable long touch as right click

Sun Jun 16, 2019 2:50 pm

Asymic wrote:
Sun Jun 16, 2019 8:39 am
Please can someone expand on the last post, quoting "solved it".

Is this all I have to do to get a long touch on Jessie?

I am quite new to Pi. The line "Solved it by adding this to /etc/X11/xorg.conf.d/99-calibration.conf: " is a little confusing to me.

I take it that this is the path:- "/etc/X11/xorg.conf.d/" and this is a file name:- "99-calibration.conf"

If that is the case, and this is a new file, How does Pi know to read it?

Thank you.
I think that my "method" only works in Raspbian 9 "Stretch". And yes, the path is "/etc/X11/xorg.conf.d/" and the filename is "99-calibration.conf". If you don't have that file on your Pi then I don't think it will work. By the way, all files in /etc/X11/xorg.conf.d/ are read and executed when Linux starts up. By the way, the text must be added in the section called "InputClass" in said file.

If you're new to the Pi and to Linux then trying to get a TFT screen to work on Raspbian Stretch may be quite difficult. See this topic.

Return to “Official Foundation Display”