Skip to content

Commit

Permalink
Clean up SEvent initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
grorp committed Oct 25, 2024
1 parent 3f306a4 commit 820cf0d
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 59 deletions.
5 changes: 0 additions & 5 deletions irr/include/IEventReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,6 @@ struct SEvent
struct SUserEvent UserEvent;
struct SApplicationEvent ApplicationEvent;
};

SEvent() {
// would be left uninitialized in many places otherwise
MouseInput.Simulated = false;
}
};

//! Interface of an object which can receive events.
Expand Down
4 changes: 2 additions & 2 deletions irr/src/CGUIButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ bool CGUIButton::OnEvent(const SEvent &event)
ClickShiftState = event.KeyInput.Shift;
ClickControlState = event.KeyInput.Control;

SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand Down Expand Up @@ -179,7 +179,7 @@ bool CGUIButton::OnEvent(const SEvent &event)
ClickShiftState = event.MouseInput.Shift;
ClickControlState = event.MouseInput.Control;

SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand Down
4 changes: 2 additions & 2 deletions irr/src/CGUICheckBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool CGUICheckBox::OnEvent(const SEvent &event)
(event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) {
Pressed = false;
if (Parent) {
SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand Down Expand Up @@ -77,7 +77,7 @@ bool CGUICheckBox::OnEvent(const SEvent &event)
return true;
}

SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand Down
4 changes: 2 additions & 2 deletions irr/src/CGUIComboBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ bool CGUIComboBox::OnEvent(const SEvent &event)
void CGUIComboBox::sendSelectionChangedEvent()
{
if (Parent) {
SEvent event;
SEvent event{};

event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
Expand Down Expand Up @@ -411,7 +411,7 @@ void CGUIComboBox::openCloseMenu()
ListBox = nullptr;
} else {
if (Parent) {
SEvent event;
SEvent event{};
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.Element = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion irr/src/CGUIEditBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ void CGUIEditBox::setTextMarkers(s32 begin, s32 end)
void CGUIEditBox::sendGuiEvent(EGUI_EVENT_TYPE type)
{
if (Parent) {
SEvent e;
SEvent e{};
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
Expand Down
8 changes: 4 additions & 4 deletions irr/src/CGUIEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ bool CGUIEnvironment::setFocus(IGUIElement *element)
if (Focus) {
currentFocus = Focus;
currentFocus->grab();
SEvent e;
SEvent e{};
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = Focus;
e.GUIEvent.Element = element;
Expand All @@ -217,7 +217,7 @@ bool CGUIEnvironment::setFocus(IGUIElement *element)
currentFocus->grab();

// send focused event
SEvent e;
SEvent e{};
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = element;
e.GUIEvent.Element = Focus;
Expand Down Expand Up @@ -259,7 +259,7 @@ IGUIElement *CGUIEnvironment::getHovered() const
bool CGUIEnvironment::removeFocus(IGUIElement *element)
{
if (Focus && Focus == element) {
SEvent e;
SEvent e{};
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = Focus;
e.GUIEvent.Element = 0;
Expand Down Expand Up @@ -452,7 +452,7 @@ void CGUIEnvironment::updateHoveredElement(core::position2d<s32> mousePos)
HoveredNoSubelement->grab();

if (Hovered != lastHovered) {
SEvent event;
SEvent event{};
event.EventType = EET_GUI_EVENT;

if (lastHovered) {
Expand Down
4 changes: 2 additions & 2 deletions irr/src/CGUIFileOpenDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void CGUIFileOpenDialog::fillListBox()
//! sends the event that the file has been selected.
void CGUIFileOpenDialog::sendSelectedEvent(EGUI_EVENT_TYPE type)
{
SEvent event;
SEvent event{};
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.Element = 0;
Expand All @@ -360,7 +360,7 @@ void CGUIFileOpenDialog::sendSelectedEvent(EGUI_EVENT_TYPE type)
//! sends the event that the file choose process has been cancelled
void CGUIFileOpenDialog::sendCancelEvent()
{
SEvent event;
SEvent event{};
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.Element = 0;
Expand Down
10 changes: 5 additions & 5 deletions irr/src/CGUIListBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ bool CGUIListBox::OnEvent(const SEvent &event)
// post the news

if (oldSelected != Selected && Parent && !Selecting && !MoveOverSelect) {
SEvent e;
SEvent e{};
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
Expand All @@ -265,7 +265,7 @@ bool CGUIListBox::OnEvent(const SEvent &event)
return true;
} else if (!event.KeyInput.PressedDown && (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) {
if (Parent) {
SEvent e;
SEvent e{};
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
Expand Down Expand Up @@ -305,7 +305,7 @@ bool CGUIListBox::OnEvent(const SEvent &event)
if (Items[current].Text.size() >= KeyBuffer.size()) {
if (KeyBuffer.equals_ignore_case(Items[current].Text.subString(0, KeyBuffer.size()))) {
if (Parent && Selected != current && !Selecting && !MoveOverSelect) {
SEvent e;
SEvent e{};
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
Expand All @@ -322,7 +322,7 @@ bool CGUIListBox::OnEvent(const SEvent &event)
if (KeyBuffer.equals_ignore_case(Items[current].Text.subString(0, KeyBuffer.size()))) {
if (Parent && Selected != current && !Selecting && !MoveOverSelect) {
Selected = current;
SEvent e;
SEvent e{};
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
Expand Down Expand Up @@ -410,7 +410,7 @@ void CGUIListBox::selectNew(s32 ypos, bool onlyHover)
selectTime = now;
// post the news
if (Parent && !onlyHover) {
SEvent event;
SEvent event{};
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.Element = 0;
Expand Down
10 changes: 5 additions & 5 deletions irr/src/CGUIScrollBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bool CGUIScrollBar::OnEvent(const SEvent &event)
}

if (Pos != oldPos) {
SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand All @@ -107,7 +107,7 @@ bool CGUIScrollBar::OnEvent(const SEvent &event)
else if (event.GUIEvent.Caller == DownButton)
setPos(Pos + SmallStep);

SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand All @@ -132,7 +132,7 @@ bool CGUIScrollBar::OnEvent(const SEvent &event)
setPos(getPos() +
((event.MouseInput.Wheel < 0 ? -1 : 1) * SmallStep * (Horizontal ? 1 : -1)));

SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand Down Expand Up @@ -190,7 +190,7 @@ bool CGUIScrollBar::OnEvent(const SEvent &event)
}

if (Pos != oldPos && Parent) {
SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand Down Expand Up @@ -227,7 +227,7 @@ void CGUIScrollBar::OnPostRender(u32 timeMs)
setPos(DesiredPos);

if (Pos != oldPos && Parent) {
SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand Down
2 changes: 1 addition & 1 deletion irr/src/CGUITabControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ bool CGUITabControl::setActiveTab(s32 idx)
setVisibleTab(ActiveTabIndex);

if (changed && Parent) {
SEvent event;
SEvent event{};
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.Element = 0;
Expand Down
4 changes: 2 additions & 2 deletions irr/src/CIrrDeviceLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ bool CIrrDeviceLinux::run()
static_cast<CCursorControl *>(CursorControl)->update();

if ((CreationParams.DriverType != video::EDT_NULL) && XDisplay) {
SEvent irrevent;
SEvent irrevent{};
irrevent.MouseInput.ButtonStates = 0xffffffff;

while (XPending(XDisplay) > 0 && !Close) {
Expand Down Expand Up @@ -1581,7 +1581,7 @@ bool CIrrDeviceLinux::activateJoysticks(core::array<SJoystickInfo> &joystickInfo
fcntl(info.fd, F_SETFL, O_NONBLOCK);
#endif

(void)memset(&info.persistentData, 0, sizeof(info.persistentData));
info.persistentData = {};
info.persistentData.EventType = irr::EET_JOYSTICK_INPUT_EVENT;
info.persistentData.JoystickEvent.Joystick = ActiveJoysticks.size();

Expand Down
2 changes: 1 addition & 1 deletion irr/src/CIrrDeviceLinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ class CIrrDeviceLinux : public CIrrDeviceStub
int axes;
int buttons;

SEvent persistentData;
SEvent persistentData{};

JoystickInfo() :
fd(-1), axes(0), buttons(0) {}
Expand Down
6 changes: 3 additions & 3 deletions irr/src/CIrrDeviceOSX.mm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
int buttons;
int numActiveJoysticks;

irr::SEvent persistentData;
irr::SEvent persistentData{};

IOHIDDeviceInterface **interface;
bool removed;
Expand Down Expand Up @@ -740,7 +740,7 @@ - (BOOL)isQuit
NSAutoreleasePool *Pool = [[NSAutoreleasePool alloc] init];

NSEvent *event;
irr::SEvent ievent;
irr::SEvent ievent{};

os::Timer::tick();
storeMouseLocation();
Expand Down Expand Up @@ -1044,7 +1044,7 @@ - (BOOL)isQuit

const core::position2di &curr = ((CCursorControl *)CursorControl)->getPosition(true);
if (curr.X != x || curr.Y != y) {
irr::SEvent ievent;
irr::SEvent ievent{};
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
ievent.MouseInput.X = x;
Expand Down
10 changes: 5 additions & 5 deletions irr/src/CIrrDeviceSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ EM_BOOL CIrrDeviceSDL::MouseEnterCallback(int eventType, const EmscriptenMouseEv
{
CIrrDeviceSDL *This = static_cast<CIrrDeviceSDL *>(userData);

SEvent irrevent;
SEvent irrevent{};

irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.Event = irr::EMIE_MOUSE_ENTER_CANVAS;
Expand All @@ -112,7 +112,7 @@ EM_BOOL CIrrDeviceSDL::MouseLeaveCallback(int eventType, const EmscriptenMouseEv
{
CIrrDeviceSDL *This = static_cast<CIrrDeviceSDL *>(userData);

SEvent irrevent;
SEvent irrevent{};

irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.Event = irr::EMIE_MOUSE_LEAVE_CANVAS;
Expand Down Expand Up @@ -708,12 +708,12 @@ bool CIrrDeviceSDL::run()
{
os::Timer::tick();

SEvent irrevent;
SEvent irrevent{};
SDL_Event SDL_event;

while (!Close && wrap_PollEvent(&SDL_event)) {
// os::Printer::log("event: ", core::stringc((int)SDL_event.type).c_str(), ELL_INFORMATION); // just for debugging
memset(&irrevent, 0, sizeof(irrevent));
irrevent = {};

switch (SDL_event.type) {
case SDL_MOUSEMOTION: {
Expand Down Expand Up @@ -1001,7 +1001,7 @@ bool CIrrDeviceSDL::run()
// update joystick states manually
SDL_JoystickUpdate();
// we'll always send joystick input events...
SEvent joyevent;
SEvent joyevent{};
joyevent.EventType = EET_JOYSTICK_INPUT_EVENT;
for (u32 i = 0; i < Joysticks.size(); ++i) {
SDL_Joystick *joystick = Joysticks[i];
Expand Down
6 changes: 3 additions & 3 deletions irr/src/CIrrDeviceWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void SJoystickWin32Control::pollJoysticks()
// if no POV is available don't ask for POV values

if (!FAILED(ActiveJoysticks[joystick].lpdijoy->GetDeviceState(sizeof(info), &info))) {
SEvent event;
SEvent event{};

event.EventType = irr::EET_JOYSTICK_INPUT_EVENT;
event.JoystickEvent.Joystick = (u8)joystick;
Expand Down Expand Up @@ -304,7 +304,7 @@ void SJoystickWin32Control::pollJoysticks()
if (!(caps.wCaps & JOYCAPS_HASPOV))
info.dwFlags &= ~(JOY_RETURNPOV | JOY_RETURNPOVCTS);
if (JOYERR_NOERROR == joyGetPosEx(ActiveJoysticks[joystick].Index, &info)) {
SEvent event;
SEvent event{};

event.EventType = irr::EET_JOYSTICK_INPUT_EVENT;
event.JoystickEvent.Joystick = (u8)joystick;
Expand Down Expand Up @@ -517,7 +517,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
#endif

irr::CIrrDeviceWin32 *dev = 0;
irr::SEvent event;
SEvent event{};

static irr::s32 ClickCount = 0;
if (GetCapture() != hWnd && ClickCount > 0)
Expand Down
2 changes: 1 addition & 1 deletion irr/src/CLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void CLogger::log(const c8 *text, ELOG_LEVEL ll)
return;

if (Receiver) {
SEvent event;
SEvent event{};
event.EventType = EET_LOG_TEXT_EVENT;
event.LogEvent.Text = text;
event.LogEvent.Level = ll;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/guiButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool GUIButton::OnEvent(const SEvent& event)
ClickShiftState = event.KeyInput.Shift;
ClickControlState = event.KeyInput.Control;

SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand Down Expand Up @@ -218,7 +218,7 @@ bool GUIButton::OnEvent(const SEvent& event)
ClickShiftState = event.MouseInput.Shift;
ClickControlState = event.MouseInput.Control;

SEvent newEvent;
SEvent newEvent{};
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/guiEditBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void GUIEditBox::setTextMarkers(s32 begin, s32 end)
void GUIEditBox::sendGuiEvent(EGUI_EVENT_TYPE type)
{
if (Parent) {
SEvent e;
SEvent e{};
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
Expand Down
Loading

0 comments on commit 820cf0d

Please sign in to comment.