1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-02 17:27:23 -04:00
OpenDiablo2/d2common/d2interface/input_service.go
dk 60e6fcb7ac
moving enumerations out of d2interface (#552)
* moved filter constants back to d2enum

* moving key and mouse button enums into d2enum

* moving render type enum into d2enum

* moving input even priority enums into d2enum

* moving terminal enums into d2enum
2020-07-06 21:26:08 -04:00

26 lines
1.3 KiB
Go

package d2interface
import "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
// 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.
IsKeyPressed(key d2enum.Key) bool
// IsKeyJustPressed checks if the provided key is just transitioned from up to down.
IsKeyJustPressed(key d2enum.Key) bool
// IsKeyJustReleased checks if the provided key is just transitioned from down to up.
IsKeyJustReleased(key d2enum.Key) bool
// IsMouseButtonPressed checks if the provided mouse button is down.
IsMouseButtonPressed(button d2enum.MouseButton) bool
// IsMouseButtonJustPressed checks if the provided mouse button is just transitioned from up to down.
IsMouseButtonJustPressed(button d2enum.MouseButton) bool
// IsMouseButtonJustReleased checks if the provided mouse button is just transitioned from down to up.
IsMouseButtonJustReleased(button d2enum.MouseButton) bool
// KeyPressDuration returns how long the key is pressed in frames.
KeyPressDuration(key d2enum.Key) int
}