Gopher2600/userinput/events.go
JetSetIlly a4ed971a1b analogue thumbstick now controls stick, rather than paddle
the amount of travel in the analogue stick is just too small for it to
be useful for paddle control IMO.

triggers still control paddle but no longer self-centre. the center
position is different for different games. also, it makes some games too
easy.
2021-03-16 22:58:46 +00:00

152 lines
3.6 KiB
Go

// This file is part of Gopher2600.
//
// Gopher2600 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Gopher2600 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
package userinput
import "github.com/jetsetilly/gopher2600/hardware/riot/ports/plugging"
// Event represents all the different type of events that can occur in the GUI.
//
// Events are the things that happen in the GUI, as a result of user interaction,
// and sent over a registered event channel.
type Event interface{}
// EventQuit is sent, for example, when the GUI window is closed.
type EventQuit struct{}
// KeyMod identifies.
type KeyMod int
// list of valud key modifiers.
const (
KeyModNone KeyMod = iota
KeyModShift
KeyModCtrl
KeyModAlt
)
// EventKeyboard data is generated by the system keyboard.
type EventKeyboard struct {
Key string
Down bool
Mod KeyMod
}
// EventMouseMotion data is generated by the motion of the system mouse.
type EventMouseMotion struct {
// x and y values should be between -1.0 and 1.0
X float32
Y float32
}
// MouseButton identifies the mouse button.
type MouseButton int
// List of valid MouseButtonIDs.
const (
MouseButtonNone MouseButton = iota
MouseButtonLeft
MouseButtonRight
MouseButtonMiddle
)
// EventMouseButton data is generated by any of the system mouse buttons.
type EventMouseButton struct {
Button MouseButton
Down bool
}
// DPadDirection indentifies the direction the dpad is being pressed.
type DPadDirection int
// List of valid DPadDirection values.
const (
DPadNone DPadDirection = iota
DPadCentre
DPadUp
DPadDown
DPadLeft
DPadRight
DPadLeftUp
DPadLeftDown
DPadRightUp
DPadRightDown
)
// EventGamepadDpad data is generated by a game controller's DPad.
type EventGamepadDPad struct {
ID plugging.PortID
Direction DPadDirection
}
// GamepadButton identifies a gamepad button.
type GamepadButton int
// List of valid GamepadButtons.
const (
GamepadButtonNone GamepadButton = iota
GamepadButtonBack
GamepadButtonStart
GamepadButtonA
)
// EventGamepadButton data is generated by any of a game controller's buttons.
type EventGamepadButton struct {
ID plugging.PortID
Button GamepadButton
Down bool
}
// GamepadThumbstick identifies the gamepad thumbstick.
type GamepadThumbstick int
// List of GamepadAxis values.
const (
GamepadThumbstickLeft GamepadThumbstick = iota
GamepadThumbstickRight
)
// EventGamepadThumbstick data is generated by a gamepad's analogue sticks.
type EventGamepadThumbstick struct {
ID plugging.PortID
// the axis being moved
Thumbstick GamepadThumbstick
// value from hardware controller should use full range
Horiz int16
Vert int16
}
// GamepadTrigger identifies the gamepad triggers.
type GamepadTrigger int
// List of GamepadTrigger values.
const (
GamepadTriggerNone GamepadTrigger = iota
GamepadTriggerLeft
GamepadTriggerRight
)
// EventGamepadAnalogue data is generated by a gamepads analogue triggers.
type EventGamepadTrigger struct {
ID plugging.PortID
// the trigger being flexed
Trigger GamepadTrigger
// value from hardware controller should use full range
Amount int16
}