mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-29 06:40:08 +01:00
tools/demo-client: make the XKB layout a commandline argument
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
901235af5c
commit
04dab83115
1 changed files with 13 additions and 5 deletions
|
|
@ -76,7 +76,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(struct xkb_state*, xkb_state_unref);
|
|||
#endif
|
||||
|
||||
static void
|
||||
setup_keymap(struct ei_device *kbd)
|
||||
setup_keymap(struct ei_device *kbd, const char *layout)
|
||||
{
|
||||
#if HAVE_LIBXKBCOMMON
|
||||
_cleanup_xkb_context_ struct xkb_context *ctx =
|
||||
|
|
@ -87,7 +87,7 @@ setup_keymap(struct ei_device *kbd)
|
|||
struct xkb_rule_names names = {
|
||||
.rules = "evdev",
|
||||
.model = "pc105",
|
||||
.layout = "fr",
|
||||
.layout = layout,
|
||||
};
|
||||
|
||||
_cleanup_xkb_keymap_ struct xkb_keymap *keymap =
|
||||
|
|
@ -112,7 +112,7 @@ static void
|
|||
usage(FILE *fp, const char *argv0)
|
||||
{
|
||||
fprintf(fp,
|
||||
"Usage: %s [--verbose] [--socket]\n"
|
||||
"Usage: %s [--verbose] [--socket] [--layout=us]\n"
|
||||
"\n"
|
||||
"Start an EI demo client. The client will connect to EIS\n"
|
||||
"with the chosen backend (default: socket) and emulate pointer\n"
|
||||
|
|
@ -120,7 +120,8 @@ usage(FILE *fp, const char *argv0)
|
|||
"\n"
|
||||
"Options:\n"
|
||||
" --socket Use the socket backend. The socket path is $LIBEI_SOCKET if set, \n"
|
||||
" otherwise XDG_RUNTIME/eis-0\n",
|
||||
" otherwise XDG_RUNTIME/eis-0\n"
|
||||
" --layout Use the given XKB layout (requires libxkbcommon). Default: none\n"
|
||||
" --verbose Enable debugging output\n",
|
||||
argv0);
|
||||
}
|
||||
|
|
@ -131,14 +132,17 @@ int main(int argc, char **argv)
|
|||
SOCKET,
|
||||
} backend = SOCKET;
|
||||
bool verbose = false;
|
||||
const char *layout = NULL;
|
||||
|
||||
while (1) {
|
||||
enum {
|
||||
OPT_BACKEND_SOCKET,
|
||||
OPT_LAYOUT,
|
||||
OPT_VERBOSE,
|
||||
};
|
||||
static struct option long_opts[] = {
|
||||
{"socket", no_argument, 0, OPT_BACKEND_SOCKET},
|
||||
{"layout", required_argument, 0, OPT_LAYOUT},
|
||||
{"verbose", no_argument, 0, OPT_VERBOSE},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{NULL},
|
||||
|
|
@ -159,6 +163,9 @@ int main(int argc, char **argv)
|
|||
case OPT_BACKEND_SOCKET:
|
||||
backend = SOCKET;
|
||||
break;
|
||||
case OPT_LAYOUT:
|
||||
layout = optarg;
|
||||
break;
|
||||
default:
|
||||
usage(stderr, argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -197,7 +204,8 @@ int main(int argc, char **argv)
|
|||
|
||||
_cleanup_(ei_device_unrefp) struct ei_device *kbd = ei_device_new(ei);
|
||||
ei_device_configure_capability(kbd, EI_DEVICE_CAP_KEYBOARD);
|
||||
setup_keymap(kbd);
|
||||
if (layout)
|
||||
setup_keymap(kbd, layout);
|
||||
|
||||
bool stop = false;
|
||||
bool have_ptr = false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue