jekhor / chromiumos_touch_keyboard

touch_keyboard driver from Chromiumos, fork for run it on GNU/Linux
10 stars 4 forks source link

Touch Keyboard on Fedora 36 #8

Open Txori opened 2 years ago

Txori commented 2 years ago

Hello, I'm trying to compile on Fedora 36, but I get those errors:

[  8%] Building CXX object CMakeFiles/touch_keyboard_handler.dir/main.cc.o
In file included from /home/dude/Downloads/chromiumos_touch_keyboard-master/main.cc:11:
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h: In static member function ‘static void io::set_to_max_on_overflow::on_overflow(T&)’:
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:833:34: error: ‘numeric_limits’ is not a member of ‘std’
  833 |                         x = std::numeric_limits<T>::max();
      |                                  ^~~~~~~~~~~~~~
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:833:50: error: expected primary-expression before ‘>’ token
  833 |                         x = std::numeric_limits<T>::max();
      |                                                  ^
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:833:53: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  833 |                         x = std::numeric_limits<T>::max();
      |                                                     ^~~
      |                                                     std::max
In file included from /usr/include/c++/11/algorithm:62,
                 from /home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:38,
                 from /home/dude/Downloads/chromiumos_touch_keyboard-master/main.cc:11:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /home/dude/Downloads/chromiumos_touch_keyboard-master/main.cc:11:
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h: In static member function ‘static void io::set_to_max_on_overflow::on_underflow(T&)’:
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:838:34: error: ‘numeric_limits’ is not a member of ‘std’
  838 |                         x = std::numeric_limits<T>::min();
      |                                  ^~~~~~~~~~~~~~
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:838:50: error: expected primary-expression before ‘>’ token
  838 |                         x = std::numeric_limits<T>::min();
      |                                                  ^
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:838:53: error: ‘::min’ has not been declared; did you mean ‘std::min’?
  838 |                         x = std::numeric_limits<T>::min();
      |                                                     ^~~
      |                                                     std::min
In file included from /usr/include/c++/11/algorithm:62,
                 from /home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:38,
                 from /home/dude/Downloads/chromiumos_touch_keyboard-master/main.cc:11:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: ‘std::min’ declared here
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /home/dude/Downloads/chromiumos_touch_keyboard-master/main.cc:11:
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h: In function ‘void io::detail::parse_unsigned_integer(const char*, T&)’:
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:967:54: error: ‘numeric_limits’ is not a member of ‘std’
  967 |                                         if(x > (std::numeric_limits<T>::max()-y)/10){
      |                                                      ^~~~~~~~~~~~~~
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:967:70: error: expected primary-expression before ‘>’ token
  967 |                                if(x > (std::numeric_limits<T>::max()-y)/10){
      |                                                             ^

/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:967:73: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  967 |                             if(x > (std::numeric_limits<T>::max()-y)/10){
      |                                                             ^~~
      |                                                             std::max
In file included from /usr/include/c++/11/algorithm:62,
                 from /home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:38,
                 from /home/dude/Downloads/chromiumos_touch_keyboard-master/main.cc:11:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /home/dude/Downloads/chromiumos_touch_keyboard-master/main.cc:11:
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h: In function ‘void io::detail::parse_signed_integer(const char*, T&)’:
/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:998:62: error: ‘numeric_limits’ is not a member of ‘std’
  998 |                                                if(x < (std::numeric_limits<T>::min()+y)/10){
      |                                                             ^~~~~~~~~~~~~~

/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:998:78: error: expected primary-expression before ‘>’ token
  998 |                                if(x < (std::numeric_limits<T>::min()+y)/10){
      |                                                             ^

/home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:998:81: error: ‘::min’ has not been declared; did you mean ‘std::min’?
  998 |                             if(x < (std::numeric_limits<T>::min()+y)/10){
      |                                                             ^~~
      |                                                             std::min
In file included from /usr/include/c++/11/algorithm:62,
                 from /home/dude/Downloads/chromiumos_touch_keyboard-master/csv.h:38,
                 from /home/dude/Downloads/chromiumos_touch_keyboard-master/main.cc:11:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: ‘std::min’ declared here
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
make[2]: *** [CMakeFiles/touch_keyboard_handler.dir/build.make:76: CMakeFiles/touch_keyboard_handler.dir/main.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/touch_keyboard_handler.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
Txori commented 2 years ago

I managed to compile by adding

#include <limits>

in csv.h

Txori commented 2 years ago

Hello, the touch-keyboard_1.4.1 compiled and installed just fine, but it's not working afterwards.

Here's the locations of the files installed:

-- Install configuration: ""
-- Installing: /usr/local/sbin/touch_keyboard_handler
-- Installing: /usr/local/etc/touch_keyboard/layouts
-- Installing: /usr/local/etc/touch_keyboard/layouts/README
-- Installing: /usr/local/etc/touch_keyboard/layouts/YB1-X9x-pc104.csv
-- Installing: /usr/local/etc/touch_keyboard/layouts/YB1-X9x-pc105.csv
-- Installing: /usr/local/etc/touch_keyboard/layout-touchpad.csv
-- Installing: /usr/local/etc/touch_keyboard/touch-hw.csv
-- Installing: /lib/udev/rules.d/60-touch-keyboard.rules
-- Installing: /lib/udev/hwdb.d/61-evdev-yogabook.hwdb
-- Installing: /lib/systemd/system/touch-keyboard-handler.service

So I tried to launch the service manually without success:

$ systemctl enable touch-keyboard-handler.service
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.

Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's .wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer, D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some instance name specified.

Then I tried to launch the elf from it's working directory:

$ (cd /usr/local/etc/touch_keyboard/ && exec /usr/local/sbin/touch_keyboard_handler)

I Starting touch_keyboard_handler
I Touchpad HW config: 1200x1920 points, 139x242 mm, margins is 0+4, rotated by 270 deg. clockwise.
I Creating Fake Touchpad.
I FakeTouchpad geometry: (17, 310), (618, 1150)
E Exception occured
E Failed to open() source device /dev/touch_keyboard. (-1)

Since no files were installed in /dev/touch_keyboard, I'm a bit lost. Could you help me solving this?

Txori commented 2 years ago

All right, I found the explanations in main.cc but I'm not sure I understand what to do:

// This filepath is used as the input evdev device. Whichever touch sensor is
// to be used for touch keyboard input should have a udev rule put in place to
// set up this symlink.
constexpr char kTouchSensorDevicePath[] = "/dev/touch_keyboard";
Txori commented 2 years ago

So I tried to add the symlink as found in yogabook-livecd/config/includes.installer/lib/debian-installer-startup.d/S20touch_kbd : sudo ln -s /dev/input/by-path/platform-808622C1:01-event /dev/touch_keyboard but I still get Failed to open() source device /dev/touch_keyboard. (-1)

Although I need to recreate the symlink after restart, it is really there and working:

ls -l touch_keyboard
lrwxrwxrwx. 1 root root 45 May 22 01:29 touch_keyboard -> /dev/input/by-path/platform-808622C1:01-event
Txori commented 2 years ago

So I suspect the problem comes from the kernel, not sure... So now I'm trying to compile the Kernel and I run into new problems:

$ make yogabook_defconfig && make -j 4 bindeb-pkg
#
# No change to .config
#
sh ./scripts/package/mkdebian
dpkg-buildpackage -r"fakeroot -u" -a$(cat debian/arch)  -b -nc -uc
dpkg-buildpackage: info: source package linux-5.10.2
dpkg-buildpackage: info: source version 5.10.2-1
dpkg-buildpackage: info: source distribution ThirtySix
dpkg-buildpackage: info: source changed by dude <dude@yogabook>
dpkg-architecture: warning: specified GNU system type x86_64-linux-gnu does not match CC system type x86_64-redhat-linux, try setting a correct CC environment variable
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build .
dpkg-checkbuilddeps: error: Unmet build dependencies: bc rsync kmod cpio bison flex | flex:native libelf-dev:native libssl-dev:native
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
make[1]: *** [scripts/Makefile.package:83: bindeb-pkg] Error 3
make: *** [Makefile:1533: bindeb-pkg] Error 2

I'll continue tomorrow.

Txori commented 2 years ago

Still no luck building the kernel. The dependencies are installed but it doesn't work.

But I discovered that the keyboard is working nicely as a giant touchpad, same as the screen, so theoretically, the touch_keyboard binary should work. So I'm back at finding why it fails to open.

In the meantime, I installed gnome extension "Improved OSK" so I don't need the whole hardware package plugged to the USB port.

github-vdelf commented 2 years ago

I got it working after several steps, so I am not sure, which one was important.

I suspect, that the device is not created by udev/kernel. On my installation, the relevant files 60-touch-keyboard.rules and 61-evdev-yogabook.hwdb where not copied by the make install. So I did it manually.

After that, I had to run sudo udevadm hwdb --update

I also had to copy some layout-files, but there was always an error message pointing me in the right direction.

I hope you get it working. It was your post that had me tried fedora 36 on the yoga book.

Txori commented 2 years ago

Nope... I just verified, all files from make install are copied correctly and I run sudo udevadm hwdb --update as you said. The missing simlink is there too. The weird part is that it doesn't disappear on restart anymore, and I did nothing for that to happen. Then I tried to restart, launch the service or the elf, but I still get the same errors mentioned before. Did you install anything else, beside the chromiumos_touch_keyboard-1.4.1 ?

github-vdelf commented 2 years ago

I did not install anything else. Just Fedora, some build-tools and touch_keyboard. I struggled at the same issues as you, but i did not find the script for manually creating the symlink. Maybe some leftovers from your prevoius attempts?

What error do you got? What does ls -l /dev/touch_keyboard say? What does systemctl status touch-keyboard-handler say?

Edit 1.7.2022: I looked at my shell history for steps i did, and i did install one package: acpi. I tried to get battery level shown in the taskbar with gsettings set org.gnome.desktop.interface show-battery-percentage true

Txori commented 2 years ago

Sorry for the late response...

So here's what ls -l /dev/touch_keyboard says: lrwxrwxrwx. /dev/touch_keyboard -> input/event9

I have an error with systemctl status touch-keyboard-handler: yogabook systemd[694]: touch-keyboard-handler.service: Failed to locate executable /usr/sbin/touch_keyboard_handler: No such file or directory

That's weird, I was pretty sure it was there... I must have overlooked it. So I copied it: sudo cp touch_keyboard_handler /usr/sbin (I write it down for the next time I'll try to resurrect my YogaBook) and restarted.

By the way, in CMakeLists.txt, maybe replacing line 30 DESTINATION sbin) per DESTINATION ${CMAKE_INSTALL_SBINDIR}) should do the trick?

Now systemctl status touch-keyboard-handler says: yogabook systemd[694]: touch-keyboard-handler.service: Changing to the requested working directory failed: No such file or directory

So I tried launching the program directly /usr/bin/touch_keyboard_handler :

terminate called after throwing an instance of 'io::error::can_not_open_file'
what(): Can not open file "touch-hw.csv" because "No such file or directory".

But I verified, this files really is there: /usr/local/etc/touch_keyboard/touch-hw.csv And all the other files are correctly copied too.


Edit: I also tried to force the file directory while launching the bin and I get the same error as before: (cd /usr/local/etc/touch_keyboard/ && exec /usr/sbin/touch_keyboard_handler)

github-vdelf commented 2 years ago

I put both csv-files into /etc/touch_keyboard, because the service-file uses this as workdir: [Service] WorkingDirectory=/etc/touch_keyboard

And README.md says _To create custom keyboard layout, edit the file layout.csv and place it as /etc/touchkeyboard/layout.csv. so i copied layouts/YB1-X9x-pc105.csv to /etc/touch_keyboard/layout.csv.

Running it from /usr/local/etc/touch_keyboard directly SHOULD also work, but i did never tried that.

JustCryen commented 2 years ago

I'm on Archlinux and I also had issues running the touch keyboard on my Yoga Book. I symlinked the instalation directory (/usr/local/etc/touch_keyboard/) to the /etc/touch_keyboard and I still get the same error as Txori

I starting touch_keyboard_handler
terminate called after throwing an instance of 'io::error::can_not_open_file'
  what(): Can not open file "touch-hw.csv" because "No such file or directory".
zsh: IOT instruction (core dumped)  touch_keyboard_handler
Txori commented 2 years ago

Thanks @github-vdelf ! I had to also copy touch-hw.csv and layout-touchpad.csv to etc/touch_keyboard. Now the keyboard is working perfectly. That's already a great step ;) Maybe we should make a fedora topic on XDA !

github-vdelf commented 2 years ago

Great work! The touchpad was not working on my Yoga either. But after realizing that there is also a file named layout-touchpad.csv and putting that file into /etc/touch_keyboard, the touchpad came to life, too.

TheLastTeapot commented 1 year ago

Hello, I, on Archlinux, have done everything @Txori did to no avail. I installed the package with #include <limits> added, ran sudo udevadm hwdb --update, and copy-pasted the three layout files into /etc/touch_keyboard. They keyboard area was functioning as a mousepad before, but now it is not, and does not work as a keyboard either. Any ideas? After it didn't work, I also tried copying everything in chromiumos_touch_keyboard_master to /etc/touch_keyboard as well as touch_keyboard_handler to the same place. I also copied 60-touch-keyboard.rules to /etc/udev/rules.d and 61-evdev-yogabook.hwdb to /etc/udev/hwdb.d. I am on the lenovo yogabook YB1-X91F. running /usr/local/sbin/touch_keyboard_handler gives the same error as @JustCryen , and running /etc/touch_keyboard/touch_keyboard_handler gives I Starting touch_keyboard_handler I Touchpad HW config: 1200x1920 points, 139x242 mm, margins is 0+4, rotated by 270 deg. clockwise. I Creating Fake Touchpad. E Exception occuredI FakeTouchpad geometry: (17, 310), (618, 1150) E Unable to open /dev/uinput (-1) E Unable to enable event type 0x1(-1) E Unable to enable EV_KEY 0x14a events () E Unable to enable EV_KEY 0x145 events () E Unable to enable EV_KEY 0x14d events () E Unable to enable EV_KEY 0x14e events () E Unable to enable EV_KEY 0x14f events () E Unable to enable event type 0x3(-1) E uinput device setup ioctl failed. (-1)

The touch keyboard lights light up when I type on an external keyboard, but nothing else. What am I missing?

r00t- commented 1 year ago

E Unable to open /dev/uinput (-1)

modprobe uinput that driver is used to generate keyboard/mouse events from userspace in touch_keybord_handler

TheLastTeapot commented 1 year ago

That doesn't clarify anything?