REVIEWED: Formatting, follow raylib coding conventions
This commit is contained in:
parent
13e3092511
commit
1e1061d5c7
11 changed files with 77 additions and 78 deletions
|
@ -81,7 +81,7 @@ static PlatformData platform = { 0 }; // Platform specific data
|
||||||
// Local Variables Definition
|
// Local Variables Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#define KEYCODE_MAP_SIZE 162
|
#define KEYCODE_MAP_SIZE 162
|
||||||
static const KeyboardKey KeycodeMap[KEYCODE_MAP_SIZE] = {
|
static const KeyboardKey mapKeycode[KEYCODE_MAP_SIZE] = {
|
||||||
KEY_NULL, // AKEYCODE_UNKNOWN
|
KEY_NULL, // AKEYCODE_UNKNOWN
|
||||||
0, // AKEYCODE_SOFT_LEFT
|
0, // AKEYCODE_SOFT_LEFT
|
||||||
0, // AKEYCODE_SOFT_RIGHT
|
0, // AKEYCODE_SOFT_RIGHT
|
||||||
|
@ -1133,9 +1133,9 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||||
CORE.Input.Gamepad.axisState[0][GAMEPAD_AXIS_RIGHT_Y] = AMotionEvent_getAxisValue(
|
CORE.Input.Gamepad.axisState[0][GAMEPAD_AXIS_RIGHT_Y] = AMotionEvent_getAxisValue(
|
||||||
event, AMOTION_EVENT_AXIS_RZ, 0);
|
event, AMOTION_EVENT_AXIS_RZ, 0);
|
||||||
CORE.Input.Gamepad.axisState[0][GAMEPAD_AXIS_LEFT_TRIGGER] = AMotionEvent_getAxisValue(
|
CORE.Input.Gamepad.axisState[0][GAMEPAD_AXIS_LEFT_TRIGGER] = AMotionEvent_getAxisValue(
|
||||||
event, AMOTION_EVENT_AXIS_BRAKE, 0) * 2.0f - 1.0f;
|
event, AMOTION_EVENT_AXIS_BRAKE, 0)*2.0f - 1.0f;
|
||||||
CORE.Input.Gamepad.axisState[0][GAMEPAD_AXIS_RIGHT_TRIGGER] = AMotionEvent_getAxisValue(
|
CORE.Input.Gamepad.axisState[0][GAMEPAD_AXIS_RIGHT_TRIGGER] = AMotionEvent_getAxisValue(
|
||||||
event, AMOTION_EVENT_AXIS_GAS, 0) * 2.0f - 1.0f;
|
event, AMOTION_EVENT_AXIS_GAS, 0)*2.0f - 1.0f;
|
||||||
|
|
||||||
// dpad is reported as an axis on android
|
// dpad is reported as an axis on android
|
||||||
float dpadX = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_HAT_X, 0);
|
float dpadX = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_HAT_X, 0);
|
||||||
|
@ -1201,7 +1201,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||||
return 1; // Handled gamepad button
|
return 1; // Handled gamepad button
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardKey key = (keycode > 0 && keycode < KEYCODE_MAP_SIZE) ? KeycodeMap[keycode] : KEY_NULL;
|
KeyboardKey key = (keycode > 0 && keycode < KEYCODE_MAP_SIZE)? mapKeycode[keycode] : KEY_NULL;
|
||||||
if (key != KEY_NULL)
|
if (key != KEY_NULL)
|
||||||
{
|
{
|
||||||
// Save current key and its state
|
// Save current key and its state
|
||||||
|
@ -1252,10 +1252,10 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||||
CORE.Input.Touch.position[i] = (Vector2){ AMotionEvent_getX(event, i), AMotionEvent_getY(event, i) };
|
CORE.Input.Touch.position[i] = (Vector2){ AMotionEvent_getX(event, i), AMotionEvent_getY(event, i) };
|
||||||
|
|
||||||
// Normalize CORE.Input.Touch.position[i] for CORE.Window.screen.width and CORE.Window.screen.height
|
// Normalize CORE.Input.Touch.position[i] for CORE.Window.screen.width and CORE.Window.screen.height
|
||||||
float widthRatio = (float)(CORE.Window.screen.width + CORE.Window.renderOffset.x) / (float)CORE.Window.display.width;
|
float widthRatio = (float)(CORE.Window.screen.width + CORE.Window.renderOffset.x)/(float)CORE.Window.display.width;
|
||||||
float heightRatio = (float)(CORE.Window.screen.height + CORE.Window.renderOffset.y) / (float)CORE.Window.display.height;
|
float heightRatio = (float)(CORE.Window.screen.height + CORE.Window.renderOffset.y)/(float)CORE.Window.display.height;
|
||||||
CORE.Input.Touch.position[i].x = CORE.Input.Touch.position[i].x * widthRatio - (float)CORE.Window.renderOffset.x / 2;
|
CORE.Input.Touch.position[i].x = CORE.Input.Touch.position[i].x*widthRatio - (float)CORE.Window.renderOffset.x/2;
|
||||||
CORE.Input.Touch.position[i].y = CORE.Input.Touch.position[i].y * heightRatio - (float)CORE.Window.renderOffset.y / 2;
|
CORE.Input.Touch.position[i].y = CORE.Input.Touch.position[i].y*heightRatio - (float)CORE.Window.renderOffset.y/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t action = AMotionEvent_getAction(event);
|
int32_t action = AMotionEvent_getAction(event);
|
||||||
|
|
|
@ -1097,16 +1097,16 @@ void PollInputEvents(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
float value = (event->axis[i].x + event->axis[i].y) / (float) 32767;
|
float value = (event->axis[i].x + event->axis[i].y)/(float)32767;
|
||||||
#else
|
#else
|
||||||
float value = (event->axis[i].x + -event->axis[i].y) / (float) 32767;
|
float value = (event->axis[i].x + -event->axis[i].y)/(float)32767;
|
||||||
#endif
|
#endif
|
||||||
CORE.Input.Gamepad.axisState[event->joystick][axis] = value;
|
CORE.Input.Gamepad.axisState[event->joystick][axis] = value;
|
||||||
|
|
||||||
// Register button state for triggers in addition to their axes
|
// Register button state for triggers in addition to their axes
|
||||||
if ((axis == GAMEPAD_AXIS_LEFT_TRIGGER) || (axis == GAMEPAD_AXIS_RIGHT_TRIGGER))
|
if ((axis == GAMEPAD_AXIS_LEFT_TRIGGER) || (axis == GAMEPAD_AXIS_RIGHT_TRIGGER))
|
||||||
{
|
{
|
||||||
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER) ? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
|
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
|
||||||
int pressed = (value > 0.1f);
|
int pressed = (value > 0.1f);
|
||||||
CORE.Input.Gamepad.currentButtonState[event->joystick][button] = pressed;
|
CORE.Input.Gamepad.currentButtonState[event->joystick][button] = pressed;
|
||||||
if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
|
if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
|
||||||
|
|
|
@ -80,7 +80,7 @@ static PlatformData platform = { 0 }; // Platform specific data
|
||||||
// Local Variables Definition
|
// Local Variables Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#define SCANCODE_MAPPED_NUM 232
|
#define SCANCODE_MAPPED_NUM 232
|
||||||
static const KeyboardKey ScancodeToKey[SCANCODE_MAPPED_NUM] = {
|
static const KeyboardKey mapScancodeToKey[SCANCODE_MAPPED_NUM] = {
|
||||||
KEY_NULL, // SDL_SCANCODE_UNKNOWN
|
KEY_NULL, // SDL_SCANCODE_UNKNOWN
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -476,9 +476,9 @@ void ClearWindowState(unsigned int flags)
|
||||||
// Set icon for window
|
// Set icon for window
|
||||||
void SetWindowIcon(Image image)
|
void SetWindowIcon(Image image)
|
||||||
{
|
{
|
||||||
SDL_Surface* iconSurface = NULL;
|
SDL_Surface *iconSurface = NULL;
|
||||||
|
|
||||||
Uint32 rmask, gmask, bmask, amask;
|
unsigned int rmask = 0, gmask = 0, bmask = 0, amask = 0;
|
||||||
int depth = 0; // Depth in bits
|
int depth = 0; // Depth in bits
|
||||||
int pitch = 0; // Pixel spacing (pitch) in bytes
|
int pitch = 0; // Pixel spacing (pitch) in bytes
|
||||||
|
|
||||||
|
@ -492,72 +492,67 @@ void SetWindowIcon(Image image)
|
||||||
case PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA:
|
case PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA:
|
||||||
rmask = 0xFF, gmask = 0xFF00;
|
rmask = 0xFF, gmask = 0xFF00;
|
||||||
bmask = 0, amask = 0;
|
bmask = 0, amask = 0;
|
||||||
depth = 16, pitch = image.width * 2;
|
depth = 16, pitch = image.width*2;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R5G6B5:
|
case PIXELFORMAT_UNCOMPRESSED_R5G6B5:
|
||||||
rmask = 0xF800, gmask = 0x07E0;
|
rmask = 0xF800, gmask = 0x07E0;
|
||||||
bmask = 0x001F, amask = 0;
|
bmask = 0x001F, amask = 0;
|
||||||
depth = 16, pitch = image.width * 2;
|
depth = 16, pitch = image.width*2;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R8G8B8: // Uses BGR for 24-bit
|
case PIXELFORMAT_UNCOMPRESSED_R8G8B8: // Uses BGR for 24-bit
|
||||||
rmask = 0x0000FF, gmask = 0x00FF00;
|
rmask = 0x0000FF, gmask = 0x00FF00;
|
||||||
bmask = 0xFF0000, amask = 0;
|
bmask = 0xFF0000, amask = 0;
|
||||||
depth = 24, pitch = image.width * 3;
|
depth = 24, pitch = image.width*3;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R5G5B5A1:
|
case PIXELFORMAT_UNCOMPRESSED_R5G5B5A1:
|
||||||
rmask = 0xF800, gmask = 0x07C0;
|
rmask = 0xF800, gmask = 0x07C0;
|
||||||
bmask = 0x003E, amask = 0x0001;
|
bmask = 0x003E, amask = 0x0001;
|
||||||
depth = 16, pitch = image.width * 2;
|
depth = 16, pitch = image.width*2;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R4G4B4A4:
|
case PIXELFORMAT_UNCOMPRESSED_R4G4B4A4:
|
||||||
rmask = 0xF000, gmask = 0x0F00;
|
rmask = 0xF000, gmask = 0x0F00;
|
||||||
bmask = 0x00F0, amask = 0x000F;
|
bmask = 0x00F0, amask = 0x000F;
|
||||||
depth = 16, pitch = image.width * 2;
|
depth = 16, pitch = image.width*2;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8:
|
case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8:
|
||||||
rmask = 0xFF000000, gmask = 0x00FF0000;
|
rmask = 0xFF000000, gmask = 0x00FF0000;
|
||||||
bmask = 0x0000FF00, amask = 0x000000FF;
|
bmask = 0x0000FF00, amask = 0x000000FF;
|
||||||
depth = 32, pitch = image.width * 4;
|
depth = 32, pitch = image.width*4;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R32:
|
case PIXELFORMAT_UNCOMPRESSED_R32:
|
||||||
rmask = 0xFFFFFFFF, gmask = 0;
|
rmask = 0xFFFFFFFF, gmask = 0;
|
||||||
bmask = 0, amask = 0;
|
bmask = 0, amask = 0;
|
||||||
depth = 32, pitch = image.width * 4;
|
depth = 32, pitch = image.width*4;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R32G32B32:
|
case PIXELFORMAT_UNCOMPRESSED_R32G32B32:
|
||||||
rmask = 0xFFFFFFFF, gmask = 0xFFFFFFFF;
|
rmask = 0xFFFFFFFF, gmask = 0xFFFFFFFF;
|
||||||
bmask = 0xFFFFFFFF, amask = 0;
|
bmask = 0xFFFFFFFF, amask = 0;
|
||||||
depth = 96, pitch = image.width * 12;
|
depth = 96, pitch = image.width*12;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32:
|
case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32:
|
||||||
rmask = 0xFFFFFFFF, gmask = 0xFFFFFFFF;
|
rmask = 0xFFFFFFFF, gmask = 0xFFFFFFFF;
|
||||||
bmask = 0xFFFFFFFF, amask = 0xFFFFFFFF;
|
bmask = 0xFFFFFFFF, amask = 0xFFFFFFFF;
|
||||||
depth = 128, pitch = image.width * 16;
|
depth = 128, pitch = image.width*16;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R16:
|
case PIXELFORMAT_UNCOMPRESSED_R16:
|
||||||
rmask = 0xFFFF, gmask = 0;
|
rmask = 0xFFFF, gmask = 0;
|
||||||
bmask = 0, amask = 0;
|
bmask = 0, amask = 0;
|
||||||
depth = 16, pitch = image.width * 2;
|
depth = 16, pitch = image.width*2;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
|
case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
|
||||||
rmask = 0xFFFF, gmask = 0xFFFF;
|
rmask = 0xFFFF, gmask = 0xFFFF;
|
||||||
bmask = 0xFFFF, amask = 0;
|
bmask = 0xFFFF, amask = 0;
|
||||||
depth = 48, pitch = image.width * 6;
|
depth = 48, pitch = image.width*6;
|
||||||
break;
|
break;
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
|
case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
|
||||||
rmask = 0xFFFF, gmask = 0xFFFF;
|
rmask = 0xFFFF, gmask = 0xFFFF;
|
||||||
bmask = 0xFFFF, amask = 0xFFFF;
|
bmask = 0xFFFF, amask = 0xFFFF;
|
||||||
depth = 64, pitch = image.width * 8;
|
depth = 64, pitch = image.width*8;
|
||||||
break;
|
break;
|
||||||
default:
|
default: return; // Compressed formats are not supported
|
||||||
// Compressed formats are not supported
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iconSurface = SDL_CreateRGBSurfaceFrom(
|
iconSurface = SDL_CreateRGBSurfaceFrom( image.data, image.width, image.height, depth, pitch, rmask, gmask, bmask, amask );
|
||||||
image.data, image.width, image.height, depth, pitch,
|
|
||||||
rmask, gmask, bmask, amask
|
|
||||||
);
|
|
||||||
|
|
||||||
if (iconSurface)
|
if (iconSurface)
|
||||||
{
|
{
|
||||||
|
@ -599,7 +594,7 @@ void SetWindowMonitor(int monitor)
|
||||||
// 1. SDL started supporting moving exclusive fullscreen windows between displays on SDL3,
|
// 1. SDL started supporting moving exclusive fullscreen windows between displays on SDL3,
|
||||||
// see commit https://github.com/libsdl-org/SDL/commit/3f5ef7dd422057edbcf3e736107e34be4b75d9ba
|
// see commit https://github.com/libsdl-org/SDL/commit/3f5ef7dd422057edbcf3e736107e34be4b75d9ba
|
||||||
// 2. A workaround for SDL2 is leaving fullscreen, moving the window, then entering full screen again.
|
// 2. A workaround for SDL2 is leaving fullscreen, moving the window, then entering full screen again.
|
||||||
const bool wasFullscreen = ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) ? true : false;
|
const bool wasFullscreen = ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0)? true : false;
|
||||||
|
|
||||||
const int screenWidth = CORE.Window.screen.width;
|
const int screenWidth = CORE.Window.screen.width;
|
||||||
const int screenHeight = CORE.Window.screen.height;
|
const int screenHeight = CORE.Window.screen.height;
|
||||||
|
@ -941,11 +936,11 @@ int SetGamepadMappings(const char *mappings)
|
||||||
// Set gamepad vibration
|
// Set gamepad vibration
|
||||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor)
|
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor)
|
||||||
{
|
{
|
||||||
//Limit input values to between 0.0f and 1.0f
|
// Limit input values to between 0.0f and 1.0f
|
||||||
leftMotor = (0.0f > leftMotor) ? 0.0f : leftMotor;
|
leftMotor = (0.0f > leftMotor)? 0.0f : leftMotor;
|
||||||
rightMotor = (0.0f > rightMotor) ? 0.0f : rightMotor;
|
rightMotor = (0.0f > rightMotor)? 0.0f : rightMotor;
|
||||||
leftMotor = (1.0f < leftMotor) ? 1.0f : leftMotor;
|
leftMotor = (1.0f < leftMotor)? 1.0f : leftMotor;
|
||||||
rightMotor = (1.0f < rightMotor) ? 1.0f : rightMotor;
|
rightMotor = (1.0f < rightMotor)? 1.0f : rightMotor;
|
||||||
|
|
||||||
if (IsGamepadAvailable(gamepad))
|
if (IsGamepadAvailable(gamepad))
|
||||||
{
|
{
|
||||||
|
@ -1365,13 +1360,13 @@ void PollInputEvents(void)
|
||||||
if (axis >= 0)
|
if (axis >= 0)
|
||||||
{
|
{
|
||||||
// SDL axis value range is -32768 to 32767, we normalize it to RayLib's -1.0 to 1.0f range
|
// SDL axis value range is -32768 to 32767, we normalize it to RayLib's -1.0 to 1.0f range
|
||||||
float value = event.jaxis.value / (float) 32767;
|
float value = event.jaxis.value/(float)32767;
|
||||||
CORE.Input.Gamepad.axisState[event.jaxis.which][axis] = value;
|
CORE.Input.Gamepad.axisState[event.jaxis.which][axis] = value;
|
||||||
|
|
||||||
// Register button state for triggers in addition to their axes
|
// Register button state for triggers in addition to their axes
|
||||||
if ((axis == GAMEPAD_AXIS_LEFT_TRIGGER) || (axis == GAMEPAD_AXIS_RIGHT_TRIGGER))
|
if ((axis == GAMEPAD_AXIS_LEFT_TRIGGER) || (axis == GAMEPAD_AXIS_RIGHT_TRIGGER))
|
||||||
{
|
{
|
||||||
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER) ? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
|
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
|
||||||
int pressed = (value > 0.1f);
|
int pressed = (value > 0.1f);
|
||||||
CORE.Input.Gamepad.currentButtonState[event.jaxis.which][button] = pressed;
|
CORE.Input.Gamepad.currentButtonState[event.jaxis.which][button] = pressed;
|
||||||
if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
|
if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
|
||||||
|
@ -1554,6 +1549,7 @@ int InitPlatform(void)
|
||||||
for (int i = 0; (i < SDL_NumJoysticks()) && (i < MAX_GAMEPADS); i++)
|
for (int i = 0; (i < SDL_NumJoysticks()) && (i < MAX_GAMEPADS); i++)
|
||||||
{
|
{
|
||||||
platform.gamepad[i] = SDL_JoystickOpen(i);
|
platform.gamepad[i] = SDL_JoystickOpen(i);
|
||||||
|
|
||||||
if (platform.gamepad[i])
|
if (platform.gamepad[i])
|
||||||
{
|
{
|
||||||
CORE.Input.Gamepad.ready[i] = true;
|
CORE.Input.Gamepad.ready[i] = true;
|
||||||
|
@ -1608,8 +1604,9 @@ static KeyboardKey ConvertScancodeToKey(SDL_Scancode sdlScancode)
|
||||||
{
|
{
|
||||||
if (sdlScancode >= 0 && sdlScancode < SCANCODE_MAPPED_NUM)
|
if (sdlScancode >= 0 && sdlScancode < SCANCODE_MAPPED_NUM)
|
||||||
{
|
{
|
||||||
return ScancodeToKey[sdlScancode];
|
return mapScancodeToKey[sdlScancode];
|
||||||
}
|
}
|
||||||
|
|
||||||
return KEY_NULL; // No equivalent key in Raylib
|
return KEY_NULL; // No equivalent key in Raylib
|
||||||
}
|
}
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -1028,7 +1028,7 @@ int InitPlatform(void)
|
||||||
|
|
||||||
// If graphic device is no properly initialized, we end program
|
// If graphic device is no properly initialized, we end program
|
||||||
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return -1; }
|
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return -1; }
|
||||||
else SetWindowPosition(GetMonitorWidth(GetCurrentMonitor()) / 2 - CORE.Window.screen.width / 2, GetMonitorHeight(GetCurrentMonitor()) / 2 - CORE.Window.screen.height / 2);
|
else SetWindowPosition(GetMonitorWidth(GetCurrentMonitor())/2 - CORE.Window.screen.width/2, GetMonitorHeight(GetCurrentMonitor())/2 - CORE.Window.screen.height/2);
|
||||||
|
|
||||||
// Set some default window flags
|
// Set some default window flags
|
||||||
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN; // false
|
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN; // false
|
||||||
|
@ -1614,7 +1614,7 @@ static void PollKeyboardEvents(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACELOG(LOG_DEBUG, "INPUT: KEY_%s Keycode(linux): %4i KeyCode(raylib): %4i", (event.value == 0) ? "UP " : "DOWN", event.code, keycode);
|
TRACELOG(LOG_DEBUG, "INPUT: KEY_%s Keycode(linux): %4i KeyCode(raylib): %4i", (event.value == 0)? "UP " : "DOWN", event.code, keycode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1641,7 +1641,7 @@ static void PollGamepadEvents(void)
|
||||||
{
|
{
|
||||||
short keycodeRaylib = linuxToRaylibMap[event.code];
|
short keycodeRaylib = linuxToRaylibMap[event.code];
|
||||||
|
|
||||||
TRACELOG(LOG_DEBUG, "INPUT: Gamepad %2i: KEY_%s Keycode(linux): %4i Keycode(raylib): %4i", i, (event.value == 0) ? "UP " : "DOWN", event.code, keycodeRaylib);
|
TRACELOG(LOG_DEBUG, "INPUT: Gamepad %2i: KEY_%s Keycode(linux): %4i Keycode(raylib): %4i", i, (event.value == 0)? "UP" : "DOWN", event.code, keycodeRaylib);
|
||||||
|
|
||||||
if ((keycodeRaylib != 0) && (keycodeRaylib < MAX_GAMEPAD_BUTTONS))
|
if ((keycodeRaylib != 0) && (keycodeRaylib < MAX_GAMEPAD_BUTTONS))
|
||||||
{
|
{
|
||||||
|
@ -1666,7 +1666,7 @@ static void PollGamepadEvents(void)
|
||||||
int range = platform.gamepadAbsAxisRange[i][event.code][1];
|
int range = platform.gamepadAbsAxisRange[i][event.code][1];
|
||||||
|
|
||||||
// NOTE: Scaling of event.value to get values between -1..1
|
// NOTE: Scaling of event.value to get values between -1..1
|
||||||
CORE.Input.Gamepad.axisState[i][axisRaylib] = (2 * (float)(event.value - min) / range) - 1;
|
CORE.Input.Gamepad.axisState[i][axisRaylib] = (2*(float)(event.value - min)/range) - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,8 @@ void ToggleFullscreen(void)
|
||||||
if (enterFullscreen)
|
if (enterFullscreen)
|
||||||
{
|
{
|
||||||
// NOTE: The setTimeouts handle the browser mode change delay
|
// NOTE: The setTimeouts handle the browser mode change delay
|
||||||
EM_ASM(
|
EM_ASM
|
||||||
|
(
|
||||||
setTimeout(function()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
Module.requestFullscreen(false, false);
|
Module.requestFullscreen(false, false);
|
||||||
|
@ -298,7 +299,8 @@ void ToggleBorderlessWindowed(void)
|
||||||
{
|
{
|
||||||
// NOTE: 1. The setTimeouts handle the browser mode change delay
|
// NOTE: 1. The setTimeouts handle the browser mode change delay
|
||||||
// 2. The style unset handles the possibility of a width="value%" like on the default shell.html file
|
// 2. The style unset handles the possibility of a width="value%" like on the default shell.html file
|
||||||
EM_ASM(
|
EM_ASM
|
||||||
|
(
|
||||||
setTimeout(function()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
Module.requestFullscreen(false, true);
|
Module.requestFullscreen(false, true);
|
||||||
|
|
|
@ -1332,7 +1332,7 @@ RLAPI Image GenImageText(int width, int height, const char *text);
|
||||||
// Image manipulation functions
|
// Image manipulation functions
|
||||||
RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
|
RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
|
||||||
RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece
|
RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece
|
||||||
RLAPI Image ImageFromChannel(Image image, int selectedChannel); // Create an image from a selected channel of another image (GRAYSCALE/R16/R32)
|
RLAPI Image ImageFromChannel(Image image, int selectedChannel); // Create an image from a selected channel of another image (GRAYSCALE)
|
||||||
RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
|
RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
|
||||||
RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)
|
RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)
|
||||||
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
|
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
|
||||||
|
|
|
@ -175,7 +175,7 @@ typedef struct float16 {
|
||||||
// Clamp float value
|
// Clamp float value
|
||||||
RMAPI float Clamp(float value, float min, float max)
|
RMAPI float Clamp(float value, float min, float max)
|
||||||
{
|
{
|
||||||
float result = (value < min) ? min : value;
|
float result = (value < min)? min : value;
|
||||||
|
|
||||||
if (result > max) result = max;
|
if (result > max) result = max;
|
||||||
|
|
||||||
|
@ -962,12 +962,12 @@ RMAPI Vector3 Vector3CubicHermite(Vector3 v1, Vector3 tangent1, Vector3 v2, Vect
|
||||||
{
|
{
|
||||||
Vector3 result = { 0 };
|
Vector3 result = { 0 };
|
||||||
|
|
||||||
float amountPow2 = amount * amount;
|
float amountPow2 = amount*amount;
|
||||||
float amountPow3 = amount * amount * amount;
|
float amountPow3 = amount*amount*amount;
|
||||||
|
|
||||||
result.x = (2 * amountPow3 - 3 * amountPow2 + 1) * v1.x + (amountPow3 - 2 * amountPow2 + amount) * tangent1.x + (-2 * amountPow3 + 3 * amountPow2) * v2.x + (amountPow3 - amountPow2) * tangent2.x;
|
result.x = (2*amountPow3 - 3*amountPow2 + 1)*v1.x + (amountPow3 - 2*amountPow2 + amount)*tangent1.x + (-2*amountPow3 + 3*amountPow2)*v2.x + (amountPow3 - amountPow2)*tangent2.x;
|
||||||
result.y = (2 * amountPow3 - 3 * amountPow2 + 1) * v1.y + (amountPow3 - 2 * amountPow2 + amount) * tangent1.y + (-2 * amountPow3 + 3 * amountPow2) * v2.y + (amountPow3 - amountPow2) * tangent2.y;
|
result.y = (2*amountPow3 - 3*amountPow2 + 1)*v1.y + (amountPow3 - 2*amountPow2 + amount)*tangent1.y + (-2*amountPow3 + 3*amountPow2)*v2.y + (amountPow3 - amountPow2)*tangent2.y;
|
||||||
result.z = (2 * amountPow3 - 3 * amountPow2 + 1) * v1.z + (amountPow3 - 2 * amountPow2 + amount) * tangent1.z + (-2 * amountPow3 + 3 * amountPow2) * v2.z + (amountPow3 - amountPow2) * tangent2.z;
|
result.z = (2*amountPow3 - 3*amountPow2 + 1)*v1.z + (amountPow3 - 2*amountPow2 + amount)*tangent1.z + (-2*amountPow3 + 3*amountPow2)*v2.z + (amountPow3 - amountPow2)*tangent2.z;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2218,11 +2218,11 @@ RMAPI Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
|
||||||
// as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic
|
// as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic
|
||||||
RMAPI Quaternion QuaternionCubicHermiteSpline(Quaternion q1, Quaternion outTangent1, Quaternion q2, Quaternion inTangent2, float t)
|
RMAPI Quaternion QuaternionCubicHermiteSpline(Quaternion q1, Quaternion outTangent1, Quaternion q2, Quaternion inTangent2, float t)
|
||||||
{
|
{
|
||||||
float t2 = t * t;
|
float t2 = t*t;
|
||||||
float t3 = t2 * t;
|
float t3 = t2*t;
|
||||||
float h00 = 2 * t3 - 3 * t2 + 1;
|
float h00 = 2*t3 - 3*t2 + 1;
|
||||||
float h10 = t3 - 2 * t2 + t;
|
float h10 = t3 - 2*t2 + t;
|
||||||
float h01 = -2 * t3 + 3 * t2;
|
float h01 = -2*t3 + 3*t2;
|
||||||
float h11 = t3 - t2;
|
float h11 = t3 - t2;
|
||||||
|
|
||||||
Quaternion p0 = QuaternionScale(q1, h00);
|
Quaternion p0 = QuaternionScale(q1, h00);
|
||||||
|
|
|
@ -490,8 +490,8 @@ void UpdateCamera(Camera *camera, int mode)
|
||||||
if (IsGamepadAvailable(0))
|
if (IsGamepadAvailable(0))
|
||||||
{
|
{
|
||||||
// Gamepad controller support
|
// Gamepad controller support
|
||||||
CameraYaw(camera, -(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X) * 2)*CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget);
|
CameraYaw(camera, -(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*2)*CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget);
|
||||||
CameraPitch(camera, -(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y) * 2)*CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp);
|
CameraPitch(camera, -(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*2)*CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp);
|
||||||
|
|
||||||
if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) <= -0.25f) CameraMoveForward(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
|
if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) <= -0.25f) CameraMoveForward(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
|
||||||
if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) <= -0.25f) CameraMoveRight(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
|
if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) <= -0.25f) CameraMoveRight(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
|
||||||
|
|
|
@ -1560,7 +1560,7 @@ void rlNormal3f(float x, float y, float z)
|
||||||
float length = sqrtf(normalx*normalx + normaly*normaly + normalz*normalz);
|
float length = sqrtf(normalx*normalx + normaly*normaly + normalz*normalz);
|
||||||
if (length != 0.0f)
|
if (length != 0.0f)
|
||||||
{
|
{
|
||||||
float ilength = 1.0f / length;
|
float ilength = 1.0f/length;
|
||||||
normalx *= ilength;
|
normalx *= ilength;
|
||||||
normaly *= ilength;
|
normaly *= ilength;
|
||||||
normalz *= ilength;
|
normalz *= ilength;
|
||||||
|
|
|
@ -2235,10 +2235,10 @@ bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, floa
|
||||||
float dx = center2.x - center1.x; // X distance between centers
|
float dx = center2.x - center1.x; // X distance between centers
|
||||||
float dy = center2.y - center1.y; // Y distance between centers
|
float dy = center2.y - center1.y; // Y distance between centers
|
||||||
|
|
||||||
float distanceSquared = dx * dx + dy * dy; // Distance between centers squared
|
float distanceSquared = dx*dx + dy*dy; // Distance between centers squared
|
||||||
float radiusSum = radius1 + radius2;
|
float radiusSum = radius1 + radius2;
|
||||||
|
|
||||||
collision = (distanceSquared <= (radiusSum * radiusSum));
|
collision = (distanceSquared <= (radiusSum*radiusSum));
|
||||||
|
|
||||||
return collision;
|
return collision;
|
||||||
}
|
}
|
||||||
|
@ -2329,17 +2329,17 @@ RLAPI bool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Ve
|
||||||
return CheckCollisionCircles(p1, 0, center, radius);
|
return CheckCollisionCircles(p1, 0, center, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
float lengthSQ = ((dx * dx) + (dy * dy));
|
float lengthSQ = ((dx*dx) + (dy*dy));
|
||||||
float dotProduct = (((center.x - p1.x) * (p2.x - p1.x)) + ((center.y - p1.y) * (p2.y - p1.y))) / (lengthSQ);
|
float dotProduct = (((center.x - p1.x)*(p2.x - p1.x)) + ((center.y - p1.y)*(p2.y - p1.y)))/(lengthSQ);
|
||||||
|
|
||||||
if (dotProduct > 1.0f) dotProduct = 1.0f;
|
if (dotProduct > 1.0f) dotProduct = 1.0f;
|
||||||
else if (dotProduct < 0.0f) dotProduct = 0.0f;
|
else if (dotProduct < 0.0f) dotProduct = 0.0f;
|
||||||
|
|
||||||
float dx2 = (p1.x - (dotProduct * (dx))) - center.x;
|
float dx2 = (p1.x - (dotProduct*(dx))) - center.x;
|
||||||
float dy2 = (p1.y - (dotProduct * (dy))) - center.y;
|
float dy2 = (p1.y - (dotProduct*(dy))) - center.y;
|
||||||
float distanceSQ = ((dx2 * dx2) + (dy2 * dy2));
|
float distanceSQ = ((dx2*dx2) + (dy2*dy2));
|
||||||
|
|
||||||
return (distanceSQ <= radius * radius);
|
return (distanceSQ <= radius*radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get collision rectangle for two rectangles collision
|
// Get collision rectangle for two rectangles collision
|
||||||
|
|
|
@ -3599,7 +3599,7 @@ void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int en
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate fixed-point increment for shorter length
|
// Calculate fixed-point increment for shorter length
|
||||||
int decInc = (longLen == 0)? 0 : (shortLen<<16) / longLen;
|
int decInc = (longLen == 0)? 0 : (shortLen << 16)/longLen;
|
||||||
|
|
||||||
// Draw the line pixel by pixel
|
// Draw the line pixel by pixel
|
||||||
if (yLonger)
|
if (yLonger)
|
||||||
|
@ -3608,7 +3608,7 @@ void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int en
|
||||||
for (int i = 0, j = 0; i != endVal; i += sgnInc, j += decInc)
|
for (int i = 0, j = 0; i != endVal; i += sgnInc, j += decInc)
|
||||||
{
|
{
|
||||||
// Calculate pixel position and draw it
|
// Calculate pixel position and draw it
|
||||||
ImageDrawPixel(dst, startPosX + (j>>16), startPosY + i, color);
|
ImageDrawPixel(dst, startPosX + (j >> 16), startPosY + i, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3617,7 +3617,7 @@ void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int en
|
||||||
for (int i = 0, j = 0; i != endVal; i += sgnInc, j += decInc)
|
for (int i = 0, j = 0; i != endVal; i += sgnInc, j += decInc)
|
||||||
{
|
{
|
||||||
// Calculate pixel position and draw it
|
// Calculate pixel position and draw it
|
||||||
ImageDrawPixel(dst, startPosX + i, startPosY + (j>>16), color);
|
ImageDrawPixel(dst, startPosX + i, startPosY + (j >> 16), color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3815,10 +3815,10 @@ void ImageDrawTriangle(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color col
|
||||||
{
|
{
|
||||||
// Calculate the 2D bounding box of the triangle
|
// Calculate the 2D bounding box of the triangle
|
||||||
// Determine the minimum and maximum x and y coordinates of the triangle vertices
|
// Determine the minimum and maximum x and y coordinates of the triangle vertices
|
||||||
int xMin = (int)((v1.x < v2.x)? ((v1.x < v3.x) ? v1.x : v3.x) : ((v2.x < v3.x) ? v2.x : v3.x));
|
int xMin = (int)((v1.x < v2.x)? ((v1.x < v3.x)? v1.x : v3.x) : ((v2.x < v3.x)? v2.x : v3.x));
|
||||||
int yMin = (int)((v1.y < v2.y)? ((v1.y < v3.y) ? v1.y : v3.y) : ((v2.y < v3.y) ? v2.y : v3.y));
|
int yMin = (int)((v1.y < v2.y)? ((v1.y < v3.y)? v1.y : v3.y) : ((v2.y < v3.y)? v2.y : v3.y));
|
||||||
int xMax = (int)((v1.x > v2.x)? ((v1.x > v3.x) ? v1.x : v3.x) : ((v2.x > v3.x) ? v2.x : v3.x));
|
int xMax = (int)((v1.x > v2.x)? ((v1.x > v3.x)? v1.x : v3.x) : ((v2.x > v3.x)? v2.x : v3.x));
|
||||||
int yMax = (int)((v1.y > v2.y)? ((v1.y > v3.y) ? v1.y : v3.y) : ((v2.y > v3.y) ? v2.y : v3.y));
|
int yMax = (int)((v1.y > v2.y)? ((v1.y > v3.y)? v1.y : v3.y) : ((v2.y > v3.y)? v2.y : v3.y));
|
||||||
|
|
||||||
// Clamp the bounding box to the image dimensions
|
// Clamp the bounding box to the image dimensions
|
||||||
if (xMin < 0) xMin = 0;
|
if (xMin < 0) xMin = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue