{{- $tags := .chezmoi.config.data.tags -}}

hl.config({
  input = {
    kb_layout = "ultimatekeys",
    kb_options = "caps:escape_shifted_capslock",
    {{- if (not (index $tags "laptop")) }}
    numlock_by_default = true,
    {{- end }}
    repeat_rate = 25,
    repeat_delay = 600,
    follow_mouse = 0,
    focus_on_close = 2,

    mouse_refocus = true,
    float_switch_override_focus = 2,
    special_fallthrough = true,
    {{- if (index $tags "laptop") }}
    touchpad = {
      disable_while_typing = true,
      scroll_factor = 1.0,
      tap_to_click = true
    }
    {{- end }}
  }
})

{{- if (not (index $tags "laptop")) }}
hl.device({
  name = "Logitech Gaming Mouse G502",
  sensitivity = 0.0,
  accel_profile = "flat"
})
{{- end }}

{{- if (index $tags "laptop") }}
-- Trackpad gestures (v0.55 API): 3-finger horizontal swipe → workspaces,
-- 4-finger vertical swipe → special workspace.
hl.gesture({ fingers = 3, direction = "horizontal", action = "workspace" })
hl.gesture({ fingers = 4, direction = "vertical",   action = "special" })
{{- end }}

{{- if (index $tags "touchscreen") }}
-- Map touchscreen + stylus to the internal display so input coords
-- don't stretch across external monitors when docked.
hl.config({
  input = {
    tablet = {
      output = "eDP-1",
      relative_input = false
    }
  }
})
hl.device({ name = "ipts-045e:001f-touchscreen",      output = "eDP-1" })
hl.device({ name = "iptsd-virtual-stylus-045e:001f",  output = "eDP-1" })
hl.device({ name = "iptsd-virtual-touchscreen-045e:001f", output = "eDP-1" })
{{- end }}
