Graphical improvements, fix compile warnings
This commit is contained in:
parent
7c4b41666b
commit
8205d7e27a
@ -10,9 +10,11 @@ Drivers **must** expose the following symbols:
|
|||||||
```c
|
```c
|
||||||
void driver_init(); // Initialization
|
void driver_init(); // Initialization
|
||||||
uint32_t driver_getkey(); // Calls to this function must return USB keys that this driver registers, until 0
|
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)
|
device_type_t driver_get_capacity(); // Returns device capacity (see below)
|
||||||
char* driver_get_name(void* handle); // Returns peripheral name
|
char* driver_get_name(void* handle); // Returns peripheral name
|
||||||
char* driver_get_image(void* handle); // Returns peripheral image
|
char* driver_get_image(void* handle); // Returns peripheral image
|
||||||
|
char* driver_get_manufacturer(void* handle); // Returns manufacturer name
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mouse drivers
|
* Mouse drivers
|
||||||
|
@ -94,6 +94,11 @@ device_capacity_t driver_get_capacity(void* handle)
|
|||||||
return DEVICE_CAPACITY_MOUSE | wireless;
|
return DEVICE_CAPACITY_MOUSE | wireless;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* driver_get_manufacturer(void* handle)
|
||||||
|
{
|
||||||
|
return MANUFACTURER_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
char* driver_get_name(void* handle)
|
char* driver_get_name(void* handle)
|
||||||
{
|
{
|
||||||
libusb_device* dev = handle;
|
libusb_device* dev = handle;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "devices/hts_plus.h"
|
#include "devices/hts_plus.h"
|
||||||
#include "devices/hsk_pro.h"
|
#include "devices/hsk_pro.h"
|
||||||
|
|
||||||
|
#define MANUFACTURER_NAME "G-Wolves"
|
||||||
#define VENDOR_ID 0x33e4
|
#define VENDOR_ID 0x33e4
|
||||||
|
|
||||||
#define REPORT_MAX_SIZE 0x40 // 64 Bytes
|
#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)
|
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_name(void* handle); // Returns peripheral name
|
||||||
|
char* driver_get_manufacturer(void* handle); // Returns peripheral manufacturer
|
||||||
char* driver_get_image(void* handle); // Returns peripheral image
|
char* driver_get_image(void* handle); // Returns peripheral image
|
||||||
|
|
||||||
/* Mouse drivers */
|
/* Mouse drivers */
|
||||||
|
@ -48,6 +48,7 @@ static gboolean activate_panel(MainWindow* self, Panel* panel, const gchar* id)
|
|||||||
self->active_panel = panel;
|
self->active_panel = panel;
|
||||||
gtk_stack_add_named(self->stack, self->current_panel, id);
|
gtk_stack_add_named(self->stack, self->current_panel, id);
|
||||||
gtk_stack_set_visible_child_name (self->stack, 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
|
static void
|
||||||
main_window_map(GtkWidget* widget)
|
main_window_map(GtkWidget* widget)
|
||||||
{
|
{
|
||||||
MainWindow* self = (MainWindow*) widget;
|
// MainWindow* self = (MainWindow*) widget;
|
||||||
GTK_WIDGET_CLASS(main_window_parent_class)->map(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");
|
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);
|
mouse_panel_set_device(mp, device);
|
||||||
|
|
||||||
// TODO : change and use already added child if possible
|
// TODO : change and use already added child if possible
|
||||||
|
@ -10,9 +10,7 @@ G_DEFINE_TYPE (EmptyPanel, empty_panel, panel_get_type())
|
|||||||
static void
|
static void
|
||||||
empty_panel_class_init(EmptyPanelClass* klass)
|
empty_panel_class_init(EmptyPanelClass* klass)
|
||||||
{
|
{
|
||||||
GObjectClass* object_class = G_OBJECT_CLASS(klass);
|
|
||||||
GtkWidgetClass* widget_class = GTK_WIDGET_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");
|
gtk_widget_class_set_template_from_resource(widget_class, "/v/ginput/panel-empty.ui");
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,10 @@ struct _MousePanel
|
|||||||
Panel parent_instance;
|
Panel parent_instance;
|
||||||
|
|
||||||
GtkImage* mouse_image;
|
GtkImage* mouse_image;
|
||||||
|
GtkLabel* mouse_manufacturer;
|
||||||
GtkLabel* mouse_name;
|
GtkLabel* mouse_name;
|
||||||
AdwPreferencesGroup* dpi_preference_group;
|
AdwPreferencesGroup* dpi_preference_group;
|
||||||
|
AdwButtonContent* dpi_stage_add_button;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type())
|
G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type())
|
||||||
@ -14,15 +16,15 @@ G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type())
|
|||||||
static void
|
static void
|
||||||
mouse_panel_class_init(MousePanelClass* klass)
|
mouse_panel_class_init(MousePanelClass* klass)
|
||||||
{
|
{
|
||||||
GObjectClass* object_class = G_OBJECT_CLASS(klass);
|
|
||||||
GtkWidgetClass* widget_class = GTK_WIDGET_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_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_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, mouse_name);
|
||||||
gtk_widget_class_bind_template_child(widget_class, MousePanel, dpi_preference_group);
|
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
|
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);
|
gtk_image_set_from_file(self->mouse_image, image);
|
||||||
free(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
|
// 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
|
// Set mouse dpi
|
||||||
struct MOUSE_DPI_LEVELS dpi;
|
struct MOUSE_DPI_LEVELS dpi;
|
||||||
int (*driver_mouse_dpi_get)(void*, void*) = dlsym(device_driver(device), "driver_mouse_dpi_get");
|
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);
|
int dpi_res = driver_mouse_dpi_get(device_handle(device), &dpi);
|
||||||
if(!dpi_res)
|
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
|
// Set dpi list
|
||||||
for(size_t i = 0; i < dpi.level_count; i++)
|
for(size_t i = 0; i < dpi.level_count; i++)
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,15 @@
|
|||||||
<style />
|
<style />
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</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>
|
<child>
|
||||||
<object class="GtkLabel" id="mouse_name">
|
<object class="GtkLabel" id="mouse_name">
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
@ -57,6 +66,17 @@
|
|||||||
<property name="valign">start</property>
|
<property name="valign">start</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwPreferencesGroup" id="dpi_preference_group">
|
<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="width-request">300</property>
|
||||||
<property name="title">DPI Stages</property>
|
<property name="title">DPI Stages</property>
|
||||||
<property name="description">DPI Stages of the mouse</property>
|
<property name="description">DPI Stages of the mouse</property>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user