parent
fe241126bb
commit
28081b7689
@ -0,0 +1,66 @@
|
||||
#.rst:
|
||||
# FindLibInput
|
||||
# -------
|
||||
#
|
||||
# Find LibInput library
|
||||
#
|
||||
# Try to find LibInpu library. The following values are defined
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# LIBINPUT_FOUND - True if libinput is available
|
||||
# LIBINPUT_INCLUDE_DIRS - Include directories for libinput
|
||||
# LIBINPUT_LIBRARIES - List of libraries for libinput
|
||||
# LIBINPUT_DEFINITIONS - List of definitions for libinput
|
||||
#
|
||||
# and also the following more fine grained variables
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# LIBINPUT_VERSION
|
||||
# LIBINPUT_VERSION_MAJOR
|
||||
# LIBINPUT_VERSION_MINOR
|
||||
# LIBINPUT_VERSION_MICRO
|
||||
#
|
||||
#=============================================================================
|
||||
# Copyright (c) 2015 Jari Vetoniemi
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
include(FeatureSummary)
|
||||
set_package_properties(LibInput PROPERTIES
|
||||
URL "http://freedesktop.org/wiki/Software/libinput/"
|
||||
DESCRIPTION "Library to handle input devices")
|
||||
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(PC_INPUT QUIET libinput)
|
||||
find_library(LIBINPUT_LIBRARIES NAMES input HINTS ${PC_INPUT_LIBRARY_DIRS})
|
||||
find_path(LIBINPUT_INCLUDE_DIRS libinput.h HINTS ${PC_INPUT_INCLUDE_DIRS})
|
||||
|
||||
set(LIBINPUT_VERSION ${PC_INPUT_VERSION})
|
||||
string(REPLACE "." ";" VERSION_LIST "${PC_INPUT_VERSION}")
|
||||
|
||||
LIST(LENGTH VERSION_LIST n)
|
||||
if (n EQUAL 3)
|
||||
list(GET VERSION_LIST 0 LIBINPUT_VERSION_MAJOR)
|
||||
list(GET VERSION_LIST 1 LIBINPUT_VERSION_MINOR)
|
||||
list(GET VERSION_LIST 2 LIBINPUT_VERSION_MICRO)
|
||||
endif ()
|
||||
|
||||
# This is compatible with libinput-version.h that exists in upstream
|
||||
# but isn't in distribution (probably forgotten)
|
||||
set(LIBINPUT_DEFINITIONS ${PC_INPUT_CFLAGS_OTHER}
|
||||
-DLIBINPUT_VERSION=\"${LIBINPUT_VERSION}\"
|
||||
-DLIBINPUT_VERSION_MAJOR=${LIBINPUT_VERSION_MAJOR}
|
||||
-DLIBINPUT_VERSION_MINOR=${LIBINPUT_VERSION_MINOR}
|
||||
-DLIBINPUT_VERSION_MICRO=${LIBINPUT_VERSION_MICRO})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LIBINPUT DEFAULT_MSG LIBINPUT_INCLUDE_DIRS LIBINPUT_LIBRARIES)
|
||||
mark_as_advanced(LIBINPUT_INCLUDE_DIRS LIBINPUT_LIBRARIES LIBINPUT_DEFINITIONS
|
||||
LIBINPUT_VERSION LIBINPUT_VERSION_MAJOR LIBINPUT_VERSION_MICRO LIBINPUT_VERSION_MINOR)
|
@ -0,0 +1,23 @@
|
||||
#ifndef _SWAY_INPUT_H
|
||||
#define _SWAY_INPUT_H
|
||||
|
||||
#include <libinput.h>
|
||||
#include "config.h"
|
||||
#include "list.h"
|
||||
|
||||
struct input_config *new_input_config(const char* identifier);
|
||||
|
||||
char* libinput_dev_unique_id(struct libinput_device *dev);
|
||||
|
||||
/**
|
||||
* Global input device list.
|
||||
*/
|
||||
extern list_t *input_devices;
|
||||
|
||||
/**
|
||||
* Pointer used when reading input blocked.
|
||||
* Shared so that it can be cleared from commands.c when closing the block
|
||||
*/
|
||||
extern struct input_config *current_input_config;
|
||||
|
||||
#endif
|
@ -0,0 +1,54 @@
|
||||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libinput.h>
|
||||
#include "config.h"
|
||||
#include "input.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
|
||||
struct input_config *new_input_config(const char* identifier) {
|
||||
struct input_config *input = calloc(1, sizeof(struct input_config));
|
||||
sway_log(L_DEBUG, "new_input_config(%s)", identifier);
|
||||
input->identifier = strdup(identifier);
|
||||
|
||||
input->tap = INT_MIN;
|
||||
input->drag_lock = INT_MIN;
|
||||
input->dwt = INT_MIN;
|
||||
input->send_events = INT_MIN;
|
||||
input->click_method = INT_MIN;
|
||||
input->middle_emulation = INT_MIN;
|
||||
input->natural_scroll = INT_MIN;
|
||||
input->pointer_accel = FLT_MIN;
|
||||
input->scroll_method = INT_MIN;
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
char *libinput_dev_unique_id(struct libinput_device *device) {
|
||||
int vendor = libinput_device_get_id_vendor(device);
|
||||
int product = libinput_device_get_id_product(device);
|
||||
char *name = strdup(libinput_device_get_name(device));
|
||||
|
||||
char *p = name;
|
||||
for (; *p; ++p) {
|
||||
if (*p == ' ') {
|
||||
*p = '_';
|
||||
}
|
||||
}
|
||||
|
||||
sway_log(L_DEBUG, "rewritten name %s", name);
|
||||
|
||||
int len = strlen(name) + sizeof(char) * 6;
|
||||
char *identifier = malloc(len);
|
||||
|
||||
const char *fmt = "%d:%d:%s";
|
||||
snprintf(identifier, len, fmt, vendor, product, name);
|
||||
free(name);
|
||||
return identifier;
|
||||
}
|
||||
|
||||
list_t *input_devices = NULL;
|
||||
struct input_config *current_input_config = NULL;
|
@ -0,0 +1,46 @@
|
||||
/////
|
||||
vim:set ts=4 sw=4 tw=82 noet:
|
||||
/////
|
||||
sway (5)
|
||||
========
|
||||
|
||||
Name
|
||||
----
|
||||
sway - input configuration file and commands
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Sway allows for configuration of libinput dveices.
|
||||
|
||||
|
||||
Commands
|
||||
--------
|
||||
|
||||
**input** <identifier> click_method <none|button_areas|clickfinger>:
|
||||
Changes the click method for the specified device.
|
||||
|
||||
**input** <identifier> drag_lock <enabled|disabled>:
|
||||
Enables or disables drag lock for specified input device.
|
||||
|
||||
**input** <identifier> dwt <enabled|disabled>:
|
||||
Enables or disables disable-while-typing for the specified input device.
|
||||
|
||||
**input** <identifier> events <enable|disabled>:
|
||||
Enables or disables send_events for specified input device.
|
||||
(Disabling send_events disables the input device)
|
||||
|
||||
**input** <identifier> middle_emulation <enabled|disabled>:
|
||||
Enables or disables middle click emulation.
|
||||
|
||||
**input** <identifier> natural_scroll <enabled|disabled>:
|
||||
Enables or disables natural scrolling for the specified input device.
|
||||
|
||||
**input** <identifier> pointer_accel <[-1,1]>:
|
||||
Changes the pointer acceleration for the specified input device.
|
||||
|
||||
**input** <identifier> scroll_method <none|two_finger|edge|on_button_down>:
|
||||
Changes the scroll method for the specified input device.
|
||||
|
||||
**input** <identifier> tap <enabled|disabled>:
|
||||
Enables or disables tap for specified input device.
|
Loading…
Reference in new issue