Skip to content

Commit

Permalink
Add Controller.getHandle()
Browse files Browse the repository at this point in the history
  • Loading branch information
wrygiel committed Aug 2, 2024
1 parent 5fd35d9 commit fa5800d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export declare namespace input {
isDigitalActionPressed(actionHandle: bigint): boolean
getAnalogActionVector(actionHandle: bigint): AnalogActionVector
getType(): InputType
getHandle(): bigint
}
}
export declare namespace localplayer {
Expand Down
5 changes: 5 additions & 0 deletions src/api/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ pub mod input {
.get_input_type_for_handle(self.handle.get_u64().1)
.into()
}

#[napi]
pub fn get_handle(&self) -> BigInt {
self.handle.clone()
}
}

#[napi(object)]
Expand Down
1 change: 1 addition & 0 deletions test/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ setInterval(() => {
controller.activateActionSet(actionset)

console.log('============')
console.log('Handle: ' + controller.getHandle())
console.log('Affirm: ' + controller.isDigitalActionPressed(affirm))
console.log('Cancel: ' + controller.isDigitalActionPressed(cancel))
console.log('Control: ' + JSON.stringify(controller.getAnalogActionVector(control)))
Expand Down

0 comments on commit fa5800d

Please sign in to comment.