mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-05 07:48:01 +02:00
libeis: namespace the capability-specific getters and setters
Naming scheme is now: ei_device_<capability>_get/set_<what>. So far the range is the only one where we had to deal with the same thing for two different capabilities and it's unlikely we'll have to have different keymaps for different capabilities. But still, let's do this now while it's still easy. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
e4840d4523
commit
4a918d17d8
6 changed files with 33 additions and 33 deletions
|
|
@ -56,17 +56,17 @@ function event_device_added(event):
|
|||
# monitor with those dimensions and map the device to that monitor
|
||||
# That's a server private implementation detail, just used as
|
||||
# example here
|
||||
w = eis_device_get_pointer_width()
|
||||
h = eis_device_get_pointer_height()
|
||||
w = eis_device_pointer_get_width()
|
||||
h = eis_device_pointer_get_height()
|
||||
if (w, h) matches an output:
|
||||
eis_device_set_user_data(output)
|
||||
|
||||
if eis_device_has_capability(EIS_CAP_KEYBOARD):
|
||||
keymap = eis_device_get_keymap()
|
||||
keymap = eis_device_keyboard_get_keymap()
|
||||
# We do not implement per-device keymap in this pseudoserver, notify
|
||||
# the client. If we did, here'd be the place to assign the map.
|
||||
if keymap != -1:
|
||||
eis_device_set_keymap(device, -1)
|
||||
eis_device_keyboard_set_keymap(device, -1)
|
||||
|
||||
eis_device_connect(device)
|
||||
# Allow the client to send events
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ eis_device_set_client_keymap(struct eis_device *device,
|
|||
}
|
||||
|
||||
_public_ void
|
||||
eis_device_set_keymap(struct eis_device *device,
|
||||
eis_device_keyboard_set_keymap(struct eis_device *device,
|
||||
enum eis_keymap_type type,
|
||||
int keymap_fd, size_t size)
|
||||
{
|
||||
|
|
@ -147,43 +147,43 @@ eis_device_disable_capability(struct eis_device *device,
|
|||
}
|
||||
|
||||
_public_ uint32_t
|
||||
eis_device_get_pointer_width(struct eis_device *device)
|
||||
eis_device_pointer_get_width(struct eis_device *device)
|
||||
{
|
||||
return device->abs.dim.width;
|
||||
}
|
||||
|
||||
_public_ uint32_t
|
||||
eis_device_get_pointer_height(struct eis_device *device)
|
||||
eis_device_pointer_get_height(struct eis_device *device)
|
||||
{
|
||||
return device->abs.dim.height;
|
||||
}
|
||||
|
||||
_public_ uint32_t
|
||||
eis_device_get_touch_width(struct eis_device *device)
|
||||
eis_device_touch_get_width(struct eis_device *device)
|
||||
{
|
||||
return device->touch.dim.width;
|
||||
}
|
||||
|
||||
_public_ uint32_t
|
||||
eis_device_get_touch_height(struct eis_device *device)
|
||||
eis_device_touch_get_height(struct eis_device *device)
|
||||
{
|
||||
return device->touch.dim.height;
|
||||
}
|
||||
|
||||
_public_ enum eis_keymap_type
|
||||
eis_device_get_keymap_type(struct eis_device *device)
|
||||
eis_device_keyboard_get_keymap_type(struct eis_device *device)
|
||||
{
|
||||
return device->keymap.type;
|
||||
}
|
||||
|
||||
_public_ size_t
|
||||
eis_device_get_keymap_size(struct eis_device *device)
|
||||
eis_device_keyboard_get_keymap_size(struct eis_device *device)
|
||||
{
|
||||
return device->keymap.size;
|
||||
}
|
||||
|
||||
_public_ int
|
||||
eis_device_get_keymap(struct eis_device *device)
|
||||
eis_device_keyboard_get_keymap(struct eis_device *device)
|
||||
{
|
||||
return device->keymap.fd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ eis_device_set_client_keymap(struct eis_device *device,
|
|||
int keymap_fd, size_t size);
|
||||
|
||||
void
|
||||
eis_device_set_keymap(struct eis_device *device,
|
||||
eis_device_keyboard_set_keymap(struct eis_device *device,
|
||||
enum eis_keymap_type type,
|
||||
int keymap_fd, size_t size);
|
||||
|
||||
|
|
|
|||
24
src/libeis.h
24
src/libeis.h
|
|
@ -399,25 +399,25 @@ eis_device_resume(struct eis_device *device);
|
|||
* @return The new width in logical pixels
|
||||
*/
|
||||
uint32_t
|
||||
eis_device_get_pointer_width(struct eis_device *device);
|
||||
eis_device_pointer_get_width(struct eis_device *device);
|
||||
|
||||
/**
|
||||
* @see eis_device_get_pointer_width
|
||||
* @see eis_device_pointer_get_width
|
||||
*/
|
||||
uint32_t
|
||||
eis_device_get_pointer_height(struct eis_device *device);
|
||||
eis_device_pointer_get_height(struct eis_device *device);
|
||||
|
||||
/**
|
||||
* @see eis_device_get_pointer_width
|
||||
* @see eis_device_pointer_get_width
|
||||
*/
|
||||
uint32_t
|
||||
eis_device_get_touch_width(struct eis_device *device);
|
||||
eis_device_touch_get_width(struct eis_device *device);
|
||||
|
||||
/**
|
||||
* @see eis_device_get_touch_width
|
||||
* @see eis_device_touch_get_width
|
||||
*/
|
||||
uint32_t
|
||||
eis_device_get_touch_height(struct eis_device *device);
|
||||
eis_device_touch_get_height(struct eis_device *device);
|
||||
|
||||
/**
|
||||
* Return a memmap-able file descriptor pointing to the keymap used by the
|
||||
|
|
@ -428,18 +428,18 @@ eis_device_get_touch_height(struct eis_device *device);
|
|||
* an individual keymap assigned.
|
||||
*/
|
||||
int
|
||||
eis_device_get_keymap(struct eis_device *device);
|
||||
eis_device_keyboard_get_keymap(struct eis_device *device);
|
||||
|
||||
size_t
|
||||
eis_device_get_keymap_size(struct eis_device *device);
|
||||
eis_device_keyboard_get_keymap_size(struct eis_device *device);
|
||||
|
||||
enum eis_keymap_type
|
||||
eis_device_get_keymap_type(struct eis_device *device);
|
||||
eis_device_keyboard_get_keymap_type(struct eis_device *device);
|
||||
|
||||
/**
|
||||
* Set the keymap on the device. This overwrites the client's choice of
|
||||
* keyboard. Note that **not** calling this function when
|
||||
* eis_device_get_keymap() returns a value other than -1 is equivalent to
|
||||
* eis_device_keyboard_get_keymap() returns a value other than -1 is equivalent to
|
||||
* accepting the client's choice of keymap.
|
||||
*
|
||||
* If the fd is not -1, it is a memmap-able file descriptor pointing to the
|
||||
|
|
@ -458,7 +458,7 @@ eis_device_get_keymap_type(struct eis_device *device);
|
|||
* @param fd a memmap-able file descriptor to the keymap
|
||||
*/
|
||||
void
|
||||
eis_device_set_keymap(struct eis_device *device,
|
||||
eis_device_keyboard_set_keymap(struct eis_device *device,
|
||||
enum eis_keymap_type type,
|
||||
int fd, size_t size);
|
||||
|
||||
|
|
|
|||
|
|
@ -100,10 +100,10 @@ MUNIT_TEST(eistest_ranges)
|
|||
struct eis_device *device = eis_event_get_device(event);
|
||||
munit_assert(eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE));
|
||||
munit_assert(eis_device_has_capability(device, EIS_DEVICE_CAP_TOUCH));
|
||||
munit_assert_int(eis_device_get_pointer_width(device), ==, 1024);
|
||||
munit_assert_int(eis_device_get_pointer_height(device), ==, 768);
|
||||
munit_assert_int(eis_device_get_touch_width(device), ==, 1920);
|
||||
munit_assert_int(eis_device_get_touch_height(device), ==, 1200);
|
||||
munit_assert_int(eis_device_pointer_get_width(device), ==, 1024);
|
||||
munit_assert_int(eis_device_pointer_get_height(device), ==, 768);
|
||||
munit_assert_int(eis_device_touch_get_width(device), ==, 1920);
|
||||
munit_assert_int(eis_device_touch_get_height(device), ==, 1200);
|
||||
}
|
||||
|
||||
return MUNIT_OK;
|
||||
|
|
|
|||
|
|
@ -116,17 +116,17 @@ setup_keymap(struct eis_demo_server *server, struct eis_device *device)
|
|||
if (!f)
|
||||
return;
|
||||
|
||||
eis_device_set_keymap(device, EIS_KEYMAP_TYPE_XKB,
|
||||
eis_device_keyboard_set_keymap(device, EIS_KEYMAP_TYPE_XKB,
|
||||
memfile_get_fd(f), memfile_get_size(f));
|
||||
memfile_unref(f);
|
||||
}
|
||||
|
||||
if (eis_device_get_keymap_type(device) == EIS_KEYMAP_TYPE_NONE)
|
||||
if (eis_device_keyboard_get_keymap_type(device) == EIS_KEYMAP_TYPE_NONE)
|
||||
return;
|
||||
|
||||
colorprint("Using client keymap\n");
|
||||
int fd = eis_device_get_keymap(device);
|
||||
size_t size = eis_device_get_keymap_size(device);
|
||||
int fd = eis_device_keyboard_get_keymap(device);
|
||||
size_t size = eis_device_keyboard_get_keymap_size(device);
|
||||
char *str = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (str == MAP_FAILED)
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue