[oden] I can make this actually MATCH

This commit is contained in:
John Doty 2023-07-07 07:34:09 -07:00
parent e0878b4ea6
commit 9d04541875
3 changed files with 13 additions and 4 deletions

View file

@ -202,10 +202,10 @@ export const Key = {
// NOTE: This must match the definition in input.rs.
export const Button = {
Up: 0,
Down: 1,
Left: 2,
Right: 3,
Up: core.BUTTON_UP,
Down: core.BUTTON_DOWN,
Left: core.BUTTON_LEFT,
Right: core.BUTTON_RIGHT,
} as const;
type Button = (typeof Button)[keyof typeof Button];

View file

@ -122,6 +122,10 @@ impl InputAPI {
ctx.new_fn(move |_ctx: &ContextRef, b: u32| input.btn(b))?,
)?;
}
builder.export("BUTTON_UP", ctx.new_u32(Button::Up)?)?;
builder.export("BUTTON_DOWN", ctx.new_u32(Button::Down)?)?;
builder.export("BUTTON_LEFT", ctx.new_u32(Button::Left)?)?;
builder.export("BUTTON_RIGHT", ctx.new_u32(Button::Right)?)?;
builder.build("input-core")?;
Ok(InputAPI { input })
}

View file

@ -1,3 +1,8 @@
// These are the functions exposed by the native input module.
//
export const BUTTON_UP: number;
export const BUTTON_DOWN: number;
export const BUTTON_LEFT: number;
export const BUTTON_RIGHT: number;
export function btn(b: number): boolean;