wavelength 1.0.0
Loading...
Searching...
No Matches
joypad.h
Go to the documentation of this file.
1#pragma once
2
3#include "app/msgsink.h"
4
6constexpr int kJoypadNumSticks = 2;
7
9constexpr int kJoypadNumButtons = 24;
10
12constexpr int kJoypadNumPorts = 8;
13
15constexpr int kJoypadNumPads = 4;
16
18constexpr int kJoypadNoPad = -1;
19
52
59 float mX;
60 float mY;
61};
62
69public:
79
91 void AddStickButtons(int *pButtons, bool bMenu);
92
94 const JoypadStick *GetSticks() const {
95 return mSticks;
96 }
97
99 const float *GetPressures() const {
100 return mPressures;
101 }
102
110 void SetStick(int nStick, float fX, float fY) {
111 mSticks[nStick].mX = fX;
112 mSticks[nStick].mY = fY;
113 }
114
121 void SetPressure(int nButton, float fPressure) {
122 mPressures[nButton] = fPressure;
123 }
124
126 int GetButtons() const {
127 return mButtons;
128 }
129
131 void SetButtons(int nButtons) {
132 mButtons = nButtons;
133 }
134
136 int GetPad() const {
137 return mPad;
138 }
139
141 void SetPad(int nPad) {
142 mPad = nPad;
143 }
144
146 int GetConnected() const {
147 return mConnected;
148 }
149
151 void SetConnected(int nConnected) {
152 mConnected = nConnected;
153 }
154
156 void SetThreshold(float fThreshold) {
157 mThreshold = fThreshold;
158 }
159
160private:
161 int mButtons;
163 float mPressures[kJoypadNumButtons];
164 int mPad;
165 int mConnected;
166 float mThreshold;
167};
168
179
189
201
212
222
231
240
251void JoypadSetStickMessages(bool bEnable);
252
265void JoypadSetMenuControl(int nPad, bool bMenu);
266
278void JoypadSetVibration(int nPad, int nSmallMotor, int nBigMotor);
279
292void JoypadMapDefault(bool bPort0Multitap, bool bPort1Multitap);
293
State of one controller port as the last poll read it.
Definition joypad.h:68
void SetThreshold(float fThreshold)
Definition joypad.h:156
void SetButtons(int nButtons)
Definition joypad.h:131
void SetStick(int nStick, float fX, float fY)
Set the position of a stick.
Definition joypad.h:110
void SetPad(int nPad)
Definition joypad.h:141
int GetButtons() const
Definition joypad.h:126
const JoypadStick * GetSticks() const
Definition joypad.h:94
void AddStickButtons(int *pButtons, bool bMenu)
Set the bits of the stick directions pushed past mThreshold.
const float * GetPressures() const
Definition joypad.h:99
int GetPad() const
Definition joypad.h:136
JoypadState()
Clear the buttons, the sticks, and the pressures, and give the port no pad.
void SetPressure(int nButton, float fPressure)
Set the pressure of a button.
Definition joypad.h:121
void SetConnected(int nConnected)
Definition joypad.h:151
int GetConnected() const
Definition joypad.h:146
Receiver of engine messages.
Definition msgsink.h:21
void JoypadSetStickMessages(bool bEnable)
Turn the analog stick messages of the controller poll on or off.
constexpr int kJoypadNumPorts
The number of controllers the poll reads, four multitap slots on each of two ports.
Definition joypad.h:12
void JoypadSetVibration(int nPad, int nSmallMotor, int nBigMotor)
Drive the vibration motors of the controller on a port.
void JoypadPoll()
Read every controller port that serves a pad, and send messages for what changed.
void JoypadMapDefault(bool bPort0Multitap, bool bPort1Multitap)
Give the controller ports to the pads.
void JoypadSetMenuControl(int nPad, bool bMenu)
Give the input of a controller to the menus or to the running world.
constexpr int kJoypadNumPads
The number of players the controllers can be given to.
Definition joypad.h:15
constexpr int kJoypadNoPad
The pad a port stores while no player uses it.
Definition joypad.h:18
void JoypadRemoveSink(MsgSink *pSink)
Remove a sink from the receivers of the controller messages.
void JoypadTerminate()
Shut the controller layer down.
void JoypadInit()
Open every controller port and give the first port to pad 0.
constexpr int kJoypadNumSticks
The number of analogue sticks of a controller.
Definition joypad.h:6
void JoypadAddSink(MsgSink *pSink)
Add a sink to the receivers of the controller messages.
JoypadButton
Buttons of a controller, the values JoypadInputMsg::mButton takes.
Definition joypad.h:25
@ kPadDLeft
Definition joypad.h:41
@ kPadSelect
Definition joypad.h:34
@ kPadNone
Definition joypad.h:50
@ kPadLeftStickUp
Definition joypad.h:42
@ kPadTriangle
Definition joypad.h:30
@ kPadRightStickRight
Definition joypad.h:47
@ kPadL2
Definition joypad.h:26
@ kPadLeftStickLeft
Definition joypad.h:45
@ kPadRightStickLeft
Definition joypad.h:49
@ kPadDRight
Definition joypad.h:39
@ kPadDDown
Definition joypad.h:40
@ kPadLeftStickDown
Definition joypad.h:44
@ kPadRightStickUp
Definition joypad.h:46
@ kPadDUp
Definition joypad.h:38
@ kPadStart
Definition joypad.h:37
@ kPadR3
Definition joypad.h:36
@ kPadL1
Definition joypad.h:28
@ kPadCross
Definition joypad.h:32
@ kPadCircle
Definition joypad.h:31
@ kPadL3
Definition joypad.h:35
@ kPadLeftStickRight
Definition joypad.h:43
@ kPadR2
Definition joypad.h:27
@ kPadR1
Definition joypad.h:29
@ kPadRightStickDown
Definition joypad.h:48
@ kPadSquare
Definition joypad.h:33
JoypadState * JoypadGetState(int nPad)
Report the state of a controller.
constexpr int kJoypadNumButtons
The number of buttons of a controller, counting the stick directions.
Definition joypad.h:9
int JoypadMultitapConnected()
Report whether a multitap is connected, as the controller poll last found.
int JoypadWait()
Wait for pad 0 to release every button and then press one.
Position of one analogue stick.
Definition joypad.h:58
float mY
Definition joypad.h:60
float mX
Definition joypad.h:59