Skip to content

Commit

Permalink
Merge pull request #155 from wrygiel/main
Browse files Browse the repository at this point in the history
Add `Controller.getHandle()`
  • Loading branch information
ceifa authored Aug 6, 2024
2 parents 5fd35d9 + fa5800d commit de7136e
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 de7136e

Please sign in to comment.