ridiculous refactor to allow enums to be dbus strings for better TS generation

This commit is contained in:
Luke D. Jones
2023-06-27 21:16:13 +12:00
parent fca7d23a31
commit 7b17a13ce7
43 changed files with 1516 additions and 267 deletions

53
bindings/ts/anime.ts Normal file
View File

@@ -0,0 +1,53 @@
/*
Generated by typeshare 1.6.0
*/
export enum AnimBooting {
GlitchConstruction = "GlitchConstruction",
StaticEmergence = "StaticEmergence",
}
export enum AnimAwake {
BinaryBannerScroll = "BinaryBannerScroll",
RogLogoGlitch = "RogLogoGlitch",
}
export enum AnimSleeping {
BannerSwipe = "BannerSwipe",
Starfield = "Starfield",
}
export enum AnimShutdown {
GlitchOut = "GlitchOut",
SeeYa = "SeeYa",
}
export interface Animations {
boot: AnimBooting;
awake: AnimAwake;
sleep: AnimSleeping;
shutdown: AnimShutdown;
}
/** Base LED brightness of the display */
export enum Brightness {
Off = "Off",
Low = "Low",
Med = "Med",
High = "High",
}
export interface DeviceState {
display_enabled: boolean;
display_brightness: Brightness;
builtin_anims_enabled: boolean;
builtin_anims: Animations;
}
export enum AnimeType {
GA401 = "GA401",
GA402 = "GA402",
GU604 = "GU604",
Unknown = "Unknown",
}

219
bindings/ts/aura.ts Normal file
View File

@@ -0,0 +1,219 @@
/*
Generated by typeshare 1.6.0
*/
/** Represents the per-key raw USB packets */
export type UsbPackets = number[][];
/**
* A `UsbPackets` contains all data to change the full set of keyboard
* key colours individually.
*
* Each row of the internal array is a full HID packet that can be sent
* to the keyboard EC. One row controls one group of keys, these keys are not
* necessarily all on the same row of the keyboard, with some splitting between
* two rows.
*/
export interface LedUsbPackets {
/** The packet data used to send data to the USB keyboard */
usb_packets: UsbPackets;
/**
* Wether or not this packet collection is zoned. The determines which
* starting bytes are used and what the indexing is for lightbar RGB
* colours
*/
zoned: boolean;
}
export interface Colour {
r: number;
g: number;
b: number;
}
/** Enum of modes that convert to the actual number required by a USB HID packet */
export enum AuraModeNum {
Static = "Static",
Breathe = "Breathe",
Strobe = "Strobe",
Rainbow = "Rainbow",
Star = "Star",
Rain = "Rain",
Highlight = "Highlight",
Laser = "Laser",
Ripple = "Ripple",
Pulse = "Pulse",
Comet = "Comet",
Flash = "Flash",
}
/** Base effects have no zoning, while multizone is 1-4 */
export enum AuraZone {
/** Used if keyboard has no zones, or if setting all */
None = "None",
/** Leftmost zone */
Key1 = "Key1",
/** Zone after leftmost */
Key2 = "Key2",
/** Zone second from right */
Key3 = "Key3",
/** Rightmost zone */
Key4 = "Key4",
/** Logo on the lid (or elsewhere?) */
Logo = "Logo",
/** The left part of a lightbar (typically on the front of laptop) */
BarLeft = "BarLeft",
/** The right part of a lightbar */
BarRight = "BarRight",
}
export enum Speed {
Low = "Low",
Med = "Med",
High = "High",
}
/**
* Used for Rainbow mode.
*
* Enum corresponds to the required integer value
*/
export enum Direction {
Right = "Right",
Left = "Left",
Up = "Up",
Down = "Down",
}
/**
* Default factory modes structure. This easily converts to an USB HID packet
* with:
* ```rust
* // let bytes: [u8; LED_MSG_LEN] = mode.into();
* ```
*/
export interface AuraEffect {
/** The effect type */
mode: AuraModeNum;
/** `AuraZone::None` for no zone or zoneless keyboards */
zone: AuraZone;
/** Primary colour for all modes */
colour1: Colour;
/** Secondary colour in some modes like Breathing or Stars */
colour2: Colour;
/** One of three speeds for modes that support speed (most that animate) */
speed: Speed;
/** Up, down, left, right. Only Rainbow mode seems to use this */
direction: Direction;
}
export enum AuraDevTuf {
Boot = "Boot",
Awake = "Awake",
Sleep = "Sleep",
Keyboard = "Keyboard",
}
/**
* # Bits for older 0x1866, 0x1869, 0x1854 keyboard models
*
* Keybord and Lightbar require Awake, Boot and Sleep apply to both
* Keybord and Lightbar regardless of if either are enabled (or Awake is
* enabled)
*
* | Byte 1 | Byte 2 | Byte 3 | Byte 4 | function | hex
* |
* |------------|------------|------------|------------|-----------|-------------|
* | 0000, 0000 | 0000, 0000 | 0000, 0010 | 0000, 0000 | Awake |
* 00,00,02,00 | | 0000, 1000 | 0000, 0000 | 0000, 0000 | 0000, 0000 | Keyboard
* | 08,00,00,00 | | 0000, 0100 | 0000, 0101 | 0000, 0000 | 0000, 0000 |
* Lightbar | 04,05,00,00 | | 1100, 0011 | 0001, 0010 | 0000, 1001 | 0000,
* 0000 | Boot/Sht | c3,12,09,00 | | 0011, 0000 | 0000, 1000 | 0000, 0100 |
* 0000, 0000 | Sleep | 30,08,04,00 | | 1111, 1111 | 0001, 1111 | 0000,
* 1111 | 0000, 0000 | all on | | | 0000, 0000 | 0000, 0000 |
* 0000, 0000 | 0000, 0010 | Rear Glow | 00,00,00,02 |
*/
export enum AuraDevRog1 {
Awake = "Awake",
Keyboard = "Keyboard",
Lightbar = "Lightbar",
Boot = "Boot",
Sleep = "Sleep",
}
/**
* # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models
*
* byte 4 in the USB packet is for keyboard + logo power states
* default is on, `ff`
* Keyboard and logo use the full range of bits (almost)
*
* | n1 | n2 | hex | action | bit |
* |------|------|-----|-----------------------|-------|
* | 0000 | 0000 | 00 | all off | |
* | 0000 | 0001 | 01 | logo boot | bit 1 |
* | 0000 | 0010 | 02 | keyboard boot | bit 2 |
* | 0000 | 0100 | 04 | logo awake | bit 3 |
* | 0000 | 1000 | 08 | keyboard awake | bit 4 |
* | 0001 | 0000 | 10 | logo sleep off | bit 5 |
* | 0010 | 0000 | 20 | keyboard sleep | bit 6 |
* | 0100 | 0000 | 40 | logo shutdown off | bit 7 |
* | 1000 | 0000 | 80 | keyboard shutdown off | bit 8 |
*
* byte 5 = lightbar
*
* | 1 | 2 | hex | action | bit |
* |------|------|-----|----------------------|-------|
* | 0000 | 0010 | 02 | lightbar off boot | bit 2 |
* | 0000 | 0100 | 04 | lightbar on | bit 3 |
* | 0000 | 1000 | 08 | lightbar off sleep | bit 4 |
* | 0001 | 0000 | 10 | lightbar shtdn off | bit 5 |
*/
export enum AuraDevRog2 {
BootLogo = "BootLogo",
BootKeyb = "BootKeyb",
AwakeLogo = "AwakeLogo",
AwakeKeyb = "AwakeKeyb",
SleepLogo = "SleepLogo",
SleepKeyb = "SleepKeyb",
ShutdownLogo = "ShutdownLogo",
ShutdownKeyb = "ShutdownKeyb",
BootBar = "BootBar",
AwakeBar = "AwakeBar",
SleepBar = "SleepBar",
ShutdownBar = "ShutdownBar",
BootLid = "BootLid",
AwakeLid = "AwakeLid",
SleepLid = "SleepLid",
ShutdownLid = "ShutdownLid",
BootRearGlow = "BootRearGlow",
AwakeRearGlow = "AwakeRearGlow",
SleepRearGlow = "SleepRearGlow",
ShutdownRearGlow = "ShutdownRearGlow",
}
/** This struct is intended as a helper to pass args to generic dbus interface */
export interface AuraPowerDev {
tuf: AuraDevTuf[];
x1866: AuraDevRog1[];
x19b6: AuraDevRog2[];
}
export enum LedBrightness {
Off = "Off",
Low = "Low",
Med = "Med",
High = "High",
}
export enum AuraDevice {
Tuf = "Tuf",
X1854 = "X1854",
X1869 = "X1869",
X1866 = "X1866",
X18c6 = "X18c6",
X19b6 = "X19b6",
X1a30 = "X1a30",
Unknown = "Unknown",
}

57
bindings/ts/platform.ts Normal file
View File

@@ -0,0 +1,57 @@
/*
Generated by typeshare 1.6.0
*/
export type AnimeSupportedFunctions = boolean;
export interface ChargeSupportedFunctions {
charge_level_set: boolean;
}
export interface PlatformProfileFunctions {
platform_profile: boolean;
fan_curves: boolean;
}
export enum AdvancedAura {
None = "None",
Zoned = "Zoned",
PerKey = "PerKey",
}
export interface LedSupportedFunctions {
dev_id: AuraDevice;
brightness: boolean;
basic_modes: AuraModeNum[];
basic_zones: AuraZone[];
advanced_type: AdvancedAura;
}
export interface RogBiosSupportedFunctions {
post_sound: boolean;
gpu_mux: boolean;
panel_overdrive: boolean;
dgpu_disable: boolean;
egpu_enable: boolean;
mini_led_mode: boolean;
}
export interface SupportedFunctions {
anime_ctrl: AnimeSupportedFunctions;
charge_ctrl: ChargeSupportedFunctions;
platform_profile: PlatformProfileFunctions;
keyboard_led: LedSupportedFunctions;
rog_bios_ctrl: RogBiosSupportedFunctions;
}
export enum GpuMode {
Discrete = "Discrete",
Optimus = "Optimus",
Integrated = "Integrated",
Egpu = "Egpu",
Vfio = "Vfio",
Ultimate = "Ultimate",
Error = "Error",
NotSupported = "NotSupported",
}

35
bindings/ts/profiles.ts Normal file
View File

@@ -0,0 +1,35 @@
/*
Generated by typeshare 1.6.0
*/
export enum FanCurvePU {
CPU = "CPU",
GPU = "GPU",
}
export interface CurveData {
fan: FanCurvePU;
pwm: [number, number, number, number, number, number, number, number];
temp: [number, number, number, number, number, number, number, number];
}
/** A `FanCurveSet` contains both CPU and GPU fan curve data */
export interface FanCurveSet {
enabled: boolean;
cpu: CurveData;
gpu: CurveData;
}
/** Main purpose of `FanCurves` is to enable restoring state on system boot */
export interface FanCurveProfiles {
balanced: FanCurveSet;
performance: FanCurveSet;
quiet: FanCurveSet;
}
export enum Profile {
Balanced = "Balanced",
Performance = "Performance",
Quiet = "Quiet",
}