Graphical improvements, fix compile warnings

master
vhaudiquet 1 year ago
parent 7c4b41666b
commit 8205d7e27a
  1. 2
      README.md
  2. 5
      drivers/g-wolves/g-wolves.c
  3. 1
      drivers/g-wolves/g-wolves.h
  4. 1
      src/device/driver_interface.h
  5. 5
      src/ui/main-window.c
  6. 2
      src/ui/panels/empty-panel.c
  7. 21
      src/ui/panels/mouse-panel.c
  8. 20
      ui/panel-mouse.ui

@ -10,9 +10,11 @@ Drivers **must** expose the following symbols:
```c
void driver_init(); // Initialization
uint32_t driver_getkey(); // Calls to this function must return USB keys that this driver registers, until 0
device_type_t driver_get_capacity(); // Returns device capacity (see below)
char* driver_get_name(void* handle); // Returns peripheral name
char* driver_get_image(void* handle); // Returns peripheral image
char* driver_get_manufacturer(void* handle); // Returns manufacturer name
/*
* Mouse drivers

@ -94,6 +94,11 @@ device_capacity_t driver_get_capacity(void* handle)
return DEVICE_CAPACITY_MOUSE | wireless;
}
char* driver_get_manufacturer(void* handle)
{
return MANUFACTURER_NAME;
}
char* driver_get_name(void* handle)
{
libusb_device* dev = handle;

@ -20,6 +20,7 @@
#include "devices/hts_plus.h"
#include "devices/hsk_pro.h"
#define MANUFACTURER_NAME "G-Wolves"
#define VENDOR_ID 0x33e4
#define REPORT_MAX_SIZE 0x40 // 64 Bytes

@ -15,6 +15,7 @@ uint32_t driver_getkey(); // Calls to this function must return USB keys that th
device_capacity_t driver_get_capacity(void* handle); // Returns device capacity (see above)
char* driver_get_name(void* handle); // Returns peripheral name
char* driver_get_manufacturer(void* handle); // Returns peripheral manufacturer
char* driver_get_image(void* handle); // Returns peripheral image
/* Mouse drivers */

@ -48,6 +48,7 @@ static gboolean activate_panel(MainWindow* self, Panel* panel, const gchar* id)
self->active_panel = panel;
gtk_stack_add_named(self->stack, self->current_panel, id);
gtk_stack_set_visible_child_name (self->stack, id);
return true;
}
/*
@ -56,7 +57,7 @@ static gboolean activate_panel(MainWindow* self, Panel* panel, const gchar* id)
static void
main_window_map(GtkWidget* widget)
{
MainWindow* self = (MainWindow*) widget;
// MainWindow* self = (MainWindow*) widget;
GTK_WIDGET_CLASS(main_window_parent_class)->map(widget);
}
@ -176,7 +177,7 @@ void main_window_device_selected(GtkListBox* self, GtkListBoxRow* row, gpointer
}
device_t* device = (device_t*) g_object_get_data(G_OBJECT(row), "ginput_device");
MousePanel* mp = (Panel*) mouse_panel_new();
MousePanel* mp = (MousePanel*) mouse_panel_new();
mouse_panel_set_device(mp, device);
// TODO : change and use already added child if possible

@ -10,9 +10,7 @@ G_DEFINE_TYPE (EmptyPanel, empty_panel, panel_get_type())
static void
empty_panel_class_init(EmptyPanelClass* klass)
{
GObjectClass* object_class = G_OBJECT_CLASS(klass);
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
PanelClass* panel_class = GINPUT_PANEL_CLASS(klass);
gtk_widget_class_set_template_from_resource(widget_class, "/v/ginput/panel-empty.ui");
}

@ -5,8 +5,10 @@ struct _MousePanel
Panel parent_instance;
GtkImage* mouse_image;
GtkLabel* mouse_manufacturer;
GtkLabel* mouse_name;
AdwPreferencesGroup* dpi_preference_group;
AdwButtonContent* dpi_stage_add_button;
};
G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type())
@ -14,15 +16,15 @@ G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type())
static void
mouse_panel_class_init(MousePanelClass* klass)
{
GObjectClass* object_class = G_OBJECT_CLASS(klass);
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
PanelClass* panel_class = GINPUT_PANEL_CLASS(klass);
gtk_widget_class_set_template_from_resource(widget_class, "/v/ginput/panel-mouse.ui");
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_image);
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_manufacturer);
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_name);
gtk_widget_class_bind_template_child(widget_class, MousePanel, dpi_preference_group);
gtk_widget_class_bind_template_child(widget_class, MousePanel, dpi_stage_add_button);
}
static void
@ -44,15 +46,26 @@ void mouse_panel_set_device(MousePanel* self, device_t* device)
gtk_image_set_from_file(self->mouse_image, image);
free(image);
// Set device manufacturer
char* (*getmanufacturer_fn)(void*) = dlsym(device_driver(device), "driver_get_manufacturer");
gtk_label_set_label(self->mouse_manufacturer, getmanufacturer_fn(device_handle(device)));
// Set device name
gtk_label_set_label(self->mouse_name, device_get_name(device));
// TODO inner window title
char* device_name = device_get_name(device);
gtk_label_set_label(self->mouse_name, device_name);
// Set mouse dpi
struct MOUSE_DPI_LEVELS dpi;
int (*driver_mouse_dpi_get)(void*, void*) = dlsym(device_driver(device), "driver_mouse_dpi_get");
int dpi_res = driver_mouse_dpi_get(device_handle(device), &dpi);
if(!dpi_res)
{
// Set dpi used/max label in add button
char dpi_used_max[10];
sprintf(dpi_used_max, "%u/%u", dpi.level_count, dpi.max_level_count);
adw_button_content_set_label(self->dpi_stage_add_button, dpi_used_max);
// Set dpi list
for(size_t i = 0; i < dpi.level_count; i++)
{

@ -23,6 +23,15 @@
<style />
</object>
</child>
<child>
<object class="GtkLabel" id="mouse_manufacturer">
<property name="halign">center</property>
<property name="justify">center</property>
<style>
<class name="heading" />
</style>
</object>
</child>
<child>
<object class="GtkLabel" id="mouse_name">
<property name="halign">center</property>
@ -57,6 +66,17 @@
<property name="valign">start</property>
<child>
<object class="AdwPreferencesGroup" id="dpi_preference_group">
<property name="header-suffix">
<object class="GtkButton">
<property name="child">
<object class="AdwButtonContent" id="dpi_stage_add_button">
<property name="icon-name">list-add-symbolic</property>
<property name="label">1/1</property>
<property name="use-underline">True</property>
</object>
</property>
</object>
</property>
<property name="width-request">300</property>
<property name="title">DPI Stages</property>
<property name="description">DPI Stages of the mouse</property>

Loading…
Cancel
Save