Skip to content

Commit 5fbf67a

Browse files
[rcore] Use FLAG_* macros where possible (#5169)
* use FLAG_* macros where possible * rename `FLAG_CHECK()` to `FLAG_IS_SET()` * remove unnecessary equality checks * fix issues --------- Co-authored-by: Ray <[email protected]>
1 parent 0246621 commit 5fbf67a

File tree

8 files changed

+341
-363
lines changed

8 files changed

+341
-363
lines changed

src/platforms/rcore_android.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -796,10 +796,10 @@ int InitPlatform(void)
796796
//AConfiguration_getScreenLong(platform.app->config);
797797

798798
// Set some default window flags
799-
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN; // false
800-
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; // false
801-
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED; // true
802-
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED; // false
799+
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_HIDDEN); // false
800+
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // false
801+
FLAG_SET(CORE.Window.flags, FLAG_WINDOW_MAXIMIZED); // true
802+
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED); // false
803803
//----------------------------------------------------------------------------
804804

805805
// Initialize App command system
@@ -883,11 +883,11 @@ void ClosePlatform(void)
883883
static int InitGraphicsDevice(void)
884884
{
885885
CORE.Window.fullscreen = true;
886-
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;
886+
FLAG_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
887887

888888
EGLint samples = 0;
889889
EGLint sampleBuffer = 0;
890-
if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
890+
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
891891
{
892892
samples = 4;
893893
sampleBuffer = 1;
@@ -992,7 +992,7 @@ static int InitGraphicsDevice(void)
992992

993993
CORE.Window.ready = true;
994994

995-
if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) MinimizeWindow();
995+
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_MINIMIZED)) MinimizeWindow();
996996

997997
return 0;
998998
}
@@ -1059,7 +1059,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
10591059
// Set font white rectangle for shapes drawing, so shapes and text can be batched together
10601060
// WARNING: rshapes module is required, if not available, default internal white rectangle is used
10611061
Rectangle rec = GetFontDefault().recs[95];
1062-
if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
1062+
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
10631063
{
10641064
// NOTE: We try to maxime rec padding to avoid pixel bleeding on MSAA filtering
10651065
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 2, rec.y + 2, 1, 1 });
@@ -1102,14 +1102,14 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
11021102
case APP_CMD_GAINED_FOCUS:
11031103
{
11041104
platform.appEnabled = true;
1105-
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED;
1105+
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED);
11061106
//ResumeMusicStream();
11071107
} break;
11081108
case APP_CMD_PAUSE: break;
11091109
case APP_CMD_LOST_FOCUS:
11101110
{
11111111
platform.appEnabled = false;
1112-
CORE.Window.flags |= FLAG_WINDOW_UNFOCUSED;
1112+
FLAG_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED);
11131113
//PauseMusicStream();
11141114
} break;
11151115
case APP_CMD_TERM_WINDOW:
@@ -1187,8 +1187,8 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
11871187

11881188
if (type == AINPUT_EVENT_TYPE_MOTION)
11891189
{
1190-
if (((source & AINPUT_SOURCE_JOYSTICK) == AINPUT_SOURCE_JOYSTICK) ||
1191-
((source & AINPUT_SOURCE_GAMEPAD) == AINPUT_SOURCE_GAMEPAD))
1190+
if (FLAG_IS_SET(source, AINPUT_SOURCE_JOYSTICK) ||
1191+
FLAG_IS_SET(source, AINPUT_SOURCE_GAMEPAD))
11921192
{
11931193
// For now we'll assume a single gamepad which we "detect" on its input event
11941194
CORE.Input.Gamepad.ready[0] = true;
@@ -1251,8 +1251,8 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
12511251
//int32_t AKeyEvent_getMetaState(event);
12521252

12531253
// Handle gamepad button presses and releases
1254-
if (((source & AINPUT_SOURCE_JOYSTICK) == AINPUT_SOURCE_JOYSTICK) ||
1255-
((source & AINPUT_SOURCE_GAMEPAD) == AINPUT_SOURCE_GAMEPAD))
1254+
if (FLAG_IS_SET(source, AINPUT_SOURCE_JOYSTICK) ||
1255+
FLAG_IS_SET(source, AINPUT_SOURCE_GAMEPAD))
12561256
{
12571257
// For now we'll assume a single gamepad which we "detect" on its input event
12581258
CORE.Input.Gamepad.ready[0] = true;

src/platforms/rcore_desktop_glfw.c

Lines changed: 83 additions & 83 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)