changed asset loading model
This commit is contained in:
parent
9026d54920
commit
72271ec8f4
@ -6,7 +6,7 @@ ASSETS=$(shell find devices/ -name '*.png')
|
||||
FINAL_ASSETS=$(BUILD_DIR)/drivers/assets/gwolves-htx.png $(BUILD_DIR)/drivers/assets/gwolves-hts_plus.png $(BUILD_DIR)/drivers/assets/gwolves-hsk_pro.png
|
||||
BUILD_DIR=../../build/
|
||||
|
||||
all: $(BUILD_DIR)/drivers/g-wolves.so
|
||||
all: $(BUILD_DIR)/drivers/g-wolves.so $(FINAL_ASSETS)
|
||||
|
||||
$(BUILD_DIR)/drivers/g-wolves.so: g-wolves.c | $(BUILD_DIR)/drivers/
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "utils/array.h"
|
||||
#include "usb/usb.h"
|
||||
#include <dlfcn.h>
|
||||
#include <string.h>
|
||||
|
||||
struct DEVICE
|
||||
{
|
||||
@ -39,7 +40,21 @@ device_t* device_register(void* driver, void* handle)
|
||||
char* device_get_image(device_t* device)
|
||||
{
|
||||
char* (*getimage_fn)(void*) = dlsym(device->driver, "driver_get_image");
|
||||
return getimage_fn(device->handle);
|
||||
char* image = getimage_fn(device->handle);
|
||||
size_t image_len = strlen(image);
|
||||
|
||||
// TODO : Change PATH so that 'build' becomes executable directory
|
||||
char* path = "build/drivers/assets/";
|
||||
size_t path_len = strlen(path);
|
||||
|
||||
char* tr = malloc(image_len + path_len + 1);
|
||||
memcpy(tr, path, path_len);
|
||||
memcpy(tr + path_len, image, image_len);
|
||||
*(tr + path_len + image_len) = 0;
|
||||
|
||||
printf("path= %s\n", tr);
|
||||
|
||||
return tr;
|
||||
}
|
||||
|
||||
char* device_get_name(device_t* device)
|
||||
|
@ -37,6 +37,8 @@ mouse_panel_new(void)
|
||||
|
||||
void mouse_panel_set_device(MousePanel* self, device_t* device)
|
||||
{
|
||||
gtk_image_set_from_file(self->mouse_image, device_get_image(device));
|
||||
char* image = device_get_image(device);
|
||||
gtk_image_set_from_file(self->mouse_image, image);
|
||||
gtk_label_set_label(self->mouse_name, device_get_name(device));
|
||||
free(image);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user