<?phpnamespace App\Vnc;use JumPHP\Gui\Pointer;/** X11 keysyms of the keys (what RFB's KeyEvent carries). */final class Keysym{ public const BACKSPACE = 0xff08; public const TAB = 0xff09; public const RETURN = 0xff0d; public const ESCAPE = 0xff1b; public const DELETE = 0xffff; public const HOME = 0xff50; public const LEFT = 0xff51; public const UP = 0xff52; public const RIGHT = 0xff53; public const DOWN = 0xff54; public const PAGEUP = 0xff55; public const PAGEDOWN = 0xff56; public const END = 0xff57; public const INSERT = 0xff63; public const F1 = 0xffbe; public const SHIFT = 0xffe1; public const CONTROL = 0xffe3; public const ALT = 0xffe9; /** SDL key code -> keysym, for the keys that type no character. */ public static function special(int $sdl): ?int { if ($sdl >= 1073741882 && $sdl <= 1073741893) { return self::F1 + ($sdl - 1073741882); // F1..F12 } return match ($sdl) { Pointer::BACKSPACE => self::BACKSPACE, Pointer::TAB => self::TAB, Pointer::RETURN, Pointer::KP_ENTER => self::RETURN, Pointer::ESCAPE => self::ESCAPE, Pointer::DELETE => self::DELETE, Pointer::HOME => self::HOME, Pointer::END => self::END, Pointer::LEFT => self::LEFT, Pointer::RIGHT => self::RIGHT, Pointer::UP => self::UP, Pointer::DOWN => self::DOWN, Pointer::PAGEUP => self::PAGEUP, Pointer::PAGEDOWN => self::PAGEDOWN, 1073741897 => self::INSERT, default => null, }; } /** A typed character -> keysym (Latin-1 as is, other letters 0x01000000 + their code point). */ public static function char(string $char): int { $code = mb_ord($char, 'UTF-8'); if ($code === false) { return 0; } return $code < 0x100 ? $code : 0x01000000 + $code; }}