mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Add docs for gamepad API (I checked it worked on Chrome)
This commit is contained in:
parent
8987f7a645
commit
02dbeef1b9
@ -76,6 +76,14 @@ pre {
|
||||
<p>NOTE: <code>file://</code> URL may not work with Ebiten. Execute your game on a HTTP server.</p>
|
||||
|
||||
<h2>Change Log</h2>
|
||||
<h3>2015-??-??</h3>
|
||||
<ul>
|
||||
<li>v1.2.0-rc1 released.
|
||||
<ul>
|
||||
<li>Support for gamepads</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<h3>2015-01-10</h3>
|
||||
<ul>
|
||||
<li>v1.1.0-rc1 released.
|
||||
|
@ -36,20 +36,34 @@ func IsMouseButtonPressed(mouseButton MouseButton) bool {
|
||||
return ui.IsMouseButtonPressed(ui.MouseButton(mouseButton))
|
||||
}
|
||||
|
||||
// TODO: docs
|
||||
|
||||
// GamepadAxisNum returns the number of axes of the gamepad.
|
||||
//
|
||||
// NOTE: Gamepad API is available only on desktops, Chrome and Firefox.
|
||||
// To use this API, browsers might require rebooting the browser.
|
||||
func GamepadAxisNum(id int) int {
|
||||
return ui.GamepadAxisNum(id)
|
||||
}
|
||||
|
||||
// GamepadAxis returns the float value [-1.0 - 1.0] of the axis.
|
||||
//
|
||||
// NOTE: Gamepad API is available only on desktops, Chrome and Firefox.
|
||||
// To use this API, browsers might require rebooting the browser.
|
||||
func GamepadAxis(id int, axis int) float64 {
|
||||
return ui.GamepadAxis(id, axis)
|
||||
}
|
||||
|
||||
// GamepadButtonNum returns the number of the buttons of the gamepad.
|
||||
//
|
||||
// NOTE: Gamepad API is available only on desktops, Chrome and Firefox.
|
||||
// To use this API, browsers might require rebooting the browser.
|
||||
func GamepadButtonNum(id int) int {
|
||||
return ui.GamepadButtonNum(id)
|
||||
}
|
||||
|
||||
// IsGamepadButtonPressed returns the boolean indicating the buttons is pressed or not.
|
||||
//
|
||||
// NOTE: Gamepad API is available only on desktops, Chrome and Firefox.
|
||||
// To use this API, browsers might require rebooting the browser.
|
||||
func IsGamepadButtonPressed(id int, button GamepadButton) bool {
|
||||
return ui.IsGamepadButtonPressed(id, ui.GamepadButton(button))
|
||||
}
|
||||
|
@ -65,7 +65,11 @@ func (i *input) mouseMove(x, y int) {
|
||||
}
|
||||
|
||||
func (i *input) updateGamepads() {
|
||||
gamepads := js.Global.Get("navigator").Call("getGamepads")
|
||||
nav := js.Global.Get("navigator")
|
||||
if nav.Get("getGamepads") == js.Undefined {
|
||||
return
|
||||
}
|
||||
gamepads := nav.Call("getGamepads")
|
||||
l := gamepads.Get("length").Int()
|
||||
for id := 0; id < l; id++ {
|
||||
gamepad := gamepads.Index(id)
|
||||
|
@ -158,10 +158,6 @@ func init() {
|
||||
|
||||
// Gamepad
|
||||
window.Call("addEventListener", "gamepadconnected", func(e js.Object) {
|
||||
print(e)
|
||||
})
|
||||
window.Call("addEventListener", "gamepaddisconnected", func(e js.Object) {
|
||||
print(e)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user