Export named constants for InputPlatform values
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- game-dev
Research direction
Start by locating the exported INPUT_PLATFORMS record and getInputPlatform implementation, then inspect nearby tests or consumers for the existing InputPlatform values. Add the named frozen record with Gamepad, Keyboard, and Touch values while preserving the literal union and exhaustiveness behavior; done means consumers can reference the named values without changing their accepted strings.
Written by the indexing model from the issue text.
Description
Motivation
getInputPlatform() (#130) returns a bare string union, so every consumer switch reads as string literals:
switch (getInputPlatform()) {
case "gamepad": { ... }
case "keyboard": { ... }
case "touch": { ... }
}
Before #130 the same switch read Enum.PreferredInput.Gamepad, which named itself. The literals type-check exactly as well, but they lose the "where does this vocabulary come from" signal at the call site, and they read as magic strings to anyone who has not met InputPlatform.
Proposal
Export a frozen const record next to INPUT_PLATFORMS:
export const InputPlatforms = table.freeze({
Gamepad: "gamepad",
Keyboard: "keyboard",
Touch: "touch",
}) satisfies Record<string, InputPlatform>;
Consumers then write case InputPlatforms.Gamepad: and keep exhaustiveness checking, because the values are still the literal union.
Not proposed: compatibility with Enum.PreferredInput
Worth writing down so it stops being re-asked. It cannot be done:
Enumitems are engine userdata. A Luau library cannot construct one, so no exported value can be===toEnum.PreferredInput.Gamepad.- The member sets do not line up anyway.
InputPlatformhas"keyboard";Enum.PreferredInputhasKeyboardAndMouse. The mapping is 1:1 today by coincidence of member count, not by name.
A named const record is the closest available shape, and it is what the engine Enum was providing at the call site in the first place.
Notes
- Related: #130 (introduced
getInputPlatform), #199 (platform classification).
- Dominant language
- TypeScript
- Stars
- 11
- Forks
- 1
- Avg merge
- 11h 36m
- Merged PRs (30d)
- 29
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from christopher-buss/flux
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 55/100
christopher-buss/flux#317 ·
-
enhancement react
Difficulty 5/5 Over a week Newbie friendliness 35/100
christopher-buss/flux#268 ·
-
enhancement jecs react
Difficulty 5/5 Over a week Newbie friendliness 45/100
christopher-buss/flux#262 ·
-
core question wayfinder:research
Difficulty 5/5 Over a week Newbie friendliness 35/100
christopher-buss/flux#212 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
christopher-buss/flux#198 ·
All issues in christopher-buss/flux
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100