resonance 1.0.1
Loading...
Searching...
No Matches
inputpoller.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <vector>
5
6class JoypadPS2;
7class KeyboardMgr;
8class RawController;
9
33public:
39
44 virtual ~InputPoller();
45
58 void SetVibration(int nPort, int nSmallMotor, int nBigMotor);
59
70 void SetController(RawController *pController);
71
82 void SetActive(int bActive);
83
93 void SetPaused(int bPaused);
94
105 void DetachController(RawController *pController);
106
116 void Poll();
117
128 void SetGameInputEnabled(int bEnabled) {
129 mGameInputEnabled = bEnabled;
130 }
131
141 mUnusedFlag = 1;
142 }
143
154 mUnusedFlag = 0;
155 }
156
166 void EmptyStubA() {
167 }
168
177 void EmptyStubB() {
178 }
179
190 return mBusyJoypadSeen;
191 }
192
204 return mPressedThisPoll;
205 }
206
207#ifdef VIDEO_STANDARD_PAL
217 int GetMultitap0() {
218 return mMultitap0;
219 }
220
228 static void EndPadLibrary();
229#endif
230
231private:
241 void Init();
242
254 void Setup();
255
265 void Shutdown();
266
278 void FindJoypadConnections();
279
294 void ReadControllers();
295
302 void FinishPoll();
303
313 void ResetJoypads();
314
324 void NumberConnectedJoypads();
325
326 // The controls, in the order of the mask table the control numbers index.
327 static constexpr int kControlCount = 16;
328
329 // Bytes of stick position per reading, one per axis.
330 static constexpr int kAxisCount = 4;
331
332 // One record per JoypadPS2, the last reading it sent. The class emits no RTTI, has no
333 // constructor or destructor, and is copied into the vector byte for byte. Its name is lost.
334 struct Entry {
335 int mControlStates[kControlCount]; // +0x00, zeroed by Setup() and never read
336 char mAxes[kAxisCount]; // +0x40
337 unsigned int mButtons; // +0x44
338 // Set while a d-pad direction's press has gone out, cleared once all four are up.
339 int mDirectionHeld; // +0x48
340 };
341
342 std::vector<Entry> mEntries; // +0x00
343 std::vector<int> mJoypadPlayers; // +0x0c, the player of each JoypadPS2 from 1, or 0 for none
344 int mNextJoypadId; // +0x18
345 std::vector<JoypadPS2 *> mJoypads; // +0x1c
346 // Set from KeyboardMgr::shared() and never read again.
347 KeyboardMgr *mBytePairs; // +0x28
348 // Built by the constructor and destroyed by the destructor, with no other use.
349 std::list<int> mUnusedList; // +0x2c element type not recovered, 16-byte node
350 // Zeroed by the constructor and never read.
351 int mUnusedWord; // +0x30
352 // Starts at 1. SetUnusedFlag() and ClearUnusedFlag() are the only recovered writers, and the
353 // image has no reader.
354 int mUnusedFlag; // +0x34
355
356public:
365
366private:
367 int mActive; // +0x3c starts at 1
368 int mMultitap0; // +0x40, a multitap is on port 0
369 int mMultitap1; // +0x44, a multitap is on port 1
370 // Set by SetPaused() and by ReadControllers() when it pauses the game.
371 int mPaused; // +0x48
372 // Starts at 1. The reading routine at 0x001dfab0 tests it at 0x001dfb7c before it hands a
373 // reading to a game world. +0x4c
374 int mGameInputEnabled;
375 int mBusyJoypadSeen; // +0x50, set when a JoypadPS2's read reports 1
376 // The receiver of the readings, which SetController() installs.
377 RawController *mController; // +0x54
378};
void EmptyStubB()
Do nothing.
Definition inputpoller.h:177
void EmptyStubA()
Do nothing.
Definition inputpoller.h:166
void ClearUnusedFlag()
Clear mUnusedFlag.
Definition inputpoller.h:153
void Poll()
Read the controllers once.
void SetGameInputEnabled(int bEnabled)
Set mGameInputEnabled.
Definition inputpoller.h:128
int mPressedThisPoll
Non-zero when the last Poll() sent a reading out.
Definition inputpoller.h:364
virtual ~InputPoller()
void SetController(RawController *pController)
Set the controller the readings go to.
void SetUnusedFlag()
Set mUnusedFlag to 1, the value the constructor starts it at.
Definition inputpoller.h:140
void DetachController(RawController *pController)
Clear the controller the readings go to, if it is pController.
int GetBusyJoypadSeen()
Report mBusyJoypadSeen.
Definition inputpoller.h:189
int GetPressedThisPoll()
Report whether the last Poll() sent a reading out.
Definition inputpoller.h:203
void SetVibration(int nPort, int nSmallMotor, int nBigMotor)
Drive the vibration motors of the controller on one port.
void SetActive(int bActive)
Set the word at +0x3c, which the constructor starts at 1.
void SetPaused(int bPaused)
Set the paused flag.
Handle to one of the eight pad slots, two ports of four multitap slots each.
Definition joypadps2.h:15
Two-byte object with one shared instance, reached through shared().
Definition keyboardmgr.h:18
Base of every object that reads a controller directly.
Definition rawcontroller.h:19