forked from drath/libratbag
lur: add lur_device_get/set_userdata
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> BT: move the functions in LIBLUR_0.4.0 Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
13
src/liblur.c
13
src/liblur.c
@@ -50,6 +50,7 @@ struct lur_receiver {
|
||||
struct lur_device {
|
||||
struct lur_receiver *receiver;
|
||||
int refcount;
|
||||
void *userdata;
|
||||
|
||||
char *name;
|
||||
uint16_t vid, pid;
|
||||
@@ -347,3 +348,15 @@ lur_device_unref(struct lur_device *dev)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_EXPORT_ void
|
||||
lur_device_set_user_data(struct lur_device *dev, void *userdata)
|
||||
{
|
||||
dev->userdata = userdata;
|
||||
}
|
||||
|
||||
_EXPORT_ void*
|
||||
lur_device_get_user_data(const struct lur_device *dev)
|
||||
{
|
||||
return dev->userdata;
|
||||
}
|
||||
|
||||
21
src/liblur.h
21
src/liblur.h
@@ -239,6 +239,27 @@ lur_device_ref(struct lur_device *dev);
|
||||
struct lur_device *
|
||||
lur_device_unref(struct lur_device *dev);
|
||||
|
||||
/**
|
||||
* Set caller-specific data associated with this object. liblur does
|
||||
* not manage, look at, or modify this data. The caller must ensure the
|
||||
* data is valid.
|
||||
*
|
||||
* @param dev A valid device object
|
||||
* @param userdata Caller-specific data
|
||||
*/
|
||||
void
|
||||
lur_device_set_user_data(struct lur_device *dev, void *userdata);
|
||||
|
||||
/**
|
||||
* Get the caller-specific data associated with this object, if any.
|
||||
*
|
||||
* @param dev A valid device object
|
||||
* @return The caller-specific data previously assigned in
|
||||
* lur_device_set_user_data().
|
||||
*/
|
||||
void*
|
||||
lur_device_get_user_data(const struct lur_device *dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -23,3 +23,9 @@ global:
|
||||
local:
|
||||
*;
|
||||
};
|
||||
|
||||
LIBLUR_0.4.0 {
|
||||
global:
|
||||
lur_device_get_user_data;
|
||||
lur_device_set_user_data;
|
||||
} LIBLUR_0.3.0;
|
||||
|
||||
Reference in New Issue
Block a user