Skip to content

Commit

Permalink
Rename stylus->id to stylus->tool_id in prep for multi-vendor styli
Browse files Browse the repository at this point in the history
This is preparation work to add a vendor ID for styli in the future.
Rename the current single-item "id" to "tool_id" for a future
vid/tool_id pair.
  • Loading branch information
whot committed Oct 4, 2024
1 parent 3d276a2 commit be6ef19
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions libwacom/libwacom-database.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,17 @@ libwacom_parse_stylus_keyfile(WacomDeviceDatabase *db, const char *path)
WacomStylus *stylus;
GError *error = NULL;
char *eraser_type, *type;
int id;
int tool_id;
char **string_list;

if (!safe_atoi_base (groups[i], &id, 16)) {
if (!safe_atoi_base (groups[i], &tool_id, 16)) {
g_warning ("Failed to parse stylus ID '%s'", groups[i]);
continue;
}

stylus = g_new0 (WacomStylus, 1);
stylus->refcnt = 1;
stylus->id = id;
stylus->tool_id = tool_id;
stylus->name = g_key_file_get_string(keyfile, groups[i], "Name", NULL);
stylus->group = g_key_file_get_string(keyfile, groups[i], "Group", NULL);

Expand Down Expand Up @@ -346,10 +346,10 @@ libwacom_parse_stylus_keyfile(WacomDeviceDatabase *db, const char *path)
stylus->type = type_from_str (type);
g_clear_pointer(&type, g_free);

if (g_hash_table_lookup (db->stylus_ht, GINT_TO_POINTER (id)) != NULL)
g_warning ("Duplicate definition for stylus ID '%#x'", id);
if (g_hash_table_lookup (db->stylus_ht, GINT_TO_POINTER (tool_id)) != NULL)
g_warning ("Duplicate definition for stylus ID '%#x'", tool_id);

g_hash_table_insert (db->stylus_ht, GINT_TO_POINTER (id), stylus);
g_hash_table_insert (db->stylus_ht, GINT_TO_POINTER (tool_id), stylus);
}
g_clear_pointer(&groups, g_strfreev);
g_clear_pointer(&keyfile, g_key_file_free);
Expand Down Expand Up @@ -721,7 +721,7 @@ libwacom_parse_styli_list(WacomDeviceDatabase *db, WacomDevice *device,
while (g_hash_table_iter_next (&iter, &key, &value)) {
WacomStylus *stylus = value;
if (stylus->group && g_str_equal(group, stylus->group)) {
g_array_append_val (array, stylus->id);
g_array_append_val (array, stylus->tool_id);
}
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions libwacom/libwacom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ libwacom_stylus_get_for_id (const WacomDeviceDatabase *db, int id)
LIBWACOM_EXPORT int
libwacom_stylus_get_id (const WacomStylus *stylus)
{
return stylus->id;
return stylus->tool_id;
}

LIBWACOM_EXPORT const char *
Expand All @@ -1564,7 +1564,7 @@ LIBWACOM_EXPORT int
libwacom_stylus_get_num_buttons (const WacomStylus *stylus)
{
if (stylus->num_buttons == -1) {
g_warning ("Stylus '0x%x' has no number of buttons defined, falling back to 2", stylus->id);
g_warning ("Stylus '0x%x' has no number of buttons defined, falling back to 2", stylus->tool_id);
return 2;
}
return stylus->num_buttons;
Expand Down Expand Up @@ -1604,7 +1604,7 @@ LIBWACOM_EXPORT WacomStylusType
libwacom_stylus_get_type (const WacomStylus *stylus)
{
if (stylus->type == WSTYLUS_UNKNOWN) {
g_warning ("Stylus '0x%x' has no type defined, falling back to 'General'", stylus->id);
g_warning ("Stylus '0x%x' has no type defined, falling back to 'General'", stylus->tool_id);
return WSTYLUS_GENERAL;
}
return stylus->type;
Expand Down
2 changes: 1 addition & 1 deletion libwacom/libwacomint.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ struct _WacomDevice {

struct _WacomStylus {
gint refcnt;
int id;
int tool_id;
char *name;
char *group;
int num_buttons;
Expand Down

0 comments on commit be6ef19

Please sign in to comment.