Move log to shared component
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UL_CURSOR_H
|
||||
#define UL_CURSOR_H
|
||||
#ifndef BB_CURSOR_H
|
||||
#define BB_CURSOR_H
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
/* Image description of the mouse cursor */
|
||||
extern const lv_img_dsc_t bb_cursor_img_dsc;
|
||||
|
||||
#endif /* UL_CURSOR_H */
|
||||
#endif /* BB_CURSOR_H */
|
||||
|
@@ -15,18 +15,18 @@
|
||||
* Static variables
|
||||
*/
|
||||
|
||||
static ul_log_level log_level = UL_LOG_LEVEL_ERROR;
|
||||
static bb_log_level log_level = BB_LOG_LEVEL_ERROR;
|
||||
|
||||
|
||||
/**
|
||||
* Public functions
|
||||
*/
|
||||
|
||||
void ul_log_set_level(ul_log_level level) {
|
||||
void bb_log_set_level(bb_log_level level) {
|
||||
log_level = level;
|
||||
}
|
||||
|
||||
void ul_log(ul_log_level level, const char *format, ...) {
|
||||
void bb_log(bb_log_level level, const char *format, ...) {
|
||||
if (level > log_level) {
|
||||
return;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ void ul_log(ul_log_level level, const char *format, ...) {
|
||||
}
|
||||
}
|
||||
|
||||
void ul_log_print_cb(lv_log_level_t level, const char *msg) {
|
||||
void bb_log_print_cb(lv_log_level_t level, const char *msg) {
|
||||
LV_UNUSED(level);
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, msg);
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, msg);
|
||||
}
|
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UL_LOG_H
|
||||
#define UL_LOG_H
|
||||
#ifndef BB_LOG_H
|
||||
#define BB_LOG_H
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
@@ -14,19 +14,19 @@
|
||||
*/
|
||||
typedef enum {
|
||||
/* Errors only */
|
||||
UL_LOG_LEVEL_ERROR = 0,
|
||||
BB_LOG_LEVEL_ERROR = 0,
|
||||
/* Warnings and errors */
|
||||
UL_LOG_LEVEL_WARNING = 1,
|
||||
BB_LOG_LEVEL_WARNING = 1,
|
||||
/* Include non-errors in log */
|
||||
UL_LOG_LEVEL_VERBOSE = 2
|
||||
} ul_log_level;
|
||||
BB_LOG_LEVEL_VERBOSE = 2
|
||||
} bb_log_level;
|
||||
|
||||
/**
|
||||
* Set the log level.
|
||||
*
|
||||
* @param level new log level value
|
||||
*/
|
||||
void ul_log_set_level(ul_log_level level);
|
||||
void bb_log_set_level(bb_log_level level);
|
||||
|
||||
/**
|
||||
* Log a message. A newline character is appended unless the message ends in one.
|
||||
@@ -35,7 +35,7 @@ void ul_log_set_level(ul_log_level level);
|
||||
* @param format message format string
|
||||
* @param ... parameters to fill into the format string
|
||||
*/
|
||||
void ul_log(ul_log_level level, const char *format, ...);
|
||||
void bb_log(bb_log_level level, const char *format, ...);
|
||||
|
||||
/**
|
||||
* Handle an LVGL log message.
|
||||
@@ -43,6 +43,6 @@ void ul_log(ul_log_level level, const char *format, ...);
|
||||
* @param level LVGL log level
|
||||
* @param msg message to print
|
||||
*/
|
||||
void ul_log_print_cb(lv_log_level_t level, const char *msg);
|
||||
void bb_log_print_cb(lv_log_level_t level, const char *msg);
|
||||
|
||||
#endif /* UL_LOG_H */
|
||||
#endif /* BB_LOG_H */
|
@@ -6,8 +6,11 @@
|
||||
|
||||
#include "backends.h"
|
||||
|
||||
#include "../shared/log.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/**
|
||||
* Public interface
|
||||
*/
|
||||
@@ -25,10 +28,10 @@ const char *ul_backends_backends[] = {
|
||||
ul_backends_backend_id_t ul_backends_find_backend_with_name(const char *name) {
|
||||
for (int i = 0; ul_backends_backends[i] != NULL; ++i) {
|
||||
if (strcmp(ul_backends_backends[i], name) == 0) {
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, "Found backend: %s\n", name);
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, "Found backend: %s\n", name);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Backend %s not found\n", name);
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Backend %s not found\n", name);
|
||||
return UL_BACKENDS_BACKEND_NONE;
|
||||
}
|
||||
|
@@ -7,8 +7,6 @@
|
||||
#ifndef UL_BACKENDS_H
|
||||
#define UL_BACKENDS_H
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
/**
|
||||
|
@@ -6,9 +6,10 @@
|
||||
|
||||
#include "command_line.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "unl0kr.h"
|
||||
|
||||
#include "../shared/log.h"
|
||||
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -96,7 +97,7 @@ void ul_cli_parse_opts(int argc, char *argv[], ul_cli_opts *opts) {
|
||||
case 'C':
|
||||
opts->config_files = realloc(opts->config_files, (opts->num_config_files + 1) * sizeof(char *));
|
||||
if (!opts->config_files) {
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Could not allocate memory for config file paths");
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Could not allocate memory for config file paths");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
opts->config_files[opts->num_config_files] = optarg;
|
||||
@@ -105,14 +106,14 @@ void ul_cli_parse_opts(int argc, char *argv[], ul_cli_opts *opts) {
|
||||
case 'g':
|
||||
if (sscanf(optarg, "%ix%i@%i,%i", &(opts->hor_res), &(opts->ver_res), &(opts->x_offset), &(opts->y_offset)) != 4) {
|
||||
if (sscanf(optarg, "%ix%i", &(opts->hor_res), &(opts->ver_res)) != 2) {
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Invalid geometry argument \"%s\"\n", optarg);
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Invalid geometry argument \"%s\"\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
if (sscanf(optarg, "%i", &(opts->dpi)) != 1) {
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Invalid dpi argument \"%s\"\n", optarg);
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Invalid dpi argument \"%s\"\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
@@ -6,7 +6,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "../shared/log.h"
|
||||
#include "../squeek2lvgl/sq2lv.h"
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
@@ -15,8 +16,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../squeek2lvgl/sq2lv.h"
|
||||
|
||||
|
||||
/**
|
||||
* Static prototypes
|
||||
@@ -96,7 +95,7 @@ static void find_files(const char *path, char ***found, int *num_found) {
|
||||
/* Open directory */
|
||||
DIR *d = opendir(path);
|
||||
if (!d) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not read contents of folder %s", path);
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not read contents of folder %s", path);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,7 +110,7 @@ static void find_files(const char *path, char ***found, int *num_found) {
|
||||
/* Grow output array */
|
||||
char **tmp = realloc(*found, (*num_found + 1) * sizeof(char *));
|
||||
if (!tmp) {
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Could not reallocate memory for configuration file paths");
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Could not reallocate memory for configuration file paths");
|
||||
break;
|
||||
}
|
||||
*found = tmp;
|
||||
@@ -123,7 +122,7 @@ static void find_files(const char *path, char ***found, int *num_found) {
|
||||
/* Allocate memory for full path */
|
||||
char *found_path = malloc(path_length + name_length + 2); /* +1 for path separator and null terminator, respectively */
|
||||
if (!found_path) {
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Could not allocate memory for configuration file path");
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Could not allocate memory for configuration file path");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -232,7 +231,7 @@ static int parsing_handler(void* user_data, const char* section, const char* key
|
||||
}
|
||||
}
|
||||
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Ignoring invalid config value \"%s\" for key \"%s\" in section \"%s\"", value, key, section);
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Ignoring invalid config value \"%s\" for key \"%s\" in section \"%s\"", value, key, section);
|
||||
return 1; /* Return 1 (true) so that we can use the return value of ini_parse exclusively for file-level errors (e.g. file not found) */
|
||||
}
|
||||
|
||||
@@ -298,8 +297,8 @@ void ul_config_parse_files(const char **files, int num_files, ul_config_opts *op
|
||||
}
|
||||
|
||||
void ul_config_parse_file(const char *path, ul_config_opts *opts) {
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, "Parsing config file %s", path);
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, "Parsing config file %s", path);
|
||||
if (ini_parse(path, parsing_handler, opts) != 0) {
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Ignoring invalid config file %s", path);
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Ignoring invalid config file %s", path);
|
||||
}
|
||||
}
|
||||
|
@@ -6,9 +6,8 @@
|
||||
|
||||
#include "indev.h"
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#include "../shared/cursor/cursor.h"
|
||||
#include "../shared/log.h"
|
||||
|
||||
#include "lvgl/src/indev/lv_indev_private.h"
|
||||
|
||||
@@ -170,7 +169,7 @@ static void connect_udev_device(struct udev_device *device) {
|
||||
/* Obtain and verify device node */
|
||||
const char *node = udev_device_get_devnode(device);
|
||||
if (!node || strncmp(node, INPUT_DEVICE_NODE_PREFIX, strlen(INPUT_DEVICE_NODE_PREFIX)) != 0) {
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, "Ignoring unsupported input device %s", udev_device_get_syspath(device));
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, "Ignoring unsupported input device %s", udev_device_get_syspath(device));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -182,7 +181,7 @@ static void connect_devnode(const char *node) {
|
||||
/* Check if the device is already connected */
|
||||
for (int i = 0; i < num_connected_devices; ++i) {
|
||||
if (strcmp(devices[i]->node, node) == 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Ignoring already connected input device %s", node);
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Ignoring already connected input device %s", node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -192,7 +191,7 @@ static void connect_devnode(const char *node) {
|
||||
/* Re-allocate array */
|
||||
struct input_device **tmp = realloc(devices, (2 * num_devices + 1) * sizeof(struct input_device *));
|
||||
if (!tmp) {
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Could not reallocate memory for input device array");
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Could not reallocate memory for input device array");
|
||||
return;
|
||||
}
|
||||
devices = tmp;
|
||||
@@ -215,14 +214,14 @@ static void connect_devnode(const char *node) {
|
||||
/* Initialise the indev and obtain the libinput device */
|
||||
device->indev = lv_libinput_create(LV_INDEV_TYPE_NONE, device->node);
|
||||
if (!device->indev) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Aborting connection of input device %s because libinput failed to connect it", node);
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Aborting connection of input device %s because libinput failed to connect it", node);
|
||||
disconnect_idx(num_connected_devices);
|
||||
return;
|
||||
}
|
||||
lv_libinput_t *dsc = lv_indev_get_driver_data(device->indev);
|
||||
struct libinput_device *device_libinput = dsc->libinput_device;
|
||||
if (!device_libinput) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Aborting connection of input device %s because libinput failed to connect it", node);
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Aborting connection of input device %s because libinput failed to connect it", node);
|
||||
disconnect_idx(num_connected_devices);
|
||||
return;
|
||||
}
|
||||
@@ -232,7 +231,7 @@ static void connect_devnode(const char *node) {
|
||||
|
||||
/* If the device doesn't have any supported capabilities, exit */
|
||||
if ((device->capability & allowed_capability) == LV_LIBINPUT_CAPABILITY_NONE) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Aborting connection of input device %s because it has no allowed capabilities", node);
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Aborting connection of input device %s because it has no allowed capabilities", node);
|
||||
disconnect_idx(num_connected_devices);
|
||||
return;
|
||||
}
|
||||
@@ -270,14 +269,14 @@ static void connect_devnode(const char *node) {
|
||||
/* Increment connected device count */
|
||||
num_connected_devices++;
|
||||
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, "Connected input device %s (%s)", node, capability_to_str(device->capability));
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, "Connected input device %s (%s)", node, capability_to_str(device->capability));
|
||||
}
|
||||
|
||||
static void disconnect_udev_device(struct udev_device *device) {
|
||||
/* Obtain and verify device node */
|
||||
const char *node = udev_device_get_devnode(device);
|
||||
if (!node || strncmp(node, INPUT_DEVICE_NODE_PREFIX, strlen(INPUT_DEVICE_NODE_PREFIX)) != 0) {
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, "Ignoring unsupported input device %s", udev_device_get_syspath(device));
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, "Ignoring unsupported input device %s", udev_device_get_syspath(device));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -297,7 +296,7 @@ static void disconnect_devnode(const char *node) {
|
||||
|
||||
/* If no matching device was found, exit */
|
||||
if (idx < 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Ignoring already disconnected input device %s", node);
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Ignoring already disconnected input device %s", node);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -317,7 +316,7 @@ static void disconnect_devnode(const char *node) {
|
||||
/* Decrement connected device count */
|
||||
--num_connected_devices;
|
||||
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, "Disconnected input device %s", node);
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, "Disconnected input device %s", node);
|
||||
}
|
||||
|
||||
static void disconnect_idx(int idx) {
|
||||
@@ -393,13 +392,13 @@ void ul_indev_set_keyboard_input_group(lv_group_t *group) {
|
||||
}
|
||||
|
||||
void ul_indev_auto_connect() {
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, "Auto-connecting supported input devices");
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, "Auto-connecting supported input devices");
|
||||
|
||||
/* Make sure udev context is initialised */
|
||||
if (!context) {
|
||||
context = udev_new();
|
||||
if (!context) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not create udev context");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not create udev context");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -420,7 +419,7 @@ void ul_indev_auto_connect() {
|
||||
/* Create udev device */
|
||||
struct udev_device *device = udev_device_new_from_syspath(context, path);
|
||||
if (!device) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not create udev device for %s", path);
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not create udev device for %s", path);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -440,40 +439,40 @@ void ul_indev_start_monitor() {
|
||||
if (!context) {
|
||||
context = udev_new();
|
||||
if (!context) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not create udev context");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not create udev context");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if monitor is already running */
|
||||
if (monitor) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Not starting udev monitor because it is already running");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Not starting udev monitor because it is already running");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create new monitor */
|
||||
monitor = udev_monitor_new_from_netlink(context, "udev");
|
||||
if (!monitor) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not create udev monitor");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not create udev monitor");
|
||||
ul_indev_stop_monitor();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Apply input subsystem filter */
|
||||
if (udev_monitor_filter_add_match_subsystem_devtype(monitor, "input", NULL) < 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not add input subsystem filter for udev monitor");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not add input subsystem filter for udev monitor");
|
||||
}
|
||||
|
||||
/* Start monitor */
|
||||
if (udev_monitor_enable_receiving(monitor) < 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not enable udev monitor");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not enable udev monitor");
|
||||
ul_indev_stop_monitor();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Obtain monitor file descriptor */
|
||||
if ((monitor_fd = udev_monitor_get_fd(monitor)) < 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not acquire file descriptor for udev monitor");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not acquire file descriptor for udev monitor");
|
||||
ul_indev_stop_monitor();
|
||||
return;
|
||||
}
|
||||
@@ -501,7 +500,7 @@ void ul_indev_stop_monitor() {
|
||||
void ul_indev_query_monitor() {
|
||||
/* Make sure the monitor is running */
|
||||
if (!monitor) {
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Cannot query udev monitor because it is not running");
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Cannot query udev monitor because it is not running");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -8,16 +8,16 @@
|
||||
#include "command_line.h"
|
||||
#include "config.h"
|
||||
#include "indev.h"
|
||||
#include "log.h"
|
||||
#include "unl0kr.h"
|
||||
#include "terminal.h"
|
||||
#include "theme.h"
|
||||
#include "themes.h"
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
#include "../shared/log.h"
|
||||
#include "../squeek2lvgl/sq2lv.h"
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@@ -375,11 +375,11 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
/* Set up log level */
|
||||
if (cli_opts.verbose) {
|
||||
ul_log_set_level(UL_LOG_LEVEL_VERBOSE);
|
||||
bb_log_set_level(BB_LOG_LEVEL_VERBOSE);
|
||||
}
|
||||
|
||||
/* Announce ourselves */
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, "unl0kr %s", UL_VERSION);
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, "unl0kr %s", UL_VERSION);
|
||||
|
||||
/* Parse config files */
|
||||
ul_config_init_opts(&conf_opts);
|
||||
@@ -397,7 +397,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
/* Initialise LVGL and set up logging callback */
|
||||
lv_init();
|
||||
lv_log_register_print_cb(ul_log_print_cb);
|
||||
lv_log_register_print_cb(bb_log_print_cb);
|
||||
|
||||
/* Start the tick thread */
|
||||
pthread_t ticker;
|
||||
@@ -422,7 +422,7 @@ int main(int argc, char *argv[]) {
|
||||
break;
|
||||
#endif /* LV_USE_LINUX_DRM */
|
||||
default:
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Unable to find suitable backend");
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Unable to find suitable backend");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@ unl0kr_sources = [
|
||||
'config.c',
|
||||
'font_32.c',
|
||||
'indev.c',
|
||||
'log.c',
|
||||
'main.c',
|
||||
'sq2lv_layouts.c',
|
||||
'terminal.c',
|
||||
@@ -27,7 +26,8 @@ unl0kr_sources = [
|
||||
]
|
||||
|
||||
shared_sources = [
|
||||
'../shared/cursor/cursor.c'
|
||||
'../shared/cursor/cursor.c',
|
||||
'../shared/log.c',
|
||||
]
|
||||
|
||||
squeek2lvgl_sources = [
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "terminal.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "../shared/log.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
@@ -53,7 +53,7 @@ static bool reopen_current_terminal(void) {
|
||||
|
||||
current_fd = open("/dev/tty0", O_RDWR);
|
||||
if (current_fd < 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not open /dev/tty0");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not open /dev/tty0");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -84,29 +84,29 @@ void ul_terminal_prepare_current_terminal(bool enable_graphics_mode, bool disabl
|
||||
reopen_current_terminal();
|
||||
|
||||
if (current_fd < 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not prepare current terminal");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not prepare current terminal");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Disable terminal keyboard input (hides entered text) */
|
||||
if (disable_keyboard_input) {
|
||||
if (ioctl(current_fd, KDGKBMODE, &original_kb_mode) != 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not get terminal keyboard mode");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not get terminal keyboard mode");
|
||||
}
|
||||
|
||||
if (ioctl(current_fd, KDSKBMODE, K_OFF) != 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not set terminal keyboard mode to off");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not set terminal keyboard mode to off");
|
||||
}
|
||||
}
|
||||
|
||||
/* Switch terminal into graphics mode (hides command prompt) */
|
||||
if (enable_graphics_mode) {
|
||||
if (ioctl(current_fd, KDGETMODE, &original_mode) != 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not get terminal mode");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not get terminal mode");
|
||||
}
|
||||
|
||||
if (ioctl(current_fd, KDSETMODE, KD_GRAPHICS) != 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not set terminal mode to graphics");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not set terminal mode to graphics");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,18 +114,18 @@ void ul_terminal_prepare_current_terminal(bool enable_graphics_mode, bool disabl
|
||||
void ul_terminal_reset_current_terminal(void) {
|
||||
/* If we haven't previously opened the current terminal, exit */
|
||||
if (current_fd < 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not reset current terminal");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not reset current terminal");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reset terminal mode if needed */
|
||||
if (original_mode >= 0 && ioctl(current_fd, KDSETMODE, original_mode) != 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not reset terminal mode");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not reset terminal mode");
|
||||
}
|
||||
|
||||
/* Reset terminal keyboard mode if needed */
|
||||
if (original_kb_mode >= 0 && ioctl(current_fd, KDSKBMODE, original_kb_mode) != 0) {
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Could not reset terminal keyboard mode");
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Could not reset terminal keyboard mode");
|
||||
}
|
||||
|
||||
close_current_terminal();
|
||||
|
@@ -6,10 +6,11 @@
|
||||
|
||||
#include "theme.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "sq2lv_layouts.h"
|
||||
#include "unl0kr.h"
|
||||
|
||||
#include "../shared/log.h"
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
|
||||
@@ -372,7 +373,7 @@ void ul_theme_prepare_keyboard(lv_obj_t *keyboard) {
|
||||
|
||||
void ul_theme_apply(const ul_theme *theme) {
|
||||
if (!theme) {
|
||||
ul_log(UL_LOG_LEVEL_ERROR, "Could not apply theme from NULL pointer");
|
||||
bb_log(BB_LOG_LEVEL_ERROR, "Could not apply theme from NULL pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,8 @@
|
||||
|
||||
#include "themes.h"
|
||||
|
||||
#include "../shared/log.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -657,10 +659,10 @@ const ul_theme *ul_themes_themes[] = {
|
||||
ul_themes_theme_id_t ul_themes_find_theme_with_name(const char *name) {
|
||||
for (int i = 0; i < ul_themes_num_themes; ++i) {
|
||||
if (strcmp(ul_themes_themes[i]->name, name) == 0) {
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, "Found theme: %s\n", name);
|
||||
bb_log(BB_LOG_LEVEL_VERBOSE, "Found theme: %s\n", name);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
ul_log(UL_LOG_LEVEL_WARNING, "Theme %s not found\n", name);
|
||||
bb_log(BB_LOG_LEVEL_WARNING, "Theme %s not found\n", name);
|
||||
return UL_THEMES_THEME_NONE;
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@
|
||||
#define UL_THEMES_H
|
||||
|
||||
#include "theme.h"
|
||||
#include "log.h"
|
||||
|
||||
/* Theme IDs, values can be used as indexes into the ul_themes_themes array */
|
||||
typedef enum {
|
||||
|
Reference in New Issue
Block a user