Skip to content

Input Devices

Pinnacle provides ways to manage input devices, like keyboards, mice, touchpads, and more.

Device handles

Input devices are exposed to you through device handles. Handles can be retrieved by requesting all of them manually, and they are also provided through the "device added" signal and for_each_device function.

lua
local devices = require("pinnacle.input.libinput").get_devices()

Device handles expose ways to set various libinput settings as well as getters for device information, like name and vendor ID.

Device setup

You will probably want to set device settings on both startup and whenever a new device is connected. The API provides the for_each_device function, which allows you to supply a function that operates on all currently connected input devices as well as all newly connected ones.

lua
require("pinnacle.input.libinput").for_each_device(function(device)
    if device:device_type() == "touchpad" then
        device:set_natural_scroll(true)
        device:set_tap(true)
    end
    -- Do other stuff with the device
end)

Read the corresponding API reference to see all possible settings.

Keyboard settings

Keyboards have some extra settings separate from libinput.

xkeyboard-config

You can set a custom xkb-config by doing the following:

lua
require("pinnacle.input").set_xkb_config({
    layout = "us,fr,ge",
    options = "ctrl:swapcaps,caps:shift"
})

This currently only supports setting the xkb-config globally.

Repeat rate and delay

Setting the repeat rate and delay changes how long it takes a held down key to start repeating as well as how often it repeats once it does.

lua
require("pinnacle.input").set_repeat_rate(25, 500)

This currently only supports setting the repeat rate and delay globally.