NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.13k stars 14.16k forks source link

Graphic Tablet VEIKK Linux Driver #90581

Open mnajib opened 4 years ago

mnajib commented 4 years ago

Project description A driver for VEIKK-brand digitizers/drawing tablets using the usbhid API.

Metadata

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

tobiasBora commented 2 years ago

Weikk provides now official drivers. I don't have time right now to submit a PR, but here is what I used successfully. To use it, just install as a regular program. In case you want to try it locally, run it as root or it won't recognize the device (need for udev rules to be loaded) veikk_driver.nix:

# WARNING: if you want to install this driver for the Veikk, make sure to either run it as root (to avoid issues with udev rules)
# or (to get udev rule loaded) to add it in `services.udev.packages. For now, all models seems to use the same file, but in case of doubt double check here
# https://www.veikk.com/support/download.html
# Make sure to run a single instance.
{ stdenv, lib, fetchurl, dpkg, libusb, autoPatchelfHook, libGL, glib, fontconfig, libXi, libX11, dbus, makeWrapper, xkeyboard_config }:
stdenv.mkDerivation rec {
  name = "-${version}";
  version = "";

  # This is like 20M, so it can take some time
  src = fetchurl {
    url = "https://www.veikk.com/upload/file/20211217/vktablet-1.0.3-2-x86_64.deb";
    sha256 = "sha256-UcjWqVcnCPhfaHGFWJc/LmQspSpeU8rfy3U5VJ55sRg=";
  };

  buildInputs = [ dpkg libusb autoPatchelfHook libGL stdenv.cc.cc.lib glib libX11 libXi dbus fontconfig makeWrapper xkeyboard_config];

  unpackPhase = ''
    echo "Unpacking";
    dpkg -x "$src" .
  '';

  installPhase = ''
    mkdir -p $out
    mv usr/lib $out/opt # contains the main executable
    mv usr/share $out/share # Contains the desktop file
    mv lib $out/lib # Contains udev rules
    substituteInPlace $out/share/applications/vktablet.desktop \
      --replace "Exec=/usr/lib/vktablet/vktablet" "Exec=$out/opt/vktablet/vktablet" \
      --replace "Icon=/usr/lib/vktablet/vktablet.png" "Icon=$out/opt/vktablet/vktablet.png"
    makeWrapper $out/opt/vktablet/vktablet $out/bin/vktablet \
      --set QT_XKB_CONFIG_ROOT ${xkeyboard_config}/share/X11/xkb
  '';

  meta = {
    description = "Official drivers for Veikk tablets (provides pen configuration, pressure map, key mapping, screen mapping...)";
    homepage = https://www.veikk.com/support/download.html;
    license = lib.licenses.unfree; # Supposed to be open source (GPL), but source can't be found online even when requested by users.
    maintainers = [ lib.maintainers.tobiasBora ];
    platforms = lib.platforms.linux;
  };
}

veikk.nix (then import ./veikk.nix from configuration.nix):

{ config, pkgs, ... } :
let veikk_driver = (pkgs.callPackage ./veikk_driver.nix {});
in
{
  environment.systemPackages = [ veikk_driver ];
  # Add udev rules... otherwise you will need root to install the driver.
  services.udev.packages = [ veikk_driver ];
}

this should provide a vktablet executable and entry in the application menu (.desktop). A widget will appear in the systray:

image

and you can configure what you like:

image

image

image

tobiasBora commented 2 years ago

node however that is seems to be unable to save the settings... The problem is that it tries to write in /nix/store/.../opt/vktablet/conf/usr/A30.xml which is read-only for now.

Uncoded-Jargon commented 2 years ago

Hi there, does this method still work or should I just use the ones on the Nix repos? Sorry quite new on Nix and I am still learning how to use it, thanks!

tobiasBora commented 2 years ago

I'm still using this code on a daily basis so it should still work unless they removed the online binary because of an upgrade (I should still fix the problem with saved config and push it to nixpkgs). The packaged version is an unofficial driver that was abandonned once veikk published their drivers.

Uncoded-Jargon commented 2 years ago

I see, do I just put the veikk_drivers.nix and veikk.nix under /nix/store??

tobiasBora commented 2 years ago

Oh no, the /nix/store is read-only, you cannot change it yourself. You are on NixOs or on another os? If you are in NixOs then write the two files in the /etc/nixos/ folder. Then, you should have a file /etc/nixos/configuration.nix: open that file. You should see something like

# some stuff
imports = [
  # some stuff
];
# some stuff

Change it into

# some stuff
imports = [
  # some stuff
 ./veikk.nix
];
# some stuff

Save quit, and run nixos-rebuild switch. You should now have a new program installed called Vktablet. Just start it and play with it!

Uncoded-Jargon commented 2 years ago

Oh yes I am in NixOS, daily driving it for about a week now, anyway thank you so much!

tobiasBora commented 2 years ago

No problems :-) Let me know if you have any issues.

Uncoded-Jargon commented 2 years ago

Seems like the link's dead, should I just replace the old URL with the updated URL for the .deb file?

Update: Did it might self and changed the URL to this long link:

https://veikk.com/image/catalog/Software/new/Linux%EF%BC%88elementary%20OS%E3%80%81Pop%EF%BC%81_OS%E3%80%81Ubuntu%E3%80%81ezgo%E3%80%81debian%E3%80%81mint%E3%80%81mangaro%E3%80%81centOS%E3%80%81Arch%EF%BC%89.zip?v=1660307251

I then ran sudo nixos-rebuild switch and got this error

specified: sha256-UcjWqVcnCPhfaHGFWJc/LmQspSpeU8rfy3U5VJ55sRg=
         got: sha256-v/pvgvJIsaNBVQl+rNbAa8UzjO+fgcq53jnQTTjPhI8=

which makes sense since I didn't change the sha256, so after that I edited it to match with the given file and this error popped up:

dpkg-deb: error: '/nix/store/qjzzs2vllw5fh6rkz1zni6ar6hydlq51-Linux-EF-BC-88elementary-20OS-E3-80-81Pop-EF-BC-81_OS-E3-80-81Ubuntu-E3-80-81ezgo-E3-80-81debian-E3-80-81mint-E3-80-81mangaro-E3-80-81centOS-E3-80-81Arch-EF-BC-89.zip?v=1660307251' is not a Debian format archive

Not sure what to do from here though :<

tobiasBora commented 2 years ago

So as you say the url/hash needs to be updated, and because the driver is now compressed into a zip file, you need to change fetchurl to fetchzip (this way the zip is automatically uncompressed) and the dpkg command should now be changed into dpkg -x $src/*.deb . in order to decompress the deb file contained into the zip file. The rest seems to work as before so the new file becomes:

# WARNING: if you want to install this driver for the Veikk, make sure to either run it as root (to avoid issues with udev rules)
# or (to get udev rule loaded) to add it in `services.udev.packages. For now, all models seems to use the same file, but in case of doubt double check here
# https://www.veikk.com/support/download.html
# Make sure to run a single instance.
{ stdenv, lib, fetchzip, dpkg, libusb, autoPatchelfHook, libGL, glib, fontconfig, libXi, libX11, dbus, makeWrapper, xkeyboard_config }:
stdenv.mkDerivation rec {
  name = "-${version}";
  version = "";

  # This is like 20M, so it can take some time
  src = fetchzip {
    url = "https://veikk.com/image/catalog/Software/new/Linux%EF%BC%88elementary%20OS%E3%80%81Pop%EF%BC%81_OS%E3%80%81Ubuntu%E3%80%81ezgo%E3%80%81debian%E3%80%81mint%E3%80%81mangaro%E3%80%81centOS%E3%80%81Arch%EF%BC%89.zip";
    sha256 = "sha256-5w7xUYe8GeTxY1CA9URmjDwLQWhPBkXNzHovf1BTH38=";
  };

  buildInputs = [ dpkg libusb autoPatchelfHook libGL stdenv.cc.cc.lib glib libX11 libXi dbus fontconfig makeWrapper xkeyboard_config];

  unpackPhase = ''
    echo "Unpacking";
    dpkg -x $src/*.deb .
  '';

  installPhase = ''
    mkdir -p $out
    mv usr/lib $out/opt # contains the main executable
    mv usr/share $out/share # Contains the desktop file
    mv lib $out/lib # Contains udev rules
    substituteInPlace $out/share/applications/vktablet.desktop \
      --replace "Exec=/usr/lib/vktablet/vktablet" "Exec=$out/opt/vktablet/vktablet" \
      --replace "Icon=/usr/lib/vktablet/vktablet.png" "Icon=$out/opt/vktablet/vktablet.png"
    makeWrapper $out/opt/vktablet/vktablet $out/bin/vktablet \
      --set QT_XKB_CONFIG_ROOT ${xkeyboard_config}/share/X11/xkb
  '';

  meta = {
    description = "Official drivers for Veikk tablets (provides pen configuration, pressure map, key mapping, screen mapping...)";
    homepage = https://www.veikk.com/support/download.html;
    license = lib.licenses.unfree; # Supposed to be open source (GPL), but source can't be found online even when requested by users.
    maintainers = [ lib.maintainers.tobiasBora ];
    platforms = lib.platforms.linux;
  };
}
Uncoded-Jargon commented 2 years ago

Hi there! Thank you so much, it works (kinda) now! The aforementioned problem of not having the ability to save configs through the VKTablet program is there it works now!

Update: The earlier issue was resolved, I just needed to change the wires lol

EzekielEnns commented 1 year ago

Thank you!!!! Please merge this someone

So as you say the url/hash needs to be updated, and because the driver is now compressed into a zip file, you need to change fetchurl to fetchzip (this way the zip is automatically uncompressed) and the dpkg command should now be changed into dpkg -x $src/*.deb . in order to decompress the deb file contained into the zip file. The rest seems to work as before so the new file becomes:

# WARNING: if you want to install this driver for the Veikk, make sure to either run it as root (to avoid issues with udev rules)
# or (to get udev rule loaded) to add it in `services.udev.packages. For now, all models seems to use the same file, but in case of doubt double check here
# https://www.veikk.com/support/download.html
# Make sure to run a single instance.
{ stdenv, lib, fetchzip, dpkg, libusb, autoPatchelfHook, libGL, glib, fontconfig, libXi, libX11, dbus, makeWrapper, xkeyboard_config }:
stdenv.mkDerivation rec {
  name = "-${version}";
  version = "";

  # This is like 20M, so it can take some time
  src = fetchzip {
    url = "https://veikk.com/image/catalog/Software/new/Linux%EF%BC%88elementary%20OS%E3%80%81Pop%EF%BC%81_OS%E3%80%81Ubuntu%E3%80%81ezgo%E3%80%81debian%E3%80%81mint%E3%80%81mangaro%E3%80%81centOS%E3%80%81Arch%EF%BC%89.zip";
    sha256 = "sha256-5w7xUYe8GeTxY1CA9URmjDwLQWhPBkXNzHovf1BTH38=";
  };

  buildInputs = [ dpkg libusb autoPatchelfHook libGL stdenv.cc.cc.lib glib libX11 libXi dbus fontconfig makeWrapper xkeyboard_config];

  unpackPhase = ''
    echo "Unpacking";
    dpkg -x $src/*.deb .
  '';

  installPhase = ''
    mkdir -p $out
    mv usr/lib $out/opt # contains the main executable
    mv usr/share $out/share # Contains the desktop file
    mv lib $out/lib # Contains udev rules
    substituteInPlace $out/share/applications/vktablet.desktop \
      --replace "Exec=/usr/lib/vktablet/vktablet" "Exec=$out/opt/vktablet/vktablet" \
      --replace "Icon=/usr/lib/vktablet/vktablet.png" "Icon=$out/opt/vktablet/vktablet.png"
    makeWrapper $out/opt/vktablet/vktablet $out/bin/vktablet \
      --set QT_XKB_CONFIG_ROOT ${xkeyboard_config}/share/X11/xkb
  '';

  meta = {
    description = "Official drivers for Veikk tablets (provides pen configuration, pressure map, key mapping, screen mapping...)";
    homepage = https://www.veikk.com/support/download.html;
    license = lib.licenses.unfree; # Supposed to be open source (GPL), but source can't be found online even when requested by users.
    maintainers = [ lib.maintainers.tobiasBora ];
    platforms = lib.platforms.linux;
  };
}
nixos-discourse commented 11 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/xp-pen-drivers-on-linux/36114/2

jon-zuka commented 2 months ago

What I did is during the install phase, I copied over the xml configuration for my tablet. If you build the derivation, you can explore the result folder and find the default configurations. Copy the modified xml to config/usr

tobiasBora commented 2 months ago

@jon-zuka which folder exactly? This folder needs to be writable by the user I guess?

jon-zuka commented 2 months ago

@tobiasBora

    mkdir -p $out/opt/vktablet/conf/usr
    cp $src/A30.xml $out/opt/vktablet/conf/usr/A30.xml

    cat <<'EOF' > $out/opt/vktablet/conf/comm.xml
    <?xml version="1.0" encoding="utf-8"?>
    <Configure>
      <ShowHotkeyMessage>false</ShowHotkeyMessage>
      <ShowComponentLayout>true</ShowComponentLayout>
      <DisablePenTilt>false</DisablePenTilt>
    </Configure>
    EOF

I added the above to my derivation, where A30.xml has the following content:

<?xml version="1.0" encoding="utf-8"?>
<Configure>
    <Pen model="p01">
        <Button id="1">
            <Action type="mouse">2</Action>
        </Button>
        <Button id="2">
            <Action type="mouse">3</Action>
        </Button>
        <Curve param="0.000,0.500,0.500,1.000"/>
        <WorkMode step="5" device="pen"/>
    </Pen>
    <Tablet vid="0x2feb" enable="pkey,touch" model="A30" pid="0x0002">
        <Key id="1" virtual="false">
            <Action type="key">Ctrl+-</Action>
        </Key>
        <Key id="2" virtual="false">
            <Action type="key">Ctrl+F10</Action>
        </Key>
        <Key id="3" virtual="false">
            <Action type="key">PgUp</Action>
        </Key>
        <Key id="4" virtual="false">
            <Action type="key">PgDn</Action>
        </Key>
        <Touch id="1" event="1">
            <Action type="key">Ctrl+-;</Action>
        </Touch>
        <Touch id="1" event="2">
            <Action type="key">Ctrl++</Action>
        </Touch>
        <Touch id="1" event="3">
            <Action type="key">Ctrl+Win+Right</Action>
        </Touch>
        <Touch id="1" event="4">
            <Action type="key">Ctrl+Win+Left</Action>
        </Touch>
    </Tablet>
    <Mapping>
        <Screen rect="0,0,1920,1080" id="0"/>
        <Work rotation="0" rect="0,0,100,100"/>
    </Mapping>
</Configure>
tobiasBora commented 2 months ago

Thanks, I thought you meant it was possible to have it configured "in live" by the user… but this option is also interesting, I guess it allows some sort of declarative configuration.