No project description provided
Project description
AnalogSense Python SDK
Python port of AnalogSense.js for analog keyboard input.
Supported Keyboards/Devices
- Everything by Wooting
- Everything by NuPhy
- Everything by DrunkDeer
- Razer Huntsman V2 AnalogR
- Razer Huntsman Mini AnalogR
- Razer Huntsman V3 ProR
- Razer Huntsman V3 Pro MiniR
- Razer Huntsman V3 Pro TenkeylessR
- Keychron Q1 HEP, F
- Keychron Q3 HEP, F
- Keychron Q5 HEP, F
- Keychron K2 HEP, F
- Lemokey P1 HEP, F
- Madlions MAD60HEP
- Madlions MAD68HEP
- Madlions MAD68RP
- Redragon K709HEP
R Razer Synapse needs to be installed and running for analogue inputs to be received from this keyboard.
P The official firmware only supports polling, which can lead to lag and missed inputs.
F Custom firmware with full analog report functionality is available.
Installation
pip install AnalogSensePy
On Linux you may need udev rules or sudo for hid
printf '%s\n' \
'KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0660", GROUP="input"' \
'SUBSYSTEM=="usb", ATTRS{idVendor}=="31e3", MODE="0660", GROUP="input"' \
'SUBSYSTEM=="usb", ATTRS{idVendor}=="03eb", MODE="0660", GROUP="input"' \
'SUBSYSTEM=="usb", ATTRS{idVendor}=="1532", MODE="0660", GROUP="input"' \
'SUBSYSTEM=="usb", ATTRS{idVendor}=="19f5", MODE="0660", GROUP="input"' \
'SUBSYSTEM=="usb", ATTRS{idVendor}=="352d", MODE="0660", GROUP="input"' \
'SUBSYSTEM=="usb", ATTRS{idVendor}=="3434", MODE="0660", GROUP="input"' \
'SUBSYSTEM=="usb", ATTRS{idVendor}=="362d", MODE="0660", GROUP="input"' \
'SUBSYSTEM=="usb", ATTRS{idVendor}=="373b", MODE="0660", GROUP="input"' \
'SUBSYSTEM=="usb", ATTRS{idVendor}=="372e", MODE="0660", GROUP="input"' \
| sudo tee /etc/udev/rules.d/99-analogsense.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
Usage
from analogsense import AnalogSense
as_ = AnalogSense()
devices = as_.get_devices()
if not devices:
print("no supported analog keyboards found.")
exit()
if len(devices) == 1:
dev = devices[0]
else:
for i, d in enumerate(devices):
print(f" [{i}] {d.product_name}")
dev = devices[int(input("select device index: "))]
def on_keys(active_keys):
for k in active_keys:
# converting the scancode to a nice readable string
name = as_.scancode_to_string(k["scancode"])
# some providers can return the digital state of the key
# (what the system perceives the key as pressed or not)
# other providers that do not support this will return None
if k["digital"] is not None:
digital = " [down]" if k["digital"] else " [up]"
else:
digital = ""
print(f"{name:20s} {k['value']:.4f}{digital}")
dev.start_listening(on_keys)
input("press keys... enter to stop.\n")
dev.stop_listening()
The following functions are available on AnalogSense:
get_devices() -> list[Device]open_device(vendor_id, product_id) -> Device | Nonescancode_to_string(scancode: int) -> str
A device instance has the following members:
start_listening(handler: Callable[[list[{"scancode": int, "value": float}]], None])stop_listening()product_name: strforget()dev: DeviceHandle
Scancodes
The scancodes provided by this library are primarily HID scancodes; most keys are mapped as seen on usage page 0x07 (A = 0x04, B = 0x05, ...).
Control keys (usage page 0x0C) are mapped in the 0x3__ range, modulo 0x100:
0x3B5= Next Track0x3B6= Previous Track0x3B7= Stop Media0x3CD= Play/Pause0x394= Open File Explorer0x323= Open Browser Home Page
OEM-specific keys are mapped in the 0x4__ range:
0x401= Brightness Up0x402= Brightness Down0x403= Profile 10x404= Profile 20x405= Profile 30x408= Profile Switch0x409= Function Key (Fn)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file analogsensepy-1.0.6.tar.gz.
File metadata
- Download URL: analogsensepy-1.0.6.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5366b1a8478a9720ba80069d5f093d2be25eec0180248a1eb4b74e0081f2e6b1
|
|
| MD5 |
742ab792404a343eb7858869a155d260
|
|
| BLAKE2b-256 |
186b4be5c7d8043acb8859d4f5f169b8599efdcea9dfb80328f4fb352891f931
|
Provenance
The following attestation bundles were made for analogsensepy-1.0.6.tar.gz:
Publisher:
publish.yml on girlglock/AnalogSense-Python-SDK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
analogsensepy-1.0.6.tar.gz -
Subject digest:
5366b1a8478a9720ba80069d5f093d2be25eec0180248a1eb4b74e0081f2e6b1 - Sigstore transparency entry: 1372150786
- Sigstore integration time:
-
Permalink:
girlglock/AnalogSense-Python-SDK@e89f6a4f126e356a6cdbabe9ed4b8251043d8c60 -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/girlglock
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e89f6a4f126e356a6cdbabe9ed4b8251043d8c60 -
Trigger Event:
push
-
Statement type:
File details
Details for the file analogsensepy-1.0.6-py3-none-any.whl.
File metadata
- Download URL: analogsensepy-1.0.6-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f694e72c66bb58ab19a3b18ad44adde1f69d8df2936f27e5b8e2dade7875ac5
|
|
| MD5 |
7f0cb34c7ecaf633f0da857ec3e0eccc
|
|
| BLAKE2b-256 |
875fe97783bdeb04ec9220315388a780cacf29bbd7657573202f4a5103f26830
|
Provenance
The following attestation bundles were made for analogsensepy-1.0.6-py3-none-any.whl:
Publisher:
publish.yml on girlglock/AnalogSense-Python-SDK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
analogsensepy-1.0.6-py3-none-any.whl -
Subject digest:
6f694e72c66bb58ab19a3b18ad44adde1f69d8df2936f27e5b8e2dade7875ac5 - Sigstore transparency entry: 1372151218
- Sigstore integration time:
-
Permalink:
girlglock/AnalogSense-Python-SDK@e89f6a4f126e356a6cdbabe9ed4b8251043d8c60 -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/girlglock
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e89f6a4f126e356a6cdbabe9ed4b8251043d8c60 -
Trigger Event:
push
-
Statement type: