MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / EventCheck

Method EventCheck

Source/Window.cpp:129–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129void cWindow::EventCheck() {
130 SDL_Event SysEvent;
131
132 while (SDL_PollEvent(&SysEvent)) {
133
134 cEvent Event;
135
136 switch (SysEvent.type) {
137 case SDL_WINDOWEVENT:
138
139 switch (SysEvent.window.event) {
140 case SDL_WINDOWEVENT_FOCUS_LOST:
141 Event.mType = eEvent_Focus;
142 Event.mHasFocus = false;
143 mHasFocus = false;
144 break;
145
146 case SDL_WINDOWEVENT_FOCUS_GAINED:
147 Event.mType = eEvent_Focus;
148 Event.mHasFocus = true;
149 mHasFocus = true;
150 break;
151 }
152 break;
153
154 case SDL_KEYDOWN:
155 Event.mType = eEvent_KeyDown;
156 Event.mButton = SysEvent.key.keysym.scancode;
157 break;
158
159 case SDL_KEYUP:
160 Event.mType = eEvent_KeyUp;
161 Event.mButton = SysEvent.key.keysym.scancode;
162 break;
163
164 case SDL_MULTIGESTURE:
165 Event.mType = eEvent_MouseRightDown;
166 Event.mButton = 3;
167
168 Event.mPosition = cPosition((unsigned int)(SysEvent.tfinger.x * GetWindowWidth()),
169 (unsigned int)(SysEvent.tfinger.y * GetWindowHeight()));
170
171 break;
172
173 case SDL_FINGERMOTION:
174 Event.mType = eEvent_MouseMove;
175 Event.mPosition = cPosition((unsigned int)(SysEvent.tfinger.x * GetWindowWidth()),
176 (unsigned int)(SysEvent.tfinger.y * GetWindowHeight()));
177
178
179 break;
180
181 case SDL_FINGERDOWN:
182
183 Event.mType = eEvent_MouseLeftDown;
184 Event.mButton = 1;
185 Event.mPosition = cPosition((unsigned int)(SysEvent.tfinger.x * GetWindowWidth()),
186 (unsigned int)(SysEvent.tfinger.y * GetWindowHeight()));

Callers 1

sleepLoopMethod · 0.80

Calls 2

cPositionClass · 0.70
push_backMethod · 0.45

Tested by

no test coverage detected