summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2018-10-24 13:45:17 +0200
committerRay <[email protected]>2018-10-24 13:45:17 +0200
commit72431c6c36a166b00e52527962ab4d978ab0111d (patch)
tree346e60c85c667b4e7650b7d3cd1c7ee3c8a54be5 /src
parent550dd40cb324896138dde9ee43bb44c0b9723345 (diff)
downloadraylib-72431c6c36a166b00e52527962ab4d978ab0111d.tar.gz
raylib-72431c6c36a166b00e52527962ab4d978ab0111d.zip
Code tweaks
Diffstat (limited to 'src')
-rw-r--r--src/core.c23
-rw-r--r--src/text.c13
2 files changed, 19 insertions, 17 deletions
diff --git a/src/core.c b/src/core.c
index a0e53c87..ffbf110e 100644
--- a/src/core.c
+++ b/src/core.c
@@ -331,18 +331,19 @@ static int currentMouseWheelY = 0; // Registers current mouse wheel
#if defined(PLATFORM_RPI)
static char currentMouseStateEvdev[3] = { 0 }; // Holds the new mouse state for the next polling event to grab (Can't be written directly due to multithreading, app could miss the update)
+
typedef struct {
- pthread_t threadId; // Event reading thread id
- int fd; // File descriptor to the device it is assigned to
- int eventNum; // Number of 'event<N>' device
- Rectangle absRange; // Range of values for absolute pointing devices (touchscreens)
- int touchSlot; // Hold the touch slot number of the currently being sent multitouch block
- bool isMouse; // True if device supports relative X Y movements
- bool isTouch; // True if device supports absolute X Y movements and has BTN_TOUCH
- bool isMultitouch; // True if device supports multiple absolute movevents and has BTN_TOUCH
- bool isKeyboard; // True if device has letter keycodes
- bool isGamepad; // True if device has gamepad buttons
-}InputEventWorker;
+ pthread_t threadId; // Event reading thread id
+ int fd; // File descriptor to the device it is assigned to
+ int eventNum; // Number of 'event<N>' device
+ Rectangle absRange; // Range of values for absolute pointing devices (touchscreens)
+ int touchSlot; // Hold the touch slot number of the currently being sent multitouch block
+ bool isMouse; // True if device supports relative X Y movements
+ bool isTouch; // True if device supports absolute X Y movements and has BTN_TOUCH
+ bool isMultitouch; // True if device supports multiple absolute movevents and has BTN_TOUCH
+ bool isKeyboard; // True if device has letter keycodes
+ bool isGamepad; // True if device has gamepad buttons
+} InputEventWorker;
static InputEventWorker eventWorkers[10]; // List of worker threads for every monitored "/dev/input/event<N>"
diff --git a/src/text.c b/src/text.c
index 6e86958e..a010666e 100644
--- a/src/text.c
+++ b/src/text.c
@@ -316,6 +316,7 @@ Font LoadFontEx(const char *fileName, int fontSize, int charsCount, int *fontCha
font.texture = LoadTextureFromImage(atlas);
UnloadImage(atlas);
}
+ else font = GetFontDefault();
return font;
}
@@ -331,9 +332,9 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
#define SDF_PIXEL_DIST_SCALE 64.0f
#define BITMAP_ALPHA_THRESHOLD 80
-
+
CharInfo *chars = NULL;
-
+
// Load font data (including pixel data) from TTF file
// NOTE: Loaded information should be enough to generate font image atlas,
// using any packaging method
@@ -349,7 +350,7 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
fread(fontBuffer, size, 1, fontFile);
fclose(fontFile);
-
+
// Init font for data reading
stbtt_fontinfo fontInfo;
if (!stbtt_InitFont(&fontInfo, fontBuffer, 0)) TraceLog(LOG_WARNING, "Failed to init font!");
@@ -368,11 +369,11 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
// Fill fontChars in case not provided externally
// NOTE: By default we fill charsCount consecutevely, starting at 32 (Space)
int genFontChars = false;
- if (fontChars == NULL) genFontChars = true;
- if (genFontChars)
+ if (fontChars == NULL)
{
fontChars = (int *)malloc(charsCount*sizeof(int));
for (int i = 0; i < charsCount; i++) fontChars[i] = i + 32;
+ genFontChars = true;
}
chars = (CharInfo *)malloc(charsCount*sizeof(CharInfo));
@@ -417,7 +418,7 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL);
chars[i].advanceX *= scaleFactor;
}
-
+
free(fontBuffer);
if (genFontChars) free(fontChars);
}