wavelength 1.0.0
Loading...
Searching...
No Matches
joypadinputmsg.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4
5#include "msg/message.h"
6#include "os/mem.h"
7#include "os/prnstream.h"
8
15extern int g_nJoypadInputMsgType;
16
23class JoypadInputMsg : public Message {
24public:
31 ~JoypadInputMsg() override = default;
32
42 JoypadInputMsg(int nPad, int nButton, int nPressed)
43 : mPad(nPad), mButton(nButton), mPressed(nPressed) {
44 }
45
52 void *operator new(size_t nSize) {
53 return PoolMemAlloc(static_cast<int>(nSize), "JoypadInputMsg", 0);
54 }
55
61 void operator delete(void *pBlock) {
62 PoolMemFree(pBlock);
63 }
64
72 Message *Clone() override {
73 return new JoypadInputMsg(*this);
74 }
75
83 int Type() override {
85 }
86
94 const char *GetName() const override {
95 return "JoypadInputMsg";
96 }
97
105 void PrintExtra(PrnStream &stream) const override;
106
108 int GetButton() const {
109 return mButton;
110 }
111
113 int GetPad() const {
114 return mPad;
115 }
116
118 int GetPressed() const {
119 return mPressed;
120 }
121
122private:
123 int mPad;
124 int mButton;
125 int mPressed;
126};
Message * Clone() override
Produce a heap copy of this message.
Definition joypadinputmsg.h:72
const char * GetName() const override
Report this message's class name.
Definition joypadinputmsg.h:94
int GetPressed() const
Definition joypadinputmsg.h:118
int Type() override
Report this message's registered identity.
Definition joypadinputmsg.h:83
void PrintExtra(PrnStream &stream) const override
Write the controller, the button, and whether it went down.
JoypadInputMsg(int nPad, int nButton, int nPressed)
Construct the message of a button.
Definition joypadinputmsg.h:42
int GetPad() const
Definition joypadinputmsg.h:113
~JoypadInputMsg() override=default
Destroy the object.
int GetButton() const
Definition joypadinputmsg.h:108
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Text output stream.
Definition prnstream.h:16
int g_nJoypadInputMsgType
Identity that JoypadInputMsg::Type() reports.
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.