2020-07-03 15:09:16 -04:00
|
|
|
package d2interface
|
2020-07-01 14:03:40 -04:00
|
|
|
|
2020-07-06 21:26:08 -04:00
|
|
|
import "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
|
|
|
|
2020-07-01 14:03:40 -04:00
|
|
|
// InputService represents an interface offering Keyboard and Mouse interactions.
|
|
|
|
type InputService interface {
|
|
|
|
// CursorPosition returns a position of a mouse cursor relative to the game screen (window).
|
|
|
|
CursorPosition() (x int, y int)
|
|
|
|
// InputChars return "printable" runes read from the keyboard at the time update is called.
|
|
|
|
InputChars() []rune
|
|
|
|
// IsKeyPressed checks if the provided key is down.
|
2020-07-06 21:26:08 -04:00
|
|
|
IsKeyPressed(key d2enum.Key) bool
|
2020-07-01 14:03:40 -04:00
|
|
|
// IsKeyJustPressed checks if the provided key is just transitioned from up to down.
|
2020-07-06 21:26:08 -04:00
|
|
|
IsKeyJustPressed(key d2enum.Key) bool
|
2020-07-01 14:03:40 -04:00
|
|
|
// IsKeyJustReleased checks if the provided key is just transitioned from down to up.
|
2020-07-06 21:26:08 -04:00
|
|
|
IsKeyJustReleased(key d2enum.Key) bool
|
2020-07-01 14:03:40 -04:00
|
|
|
// IsMouseButtonPressed checks if the provided mouse button is down.
|
2020-07-06 21:26:08 -04:00
|
|
|
IsMouseButtonPressed(button d2enum.MouseButton) bool
|
2020-07-01 14:03:40 -04:00
|
|
|
// IsMouseButtonJustPressed checks if the provided mouse button is just transitioned from up to down.
|
2020-07-06 21:26:08 -04:00
|
|
|
IsMouseButtonJustPressed(button d2enum.MouseButton) bool
|
2020-07-01 14:03:40 -04:00
|
|
|
// IsMouseButtonJustReleased checks if the provided mouse button is just transitioned from down to up.
|
2020-07-06 21:26:08 -04:00
|
|
|
IsMouseButtonJustReleased(button d2enum.MouseButton) bool
|
2020-07-01 14:03:40 -04:00
|
|
|
// KeyPressDuration returns how long the key is pressed in frames.
|
2020-07-06 21:26:08 -04:00
|
|
|
KeyPressDuration(key d2enum.Key) int
|
2020-07-01 14:03:40 -04:00
|
|
|
}
|