asus-numpad

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2025 License: MIT Imports: 14 Imported by: 0

README

Asus Touchpad Numpad Driver

CI/CD Go Report Card Go Version Release License

A lightweight Linux driver written in Go that enables numpad functionality on Asus laptops with touchpad-integrated numpads.

Quick Start

git clone https://github.com/sudo-Tiz/asus-numpad.git
cd asus-numpad
make deps && sudo make install

Features

  • Simple: Pure Go, single static binary
  • Fast: Low resource usage, optimized hot path
  • Flexible: JSON layout configuration
  • Lightweight: Only dependency is i2c-tools

Requirements

  • Linux with systemd
  • i2c-tools package
  • Go 1.23+ (for building only)

Installation

1. Install dependencies

The Makefile will detect your package manager automatically:

make deps

Supported package managers: apt, pacman, dnf, zypper

2. Build and install
sudo make install

This will:

  • Build the binary with optimizations (-ldflags="-s -w")
  • Install to /usr/local/bin/asus-numpad
  • Install layout to /etc/asus-numpad/layout.json
  • Install and enable systemd service
  • Configure i2c-dev module to load at boot

Usage

Toggle numpad: Tap the top-right corner of your touchpad

The touchpad LED will light up when numpad mode is active.

Configuration

Edit /etc/asus-numpad/layout.json:

{
  "try_times": 5,
  "try_sleep_ms": 100,
  "cols": 5,
  "rows": 4,
  "top_offset": 0.3,
  "keys": [
    ["KEY_KP7", "KEY_KP8", "KEY_KP9", "KEY_KPSLASH", "KEY_BACKSPACE"],
    ["KEY_KP4", "KEY_KP5", "KEY_KP6", "KEY_KPASTERISK", "KEY_BACKSPACE"],
    ["KEY_KP1", "KEY_KP2", "KEY_KP3", "KEY_KPMINUS", "KEY_RESERVED"],
    ["KEY_KP0", "KEY_KPDOT", "KEY_KPENTER", "KEY_KPPLUS", "KEY_KPEQUAL"]
  ]
}

After editing, restart the service:

sudo systemctl restart asus-numpad

Makefile Targets

make build      # Build the binary
make deps       # Install i2c-tools
make install    # Install everything (requires sudo)
make uninstall  # Remove all files (requires sudo)
make clean      # Remove build artifacts
make help       # Show all targets

Troubleshooting

View logs
journalctl -fu asus-numpad
Manual run with custom layout
sudo /usr/local/bin/asus-numpad --layout-file /path/to/layout.json
Uninstall
sudo make uninstall

Project Structure

.
├── main.go              # Entry point and layout loading
├── driver.go            # Core event loop and key mapping
├── devices.go           # Device detection from /proc
├── layout.json          # Default numpad layout (m433ia)
├── asus-numpad.service  # Systemd service file
├── Makefile             # Build automation
└── README.md            # This file

Performance Optimizations

  • Global key mapping table (no allocations in hot path)
  • Pre-compiled regex patterns
  • Cached float64 conversions
  • Optimized i2c LED control
  • Direct syscall usage for low latency

Contributing

Setup pre-commit hooks
pip install pre-commit
pre-commit install

This will run gofmt and golangci-lint automatically before each commit.

Manual lint and format
make lint  # Format with gofmt and run golangci-lint
Requirements

Install golangci-lint:

go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

Acknowledgements

Inspired by mohamed-badaoui/asus-touchpad-numpad-driver.

License

Free software - use, modify and share as you wish.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL