GithubHelp home page GithubHelp logo

mohamed-badaoui / asus-touchpad-numpad-driver Goto Github PK

View Code? Open in Web Editor NEW
298.0 9.0 70.0 839 KB

Activate Numpad inside the touchpad with top right corner switch

Shell 25.01% Python 74.99%
asus touchpad numpad ux433

asus-touchpad-numpad-driver's Introduction

Asus touchpad numpad driver

Without % = symbols With % = symbols With % = symbols (but incompatible with the non-universal version)
Model/Layout = ux433fa Model/Layout = m433ia Model/Layout = ux581l
without % = symbols with % = symbols model ux581

This is a python service which enables switching between numpad and touchpad for the Asus UX433. It may work for other models. When running the script, use as an argument one of the strings ux433fa or m433ia or `ux581l to select the layout that fits your touchpad. You can inspect the different layouts here.

This python driver has been tested and works fine for these asus versions at the moment:

  • E210MA (with % and = symbols)
  • M433IA (with % and = symbols)
  • R424DA (without extra symbols)
  • ROG Strix G15 2021
  • S413DA (with % and = symbols)
  • TM420 (with % and = symbols)
  • UM425I (with % and = symbols)
  • UM425IA (with % and = symbols)
  • UM425UA (with % and = symbols)
  • UM431DA (without extra symbols)
  • UM433DA (with % and = symbols)
  • UX425EA (with % and = symbols)
  • UX425JA (with % and = symbols)
  • UX434FA (with % and = symbols)
  • UX463FL (with % and = symbols)
  • UX463FA (with % and = symbols)
  • UM462DA (without extra symbols)
  • UX433 (without extra symbols)
  • UX431F (without extra symbols)
  • UX393 (with % and = symbols)
  • UX371E (With % and = symbols)
  • UX362-FA (without extra symbols)
  • UX363EA (with % and = symbols)
  • UX363JA (with % and = symbols)
  • UX333FA (without extra symbols)
  • UX325EA (with % and = symbols)
  • UM325UA (with % and = symbols)
  • X412DA (without extra symbols)
  • UX581L (with % and = symbols)
  • Zephyrus S GX701 (with % and = symbols)

Install required packages

  • Debian / Ubuntu / Linux Mint / Pop!_OS / Zorin OS:
sudo apt install libevdev2 python3-libevdev i2c-tools git
  • Arch Linux / Manjaro:
sudo pacman -S libevdev python-libevdev i2c-tools git
  • Fedora:
sudo dnf install libevdev python-libevdev i2c-tools git
  • NixOS:

Add these to your /etc/nixos/configuration.nix:

# i2c for https://github.com/mohamed-badaoui/asus-touchpad-numpad-driver
hardware.i2c.enable = true;
systemd.services.asus-touchpad-numpad = {
  description = "Activate Numpad inside the touchpad with top right corner switch";
  documentation = ["https://github.com/mohamed-badaoui/asus-touchpad-numpad-driver"];
  path = [ pkgs.i2c-tools ];
  script = ''
    cd ${pkgs.fetchFromGitHub {
      owner = "mohamed-badaoui";
      repo = "asus-touchpad-numpad-driver";
      # These needs to be updated from time to time
      rev = "d80980af6ef776ee6acf42c193689f207caa7968";
      sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
    }}
    # In the last argument here you choose your layout.
    ${pkgs.python3.withPackages(ps: [ ps.libevdev ])}/bin/python asus_touchpad.py ux433fa
  '';
  # Probably needed because it fails on boot seemingly because the driver
  # is not ready yet. Alternativly, you can use `sleep 3` or similar in the
  # `script`.
  serviceConfig = {
    RestartSec = "1s";
    Restart = "on-failure";
  };
  wantedBy = [ "multi-user.target" ];
};

Then enable i2c

sudo modprobe i2c-dev
sudo i2cdetect -l

Now you can get the latest ASUS Touchpad Numpad Driver for Linux from Git and install it using the following commands.

git clone https://github.com/mohamed-badaoui/asus-touchpad-numpad-driver
cd asus-touchpad-numpad-driver
sudo ./install.sh

To turn on/off numpad, tap top right corner touchpad area. To adjust numpad brightness, tap top left corner touchpad area.

To uninstall, just run:

sudo ./uninstall.sh

Troubleshooting

To activate logger, do in a console:

LOG=DEBUG sudo -E ./asus_touchpad.py

For some operating systems with boot failure (Pop!OS, Mint, ElementaryOS, SolusOS), before installing, please uncomment in the asus_touchpad.service file, this following property and adjust its value:

# ExecStartPre=/bin/sleep 2

It is an adaptation made thanks to:

For any question, please do not hesitate to follow this tread discussion (https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1810183)

Thank you very much to all the contributors, mainly on launchpad, who made this device driver possible. (Kawaegle, David/magellan-2000, Pilot6/hanipouspilot, Julian Oertel /clunphumb, YannikSc and so many others. GG!)

asus-touchpad-numpad-driver's People

Contributors

0vj avatar adlererik avatar adrianskar avatar alinaqihassan avatar brotzeller avatar doronbehar avatar dziedzic99 avatar fadamatiik avatar glebtv avatar gregoire-perso avatar jezek avatar karledwards1 avatar kawaegle avatar mohamed-badaoui avatar moisespr123 avatar oschwede avatar pinkflozd avatar santonclause avatar techieboy avatar tobfos2611 avatar vkehayas avatar yanniksc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asus-touchpad-numpad-driver's Issues

asus zenbook ux434fa

ok thanks for your help!! i have one last question what is your kernel version ?

OS boot error on ASUS ROG STRIX 15 (ubuntu 20.04, 5.8.0)

After install on ASUS ROG STRIX 15 (G532LWS) Ubuntu does not boot to login screen. Can boot only console mode.

/proc/bus/input/devices

I: Bus=0018 Vendor=04f3 Product=315e Version=0100
N: Name="ELAN1405:00 04F3:315E Touchpad"
P: Phys=i2c-ELAN1405:00
S: Sysfs=/devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-3/i2c-ELAN1405:00/0018:04F3:315E.0001/input/input20
U: Uniq=
H: Handlers=mouse2 event17 
B: PROP=1
B: EV=1b
B: KEY=e520 30000 0 0 0 0
B: ABS=2e0800000000003
B: MSC=20

If necessary, I can provide additional information.

There may be some problem in Regex

Origin code

device_id=re.sub(r".*i2c-([^/])/.*$", r'\1', line).replace("\n", "")

can not process

S: Sysfs=/devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-15/i2c-ASUE140A:00/0018:04F3:3134.0001/input/input10

it should be fix to

device_id=re.sub(r".*/i2c-([0-9]+)/.*", r'\1', line).replace("\n", "")

Thus, the code may be chang :->

import re
import subprocess
import sys
import math
import importlib
from fcntl import F_SETFL, fcntl
from os import O_NONBLOCK
from subprocess import PIPE, Popen
from time import sleep

from libevdev import EV_ABS, EV_KEY, EV_LED, EV_SYN, Device, InputEvent

tries=5
+ devIDs = []
+ sleep(5)

# Look into the devices file #
while tries > 0:
+    sleep(8)
    keyboard_detected = 0
    touchpad_detected = 0

    with open('/proc/bus/input/devices', 'r') as f:
    
        lines = f.readlines()
        for line in lines:
            # Look for the touchpad #
            if touchpad_detected == 0 and ("Name=\"ASUE" in line or "Name=\"ELAN" in line) and "Touchpad" in line:
                touchpad_detected = 1
    
            if touchpad_detected == 1:
                if "S: " in line:
                    # search device id 
-                    # device_id=re.sub(r".*i2c-([^/])/.*$", r'\1', line).replace("\n", "")
+                    device_id=re.sub(r".*/i2c-([0-9]+)/.*", r'\1', line).replace("\n", "")
                    devIDs.append(device_id)

                if "H: " in line:
                    touchpad = line.split("event")[1]
                    touchpad = touchpad.split(" ")[0]
                    touchpad_detected = 2

            # Look for the keyboard (numlock) # AT Translated Set OR Asus Keyboard
            if keyboard_detected == 0 and ("Name=\"AT Translated Set 2 keyboard" in line or "Name=\"Asus Keyboard" in line):
                keyboard_detected = 1
    
            if keyboard_detected == 1:
                if "H: " in line:
                    keyboard = line.split("event")[1]
                    keyboard = keyboard.split(" ")[0]
                    keyboard_detected = 2

            # Stop looking if both have been found #
            if keyboard_detected == 2 and touchpad_detected == 2:
                break
    
    if keyboard_detected != 2 or touchpad_detected != 2:
        tries -= 1
        if tries == 0:
            if keyboard_detected != 2:
                print("Can't find keyboard, code " + str(keyboard_detected))
            if touchpad_detected != 2:
                print("Can't find touchpad, code " + str(touchpad_detected))
            if touchpad_detected == 2 and not device_id.isnumeric():
                print("Can't find device id")
            sys.exit(1)
    else:
        break

    sleep(0.1)

# Start monitoring the touchpad #
fd_t = open('/dev/input/event' + str(touchpad), 'rb')
fcntl(fd_t, F_SETFL, O_NONBLOCK)
d_t = Device(fd_t)
# Retrieve touchpad dimensions #
ai = d_t.absinfo[EV_ABS.ABS_X]
(minx, maxx) = (ai.minimum, ai.maximum)
ai = d_t.absinfo[EV_ABS.ABS_Y]
(miny, maxy) = (ai.minimum, ai.maximum)

# Start monitoring the keyboard (numlock) #
fd_k = open('/dev/input/event' + str(keyboard), 'rb')
fcntl(fd_k, F_SETFL, O_NONBLOCK)
d_k = Device(fd_k)

model = 'm433ia' # Model used in the derived script (with symbols)

# KEY_5:6
# KEY_APOSTROPHE:40
# [...]
percentage_key = EV_KEY.KEY_5

if len(sys.argv) > 1:
    model = sys.argv[1]

if len(sys.argv) > 2:
    percentage_key = EV_KEY.codes[int(sys.argv[2])]

model_layout = importlib.import_module('numpad_layouts.' + model)

# Create a new keyboard device to send numpad events #
dev = Device()
dev.name = "Asus Touchpad/Numpad"
dev.enable(EV_KEY.KEY_LEFTSHIFT)
dev.enable(EV_KEY.KEY_NUMLOCK)

for col in model_layout.keys:
    for key in col:
        dev.enable(key)

if percentage_key != EV_KEY.KEY_5:
    dev.enable(percentage_key)

udev = dev.create_uinput_device()
finger = 0
value = 0

onCmd = "i2ctransfer -f -y " + device_id + " w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x01 0xad"
offCmd = "i2ctransfer -f -y " + device_id + " w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x00 0xad"

+for i in range(len(devIDs)):
+	onCmd = "i2ctransfer -f -y " + devIDs[i] + " w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x01 0xad"
+	offCmd = "i2ctransfer -f -y " + devIDs[i] + " w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x00 0xad"
+	if subprocess.call(onCmd, shell=True)==0:
+		break
+	print(onCmd)
+	if i == len(devIDs)-1:
+		subprocess.call("cp /proc/bus/input/devices /home/liukairui/.numPadErr/$(date '+ERR_%Y-%m-%d_%H:%M')", shell=True)
+		subprocess.call("echo '\n========\nDEVICE_ID="+device_id+"\n========\n' >> /home/liukairui/.numPadErr/$(date '+ERR_%Y-%m-%d_%H:%M')", shell=True)
+		sys.exit(1)
+ # to record errors...
def activate_numlock():
    events = [
        InputEvent(EV_KEY.KEY_NUMLOCK, 1),
        InputEvent(EV_SYN.SYN_REPORT, 0)
    ]
    udev.send_events(events)
    d_t.grab()
    subprocess.call(onCmd, shell=True)

def deactivate_numlock():
    events = [
        InputEvent(EV_KEY.KEY_NUMLOCK, 0),
        InputEvent(EV_SYN.SYN_REPORT, 0)
    ]
    udev.send_events(events)
    d_t.ungrab()
    subprocess.call(offCmd, shell=True)

numlock=False

# Process events while running #
while True:

    # If keyboard sends numlock event with F8 key tap, enable/disable touchpad events #
    for e in d_k.events():
        if e.matches(EV_KEY.KEY_F8) and e.value == 1:
            numlock = not numlock
            if numlock:
                activate_numlock()
            else:
                deactivate_numlock()

    # If touchpad sends tap events, convert x/y position to numlock key and send it #
    for e in d_t.events():
        # ignore others events, except position and finger events 
        if not (
            e.matches(EV_ABS.ABS_MT_POSITION_X) or 
            e.matches(EV_ABS.ABS_MT_POSITION_Y) or 
            e.matches(EV_KEY.BTN_TOOL_FINGER)
        ):
            continue

        # Get x position #
        if e.matches(EV_ABS.ABS_MT_POSITION_X):
            x = e.value
            continue
        # Get y position #
        if e.matches(EV_ABS.ABS_MT_POSITION_Y):
            y = e.value
            continue

        # If tap #
        if e.matches(EV_KEY.BTN_TOOL_FINGER):
            # If end of tap, send release key event #
            if e.value == 0:
                finger = 0
                try:
                    if value:
                        events = [
                            InputEvent(EV_KEY.KEY_LEFTSHIFT, 0),
                            InputEvent(value, 0),
                            InputEvent(EV_SYN.SYN_REPORT, 0)
                        ]
                        udev.send_events(events)
                        value = None
                    pass
                except OSError as e:
                    pass

            # Start of tap #
            if finger == 0 and e.value == 1:
                finger = 1

        # Check if numlock was hit #
        if (
            e.matches(EV_KEY.BTN_TOOL_FINGER) and 
            e.value == 1 and 
            (x > 0.95 * maxx) and (y < 0.05 * maxy)
        ):
            finger=0
            numlock = not numlock
            if numlock:
                activate_numlock()
            else:
                deactivate_numlock()

        # If touchpad mode, ignore #
        if not numlock:
            continue

        # During tap #
        if finger == 1:
            finger = 2

            try:
                col = math.floor(model_layout.cols * x / maxx)
                row = math.floor((model_layout.rows * y / maxy) - 0.3) # Subtract 0.3 (a third key) as the UX581L has about a third key space at the top

                if row < 0:
                    continue

                value = model_layout.keys[row][col]

                if value == EV_KEY.KEY_5:
                    value = percentage_key

                # Send press key event #
                if value == percentage_key:
                    events = [
                            InputEvent(EV_KEY.KEY_LEFTSHIFT, 1),
                            InputEvent(value, 1),
                            InputEvent(EV_SYN.SYN_REPORT, 0)
                    ]
                else:
                    events = [
                        InputEvent(value, 1),
                        InputEvent(EV_SYN.SYN_REPORT, 0)
                    ]

                udev.send_events(events)
            except OSError as e:
                pass
    sleep(0.1)

# Close file descriptors #
fd_k.close()
fd_t.close()

ROG Zephyrus GX501 support

Hi,

Are there any plans to support the ASUS ROG Zephyrus GX501?

It has one of this numpads. I offer mine to do testing or checks if it is required. Thanks in advance!

rog-gx501-4

Working but no light up solution (maybe)

Hi,

first thing is that the driver is working on my laptop, that is a "X430FA", with the "ux433fa" layout.
The only problem is that i can't see symbols on the touchpad. I solved changing the activation function in this way:

def activate_numlock(brightness):
    numpad_cmd = "i2ctransfer -f -y " + device_id + " w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 " + BRIGHT_VAL[brightness] + " 0xad"
    events = [
        InputEvent(EV_KEY.KEY_NUMLOCK, 1),
        InputEvent(EV_SYN.SYN_REPORT, 0)
    ]
    udev.send_events(events)
    d_t.grab()
    subprocess.call(numpad_cmd, shell=True)
    change_brightness(1)  # !!! THIS ONE IS THE NEW LINE !!!

This way it is fully working. My question is: why doesn't it already work this way? Incompatibility with other devices?
However, if this fix can be accepted, I can fork and add this fix and the update to the README with the new device.

As this is very useful, if you agree, I'd like to add this to the AUR (I will always use the last commit until you make a release) to make it immediate to install on arch. In this case, in my opinion, can be recommended to add a license.

ux393e backlight

Hi!

I've an issue with asus ux393e.

Your script is works correctly on my mashine, but touchpad backlight is not working.
Do you have some ideas how to fix it?

[UM425UAZ / Mint] Failed so load at start up

I just installed it on my new UM425UAZ laptop and it mostly works with the only issues being Fn+F8 not enabling the numpad.
The top right on the touchpad enables the numpad no issues.

Is their anyway to make the driver load up at start up?
I can start the service it manually with "sudo service asus_touchpad_numpad start"
But when starting it again the brightness of the touchpad goes back to lv1 instead of where I left it(in my case Lv3)

While the Fn+F8 issue does not bother me, it might be an issue for someone else.
Have confirmed the issue mentioned in #52

Is it possible to rebind the "Calculator" key when the numpad is disabled.

When using the numpad in windows, you require a 1second hold of the numpad button to turn the numpad on, this would be nice to have here as well to prevent accidental activation

Thank you.

[ALL] Auto detect the Asus model

Greetings.

I just got an E410MA, and I was happy to find your project to enable the numpad. This device has the % and = buttons, but when running the code as-is the calibration was a bit off, because there is an extra "dead" row on the top over the 7-8-9 keys.

In short, I was able to fix this with the edits below. As you see it is just a matter of adding an extra dead row on the top - I also expanded the "ON/OFF" button area in order to match the area covered by the symbol on the display.

Many thanks for making this driver available.

Michael

Device Information:

root@ares:~ # dmidecode | grep "Product Name"
	Product Name: VivoBook_ASUS Laptop E410MA_E410MA
	Product Name: E410MA

Code Changes:


@@ -190,3 +190,3 @@ while True:
             e.value == 1 and 
-            (x > 0.95 * maxx) and (y < 0.05 * maxy)
+            (x > 0.90 * maxx) and (y < 0.20 * maxy)
         ):
@@ -207,4 +207,8 @@ while True:
             try:
+                # zero (empty) row
+                if y < 0.2 * maxy:
+                    # space is not enabled, so this intentionally does nothing
+                    value = EV_KEY.KEY_SPACE
                 # first row
-                if y < 0.25 * maxy:
+                elif y < 0.4 * maxy:
                     if x < 0.2 * maxx:
@@ -220,3 +224,3 @@ while True:
                 # second row
-                elif y < 0.5 * maxy:
+                elif y < 0.6 * maxy:
                     if x < 0.2 * maxx:
@@ -232,3 +236,3 @@ while True:
                 # third row
-                elif y < 0.75 * maxy:
+                elif y < 0.8 * maxy:
                     if x < 0.2 * maxx:



[UM425 / Ubuntu] The backlight is not working Zenbook UM425

The Numpad is working, but the backlight doesn't.
I have tried manually enabling it by this command:
i2ctransfer -f -y " + device_id + " w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x01 0xad
with correct "device_id" and it doesn't work.

Also, I have tried @kawaegle script for testing the backlight, and the result is the same with different values.

I think that enabling backlight in the UM425 has another register address, and I need to send some other I2C data.
How can I find exactly this I2C sequence?

Asus zenbook ubuntu os 5.10

hello,
when i run the command i've:

i2c-3 i2c i915 gmbus dpb I2C adapter
i2c-1 i2c Synopsys DesignWare I2C adapter I2C adapter
i2c-6 i2c i915 gmbus dpd I2C adapter
i2c-4 i2c i915 gmbus dpc I2C adapter
i2c-2 i2c Synopsys DesignWare I2C adapter I2C adapter
i2c-0 smbus SMBus I801 adapter at efa0 SMBus adapter
i2c-7 i2c AUX A/port A I2C adapter
i2c-5 i2c i915 gmbus misc I2C adapter

I would like to know what to choose and where exactly to change the name in the .py?

And then the command that could work with the new name and number?

I just bought this laptop and I removed windows but everything works except the num pad (touch pad work)

Thank you for your work and your time.

This driver worked but I can't see any light.

I have zenbook ux425ea, Numpad worked by this drivers but I can't see any light.
I also try to this:
sudo i2ctransfer -f -y 0 w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x01 0xad but not worked.

Multi-touch is not supported

If one types fast and presses another number key while still holding the previous key, the second keystroke would simply get ignored. But In order to make typing fast possible, the keystrokes must still be recorded, just like a physical keyboard.

Asus Zenbook S UX393 support (with %)

On my laptop the script says that touchpad is not found. The correct device in /proc/bus/input/devices is:

I: Bus=0018 Vendor=04f3 Product=3134 Version=0100
N: Name="ASUE140A:00 04F3:3134 Touchpad"

However, the script looks for if touchpad_detected == 0 and "Name=\"ELAN" in line and "Touchpad" in line:, but my device name starts with ASUE. I have other ELAN devices as well, but the one above works to switch the numpad on.

Can the script just look for "Touchpad" without the "ELAN"?

estimated battery time display asus zenbook ux434fa os 5.8

hi mohamed,

I have a question about the display of the estimated time remaining of the battery because I have a problem, the battery works well but the estimated time remaining changes each time I look would you have an idea to fix this problem?

Support for top-left corner

thanks for your working, my device(UX425EA/U4700E) works,
but my numpad alse have an button (at top-left of touchpad) which can start/stop the calculator on windows, may you please release the function like when touch at the top-left corner then run the bash script specified by user?

深度截图_选择区域_20210624110930

Traceback y not defined

Hi,
I don't have the traceback available. But in the code I found something that looked wrong.

In /usr/bin/asus_touchpad_numpad.py there looks to me (and my traceback at computer startup), that x and y could be undefined:

      # During tap #
      if finger == 1:
          finger = 2
          try:
              # first row
              if y < 0.25 * maxy:

if not these have been matched:

        # Get x position #
        if e.matches(EV_ABS.ABS_MT_POSITION_X):
            x = e.value
            continue
        # Get y position #
        if e.matches(EV_ABS.ABS_MT_POSITION_Y):
            y = e.value
            continue

Default values for x and y maybe could help, or an indicator if this has happened.

Also while at it, the try-catch-case this is in looks like it is only used for the last rows, so try could be moved there instead.

Failing to load numpad driver blocks keyboard from working

Expected behavior: If the numpad driver fails to load, laptop's keyboard should still work.
Actual: When I receive an error loading the numpad driver, keyboard does not response to key presses.

Hardware: Asus Zenbook UM425QA
OS: Ubuntu 21.10 w/Wayland

Steps to replicate:

  1. Cold boot to Ubuntu login screen.
  2. Receive error: "[FAILED] Failed to start Asus Touchpad to Numpad Handler."
  3. Try to use keyboard to login, find keyboard to be unresponsive.
  4. Restart computer using mouse and GUI power menu in login screen
  5. Touchpad to numberpad works fine, keyboard works fine.

Activate the numpad on Fn+F8 instead of F8

Event though the shortcut is under the F8 key, it should activate on Fn+F8, and not on F8. On devices that have the Fn-Lock, if the Lock is active, pressing F8 will not activate the numpad as would be expected.

Not detected here on NixOS with UX433

I noticed you look into /proc/bus/input/devices here. What does it mean if the code doesn't find it? I noticed ux433 is supposed to be supported. The only device I can find there myself with the words ASUS is:

I: Bus=0019 Vendor=0000 Product=0000 Version=0000
N: Name="Asus WMI hotkeys"
P: Phys=asus-nb-wmi/input0
B: EV=100013
B: KEY=1000000080000 0 0 0 0 181606f00900000 8280027801701000 e000000000000 0
B: MSC=10

But that seems like something that controls the backlight according to: http://manpages.ubuntu.com/manpages/bionic/man4/acpi_asus_wmi.4freebsd.html . Perhaps I'm missing some kernel drivers?

I wish to add this program as a service for NixOS, thanks for any help.

The installer does not move all the required files

Installation script does not move numpad_layouts directory to /usr/share/asus_touchpad_numpad-driver, This makes when the script runs by the systemd, do not run and show an error. But when I run it manuaaly(with python asus_touchpad.py) in cloned directory, it does not show the error

OS : Archlinux

ASUS M433IA

Hello Mohamed,

After many updates were deployed on my Linux Mint system, I wanted to retest the driver for the Numpad on my ASUS M433IA.

Unfortunately, the driver doesn't work at all, whereas during the previous developments, it worked.

For the record, I have an AZERTY keyboard with % and = symbols and the instructions to turn my numpad on and off are :

ON: sudo i2ctransfer -f -y 0 w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x01 0xad

OFF: sudo i2ctransfer -f -y 0 w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x00 0xad

I have reinstalled the old version I had but as soon as the Firefox browser is launched, the keyboard freaks out as usual So I would like to test the latest version which seems to work for everyone but me.

Next holiday I'm going to install the latest version of Linux Mint on my computer and hopefully things will be better. But in the meantime, I'd like to be able to test the latest version of the driver.

Thanks in advance for your help.

David.

[Model? / Solus OS - Arch] Install won't let X11 load, no errors

After installing on Solus 4.3 and rebooting, there was no GUI and X11 appeared not to have started; additionally, there was no way to start it... It just refused.

Running sudo systemctl disable asus_touchpad_numpad.service allows everything to start appropriately.

Any ideas?

ZenBook Pro Duo UX581

Hello everybody!!!
I tried to adapt the script for touchpad with % and = for the ZenBook Pro Duo UX581 with Manjaro kernel 12
asus-zenbook-pro-duo-touchpad2
I recalculate cols and rows sizes and I putted the events following the image.
After that I got a problem with the %
I could reproduce the % sending an InputEvent(EV_KEY.KEY_LEFTSHIFT, 1) plus an InputEvent(EV_KEY.KEY_5, 1)
but after write in the screen the first %, the system makes a very little pause and begins to write a lot of % till I click another character in the touchpad.
After that, the % doesn't write anything more and the keyboard respond badly. The rest of the touchpad characters follows fine.

The code modified:

`
import re
import subprocess
import sys
from fcntl import F_SETFL, fcntl
from os import O_NONBLOCK
from subprocess import PIPE, Popen
from time import sleep

from libevdev import EV_ABS, EV_KEY, EV_LED, EV_SYN, Device, InputEvent

tries=5

Look into the devices file

while tries > 0:

keyboard_detected = 0
touchpad_detected = 0

with open('/proc/bus/input/devices', 'r') as f:

    lines = f.readlines()
    for line in lines:
        # Look for the touchpad #
        if touchpad_detected == 0 and ("Name=\"ASUE" in line or "Name=\"ELAN" in line) and "Touchpad" in line:
            touchpad_detected = 1

        if touchpad_detected == 1:
            if "S: " in line:
                # search device id 
                device_id=re.sub(r".*i2c-([^/])/.*$", r'\1', line).replace("\n", "")

            if "H: " in line:
                touchpad = line.split("event")[1]
                touchpad = touchpad.split(" ")[0]
                touchpad_detected = 2

        # Look for the keyboard (numlock) # AT Translated Set OR Asus Keyboard
        if keyboard_detected == 0 and ("Name=\"AT Translated Set 2 keyboard" in line or "Name=\"Asus Keyboard" in line):
            keyboard_detected = 1

        if keyboard_detected == 1:
            if "H: " in line:
                keyboard = line.split("event")[1]
                keyboard = keyboard.split(" ")[0]
                keyboard_detected = 2

        # Stop looking if both have been found #
        if keyboard_detected == 2 and touchpad_detected == 2:
            break

if keyboard_detected != 2 or touchpad_detected != 2:
    tries -= 1
    if tries == 0:
        if keyboard_detected != 2:
            print("Can't find keyboard, code " + str(keyboard_detected))
        if touchpad_detected != 2:
            print("Can't find touchpad, code " + str(touchpad_detected))
        if touchpad_detected == 2 and not device_id.isnumeric():
            print("Can't find device id")
        sys.exit(1)
else:
    break

sleep(0.1)

Start monitoring the touchpad

fd_t = open('/dev/input/event' + str(touchpad), 'rb')
fcntl(fd_t, F_SETFL, O_NONBLOCK)
d_t = Device(fd_t)

Retrieve touchpad dimensions

ai = d_t.absinfo[EV_ABS.ABS_X]
(minx, maxx) = (ai.minimum, ai.maximum)
ai = d_t.absinfo[EV_ABS.ABS_Y]
(miny, maxy) = (ai.minimum, ai.maximum)

Start monitoring the keyboard (numlock)

fd_k = open('/dev/input/event' + str(keyboard), 'rb')
fcntl(fd_k, F_SETFL, O_NONBLOCK)
d_k = Device(fd_k)

Create a new keyboard device to send numpad events

dev = Device()
dev.name = "Asus Touchpad/Numpad"
dev.enable(EV_KEY.KEY_KP1)
dev.enable(EV_KEY.KEY_KP2)
dev.enable(EV_KEY.KEY_KP3)
dev.enable(EV_KEY.KEY_KP4)
dev.enable(EV_KEY.KEY_KP5)
dev.enable(EV_KEY.KEY_5)
dev.enable(EV_KEY.KEY_KP6)
dev.enable(EV_KEY.KEY_KP7)
dev.enable(EV_KEY.KEY_KP8)
dev.enable(EV_KEY.KEY_KP9)
dev.enable(EV_KEY.KEY_KP0)
dev.enable(EV_KEY.KEY_BACKSPACE)
dev.enable(EV_KEY.KEY_KPSLASH)
dev.enable(EV_KEY.KEY_KPASTERISK)
dev.enable(EV_KEY.KEY_KPMINUS)
dev.enable(EV_KEY.KEY_KPPLUS)
dev.enable(EV_KEY.KEY_KPCOMMA)
dev.enable(EV_KEY.KEY_KPENTER)
dev.enable(EV_KEY.KEY_LEFTSHIFT)
dev.enable(EV_KEY.KEY_NUMLOCK)
dev.enable(EV_KEY.KEY_APOSTROPHE)
dev.enable(EV_KEY.KEY_KPDOT)
dev.enable(EV_KEY.KEY_KPEQUAL)

udev = dev.create_uinput_device()
finger = 0
value = 0

onCmd = "i2ctransfer -f -y " + device_id + " w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x01 0xad"
offCmd = "i2ctransfer -f -y " + device_id + " w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x00 0xad"

def activate_numlock():
events = [
InputEvent(EV_KEY.KEY_NUMLOCK, 1),
InputEvent(EV_SYN.SYN_REPORT, 0)
]
udev.send_events(events)
d_t.grab()
subprocess.call(onCmd, shell=True)

def deactivate_numlock():
events = [
InputEvent(EV_KEY.KEY_NUMLOCK, 0),
InputEvent(EV_SYN.SYN_REPORT, 0)
]
udev.send_events(events)
d_t.ungrab()
subprocess.call(offCmd, shell=True)

numlock=False

Process events while running

while True:

# If keyboard sends numlock event with F8 key tap, enable/disable touchpad events #
for e in d_k.events():
    if e.matches(EV_KEY.KEY_F8) and e.value == 1:
        numlock = not numlock
        if numlock:
            activate_numlock()
        else:
            deactivate_numlock()

# If touchpad sends tap events, convert x/y position to numlock key and send it #
for e in d_t.events():
    # ignore others events, except position and finger events 
    if not (
        e.matches(EV_ABS.ABS_MT_POSITION_X) or 
        e.matches(EV_ABS.ABS_MT_POSITION_Y) or 
        e.matches(EV_KEY.BTN_TOOL_FINGER)
    ):
        continue

    # Get x position #
    if e.matches(EV_ABS.ABS_MT_POSITION_X):
        x = e.value
        continue
    # Get y position #
    if e.matches(EV_ABS.ABS_MT_POSITION_Y):
        y = e.value
        continue

    # If tap #
    if e.matches(EV_KEY.BTN_TOOL_FINGER):
        # If end of tap, send release key event #
        if e.value == 0:
            finger = 0
            try:
                if value:
                    events = [
                        InputEvent(EV_KEY.KEY_LEFTSHIFT, 0),
                        InputEvent(value, 0),
                        InputEvent(EV_SYN.SYN_REPORT, 0)
                    ]
                    udev.send_events(events)
                    value = None
                pass
            except OSError as e:
                pass

        # Start of tap #
        if finger == 0 and e.value == 1:
            finger = 1

    # Check if numlock was hit #
    if (
        e.matches(EV_KEY.BTN_TOOL_FINGER) and 
        e.value == 1 and 
        (x > 0.95 * maxx) and (y < 0.05 * maxy)
    ):
        finger=0
        numlock = not numlock
        if numlock:
            activate_numlock()
        else:
            deactivate_numlock()

    # If touchpad mode, ignore #
    if not numlock:
        continue

    # During tap #
    if finger == 1:
        finger = 2
        try:
            # first zero row
            #if y < 0.13 * maxy:
			#	if x < 0.499 * maxx:
            #        value = EV_KEY.KEY_APOSTROPHE
            #    else:
            #        value = EV_KEY.KEY_F8
            # first row
            if y < 0.293 * maxy:
                if x < 0.273 * maxx:
                    value = EV_KEY.KEY_KPEQUAL
                elif x < 0.499 * maxx:
                    value = EV_KEY.KEY_APOSTROPHE
                else:
                    value = EV_KEY.KEY_BACKSPACE
            # second row
            elif y < 0.456 * maxy:
                if x < 0.273 * maxx:
                    value = EV_KEY.KEY_KP7
                elif x < 0.499 * maxx:
                    value = EV_KEY.KEY_KP8
                elif x < 0.725 * maxx:
                    value = EV_KEY.KEY_KP9
                else:
                    value = EV_KEY.KEY_KPSLASH
            # third row
            elif y < 0.619 * maxy:
                if x < 0.273 * maxx:
                    value = EV_KEY.KEY_KP4
                elif x < 0.499 * maxx:
                    value = EV_KEY.KEY_KP5
                elif x < 0.725 * maxx:
                    value = EV_KEY.KEY_KP6
                else:
                    value = EV_KEY.KEY_KPASTERISK
            # fourth row
            elif y < 0.782 * maxy:
                if x < 0.273 * maxx:
                    value = EV_KEY.KEY_KP1
                elif x < 0.499 * maxx:
                    value = EV_KEY.KEY_KP2
                elif x < 0.725 * maxx:
                    value = EV_KEY.KEY_KP3
                else:
                    value = EV_KEY.KEY_KPMINUS
            # fifth row
            #elif y < 0.945 * maxy:
            else :
                if x < 0.25 * maxx:
                    value = EV_KEY.KEY_KP0
                elif x < 0.499 * maxx:
                    value = EV_KEY.KEY_KPDOT
                elif x < 0.725 * maxx:
                    value = EV_KEY.KEY_KPENTER
                else:
                    value = EV_KEY.KEY_KPPLUS
            # last zero row
            #else :

            # Send press key event #
            if value == EV_KEY.KEY_APOSTROPHE :
                events = [
                        InputEvent(EV_KEY.KEY_LEFTSHIFT, 1),
                        InputEvent(EV_KEY.KEY_5, 1),
                        InputEvent(EV_SYN.SYN_REPORT, 0)
                ]
                value = 0
            else:
                events = [
                    InputEvent(value, 1),
                    InputEvent(EV_SYN.SYN_REPORT, 0)
                ]
            udev.send_events(events)
        except OSError as e:
            pass
sleep(0.1)

Close file descriptors

fd_k.close()
fd_t.close()
`

Moreover, I had to modify the service because the gnome doesn't start till I click Alt+F2, command line, startx:

`
[Unit]
Description=Asus Touchpad to Numpad Handler
After=graphical.target

[Service]
ExecStart=/usr/bin/python3 /usr/bin/asus_touchpad_numpad.py

[Install]
WantedBy=graphical.target
`

Thanks

Small issues with Asus UX425EA

Hi,

On my Asus UX425EA, using the top right corner of the touchpad to activate/deactivate the numeric pad does not work: it works once after installing the driver, then never again.

Also sporadically the touchpad is deactivated when switching off the numpad.

How can I help debugging?

Enhancement request: map the "calculator symbol", left top of touchscreen to a F-key

As you are already taking the input from the touchpad and enhancing it, with that you made the numerical keypad "key" available. Would it be possible to also make the left top available as key?
-> If you could make the event available as a keypress (like F30), the user could use this as a shortcut to start any desktop application. (and not just the calculator as asus made available under Windows).

Thanks.

German keyboard

Hi Mohamed!
Thank you very much for your time and the wonderful solution.
Unfortunately I have a German keyboard and had to change all the keys, except the / and * that I can't get done.
It seems the installation does not accept 'SHIFT_KEY_RIGHTBRACE': '' (german) the Shift configuration, and for example: 'KEY_KPSLASH': '/', 'KEY_KPASTERISK': '', (DE) also doesnt work.
Do you know how to find exactly what kind or KEY is using my keyboard or how to use SHIFT?

Thank you again for your time and effort.

ux363ea

new value of mesh for asus ux363ea

xx = [0.232,0.410,0.588,0.768]
yy = [0.343,0.553,0.763]

        try:
            # first row
            if y < yy[0] * maxy:
                if x < xx[0] * maxx:
                    value = EV_KEY.KEY_KP7
                elif x < xx[1] * maxx:
                    value = EV_KEY.KEY_KP8
                elif x < xx[2] * maxx:
                    value = EV_KEY.KEY_KP9
                elif x < xx[3] * maxx:
                    value = EV_KEY.KEY_KPSLASH
                else:
                    value = EV_KEY.KEY_BACKSPACE
            # second row
            elif y < yy[1] * maxy:
                if x < xx[0] * maxx:
                    value = EV_KEY.KEY_KP4
                elif x < xx[1] * maxx:
                    value = EV_KEY.KEY_KP5
                elif x < xx[2] * maxx:
                    value = EV_KEY.KEY_KP6
                elif x < xx[3] * maxx:
                    value = EV_KEY.KEY_KPASTERISK
                else:
                    value = EV_KEY.KEY_BACKSPACE
            # third row
            elif y < yy[2] * maxy:
                if x < xx[0] * maxx:
                    value = EV_KEY.KEY_KP1
                elif x < xx[1] * maxx:
                    value = EV_KEY.KEY_KP2
                elif x < xx[2] * maxx:
                    value = EV_KEY.KEY_KP3
                elif x < xx[3] * maxx:
                    value = EV_KEY.KEY_KPMINUS
                else:
                    value = EV_KEY.KEY_5
            # last row
            else :
                if x < xx[0] * maxx:
                    value = EV_KEY.KEY_KP0
                elif x < xx[1] * maxx:
                    value = EV_KEY.KEY_KPDOT
                elif x < xx[2] * maxx:
                    value = EV_KEY.KEY_KPENTER
                elif x < xx[3] * maxx:
                    value = EV_KEY.KEY_KPPLUS
                else:
                    value = EV_KEY.KEY_KPEQUAL

How do you found the command to light up the numpad ?

Hi @mohamed-badaoui !
Your driver is useful for me, and i was waiting for someone to do that, but i was interested in how do you found the i2c command used to light up the touchpad ? (this one for me : sudo i2ctransfer -f -y 0 w13@0x15 0x05 0x00 0x3d 0x03 0x06 0x00 0x07 0x00 0x0d 0x14 0x03 0x01 0xad)

And also, what means lines [email protected] and StandardInput=tty-force in your .service file ?
(Actually, it doesn't work on my laptop if i ddon't remove the line [email protected] )

Work almost well for Asus S413DA

This driver work almost well for my computer, except the .service file is wrong on my computer (it does work only without the option Conflicts in [Unit] )

consider changing the name?

Might want to consider changing the name to something like asus-zenbook-touchpad-numberpad. This "driver" works on a lot of models.
btw thx for the merge.

Install Script Tries to Place Service File in Wrong Directory for Solus OS

During install on my Solus 4.3 machine, the script threw an error:
./install.sh: line 98: /lib/systemd/system/asus_touchpad_numpad.service: No such file or directory Failed to enable unit: Unit file asus_touchpad_numpad.service does not exist. Something gone wrong while enabling asus_touchpad_numpad.service

Changing line 98 from installing the service file in /lib/systemd/system/ to /etc/systemd/system/ solved the issue for me.

Fantastic work on this!

UX425EA no light

Model: UX425EA
OS: Linux Mint 20.1

After two reboots the brightness of the numpad is completally dark. How can I solve this problem?

Support for Asus Zenbook Flip 13 UX363EA-IH74T

Hi,
I have the laptop mentioned in the title. It has the exact same touchpad layout and seems to support a numpad within the touchpad (in Windows).
Would it be possible to add support for this laptop in your code?
I tested with the existing code on Arch, but I can not get this to work reliably in its current form.
Attached the output showing the devices.
Thanks.

Hendrik-Jan

Blocks Bootloader in Pop Os!

Hello,

This service blocks the boot process for Pop Os!
I haven't tried it on Ubuntu but it seems to work pretty well judging by the comments

Please note that Pop Os uses a different bootLoader than Ubuntu.
There is a work around this (disabling the Service before shutdown and starting it after the boot process) but I think that a solution out of the box is better.
I think an easy solution is to run the main loop in a secondary thread.
What do you think?

AUR support

Can I write a AUR support for that touchpad drive give your name as developer and set myself as maintainer or you are already working on the AUR ?

Enhancement: possibility not to use F8

Hi,

I've installed the driver on my Asus UX425EA. It works pretty well and I can activate and deactivate the numeric pad using the touchpad upper right corner. However I'd like not to use F8, because it is a key I use very often in my code editor (next debugger step!), so I get a lot of flashing light ;-)

Asus Pro Art Studiobook W700

Hi I just wanted to let you know that I have just installed your driver successfully on the Asus Studiobook W700 and it works perfectly.

I used Option 2 layout with Qwerty

Thank you so much for releasing this driver :)

TouchPad not highlited (ZenBook UX425EA_UX425EA)

Hi, i have next laptop
image

tried all installation options but i have next issue:
Numpad not highlighted(it just dark like turned off), but if i press right top corner i can write numbers like numpad is working properly.
Can you please direct me where i can find part of code which response for highlight of touch bar?
Tried to find by myself but with no result.
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.