Files
DeeJanuz--frametop/screens/keyboard.h
T
DeeJanuzandClaude Opus 5.5 5714978e65 Add a keyboard for text fields on the desktop
Fixes #7: SteamVR's keyboard never came up for the desktop's apps, and
opening it for our panels doesn't work well on the Frame (it's Steam's own
panel, mounted in the dashboard's scene, it follows the laser between
panels, and it takes the controllers over to SteamVR's laser).

- KWin starts input/ft-textinput as the desktop's input method. It tells
  the input relay when a text field gains or loses focus, and the relay
  asks ft-screens to open or close the keyboard. The session drops the
  QT_IM_MODULE=xim and GTK_IM_MODULE=xim that the gamescope session sets,
  or Qt and GTK apps never report text fields.
- The keyboard is ft-screens' own panel (screens/keyboard.cpp): a US laptop
  layout, typed with a controller's laser or the 3D mouse. It opens 0.7 m
  in front of you, below your eyes and facing you. It has a grab bar to
  move it, a Close key, latching Shift, Ctrl and Alt, and repeat on a held
  key. It's drawn into shared DMA-BUFs, so it doesn't flicker. Its keys
  reach the focused screen as key presses, so every app takes them.
- It steps aside while the Steam menu or Steam's own keyboard is up and
  comes back after. A layout reset closes it, and it doesn't open without
  a head pose.
- Frametop Input Settings has a Keyboard page: open it for every text
  field, only while no keyboard is connected (the default), only from a
  mapped button (the new Open/close keyboard action, for mice and
  controllers), or never. A switch keeps it open until you close it.
- The pointer helper treats every frametop.* overlay as a real panel. The
  keyboard's shared texture reports 0x0 like SteamVR's scene-graph
  controls, and the helper had given it their wide catch radius.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 13:41:47 -06:00

34 lines
1.1 KiB
C++

// Frametop's keyboard (keyboard.cpp): a panel of keys that ft-screens shows for a text
// field on the desktop. Any laser or the 3D mouse types on it, as on the screens.
#pragma once
#include <openvr.h>
#include <cstdint>
namespace keyboard {
// What happened on the panel since the last Poll.
struct Event {
enum Type { Key, Closed } type;
uint32_t code; // Key: linux KEY_*
bool pressed; // Key: down or up
};
// Show the panel at `pose` (standing universe; its front faces +z), creating it the first
// time. False if SteamVR won't make the overlay.
bool Show(const vr::HmdMatrix34_t &pose);
void Hide();
bool Shown();
// Where it is now (it can be carried by its grab bar).
const vr::HmdMatrix34_t &Pose();
// A button came up on `device` somewhere else: stop carrying the panel if it was.
void EndDragBy(uint32_t device);
// Controllers' lasers work the panel with the dashboard closed, like the screens'.
void SetLasers(bool on);
// The panel's input: key presses and releases, and Closed for its Close key.
void Poll(void (*handle)(const Event &, void *), void *data);
void Destroy();
} // namespace keyboard