Reformat directory structure
This commit is contained in:
parent
2e91ac17fd
commit
fb92169a16
58
.gitignore
vendored
58
.gitignore
vendored
@ -1,30 +1,42 @@
|
|||||||
# C++ generated headers
|
|
||||||
*.gch
|
|
||||||
.out
|
|
||||||
|
|
||||||
# Generated library
|
|
||||||
comfortable-swipe
|
|
||||||
libcomfortableswipe.a
|
|
||||||
|
|
||||||
# IDE-specific
|
# IDE-specific
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
# CMake
|
# Build
|
||||||
CMakeLists.txt.user
|
build/
|
||||||
CMakeCache.txt
|
|
||||||
CMakeFiles
|
|
||||||
CMakeScripts
|
|
||||||
Testing
|
|
||||||
Makefile
|
|
||||||
cmake_install.cmake
|
|
||||||
install_manifest.txt
|
|
||||||
compile_commands.json
|
|
||||||
CTestTestfile.cmake
|
|
||||||
_deps
|
|
||||||
|
|
||||||
# CPack
|
|
||||||
CPack*
|
|
||||||
|
|
||||||
# Library
|
# Library
|
||||||
.lib
|
.lib
|
||||||
|
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Compiled Object files
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Compiled Dynamic libraries
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
# Fortran module files
|
||||||
|
*.mod
|
||||||
|
*.smod
|
||||||
|
|
||||||
|
# Compiled Static libraries
|
||||||
|
*.lai
|
||||||
|
*.la
|
||||||
|
*.a
|
||||||
|
*.lib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
|||||||
@ -7,7 +7,7 @@ v1.1.0 (2020-04-18)
|
|||||||
* Add `mouse_hold_gestures.cpp`
|
* Add `mouse_hold_gestures.cpp`
|
||||||
* Bugfix `comfortable-swipe stop`
|
* Bugfix `comfortable-swipe stop`
|
||||||
* Bugfix `comfortable-swipe restart`
|
* Bugfix `comfortable-swipe restart`
|
||||||
* Rename `index.hpp` to `all_headers.hpp`
|
* Rename `index.hpp` to `comfortable_swipe.h`
|
||||||
* Rename source directory `lib` to `comfortable_swipe`
|
* Rename source directory `lib` to `comfortable_swipe`
|
||||||
* Separate `swipe_gesture.cpp` from `keyboard_swipe_gesture.cpp`
|
* Separate `swipe_gesture.cpp` from `keyboard_swipe_gesture.cpp`
|
||||||
* Update compiler scripts
|
* Update compiler scripts
|
||||||
|
|||||||
@ -1,44 +1,61 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.10.2)
|
# HEADER: versions
|
||||||
# find external libraries here
|
cmake_minimum_required(VERSION 3.10.2)
|
||||||
FIND_LIBRARY(XDO_LIB libxdo)
|
project(comfortable-swipe)
|
||||||
|
|
||||||
# set comfortable swipe version
|
# link external C++ libraries here
|
||||||
FILE(STRINGS "VERSION" VERSION)
|
find_library(XDO_LIB libxdo.a)
|
||||||
ADD_DEFINITIONS(-DCOMFORTABLE_SWIPE_VERSION="${VERSION}")
|
|
||||||
|
|
||||||
# set project
|
# CMAKE variables
|
||||||
PROJECT (comfortable-swipe)
|
set(CMAKE_INSTALL_PREFIX "/home/rico/Git/comfortable-swipe-ubuntu/dist")
|
||||||
|
set(CMAKE_PROJECT_NAME "comfortable-swipe")
|
||||||
|
set(CMAKE_PROJECT_DESCRIPTION "3/4-finger comfortableswipe gestures")
|
||||||
|
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
||||||
|
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
||||||
|
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||||
|
|
||||||
# add our own library
|
# set flags to use C++ 11
|
||||||
ADD_LIBRARY(comfortableswipe STATIC comfortable_swipe/lib.cpp)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
set(CMAKE_CXX_FLAGS_DISTRIBUTION "-O2")
|
||||||
|
|
||||||
# set our target library output
|
# set main directories
|
||||||
#SET_TARGET_PROPERTIES(comfortableswipe
|
set(comfortable_swipe_bin "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
||||||
# PROPERTIES
|
set(comfortable_swipe_lib "${CMAKE_CURRENT_BINARY_DIR}/lib")
|
||||||
# LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/library
|
set(comfortable_swipe_share "${CMAKE_CURRENT_BINARY_DIR}/share")
|
||||||
#)
|
set(comfortable_swipe_include "${CMAKE_CURRENT_BINARY_DIR}/include")
|
||||||
|
|
||||||
# set our library includes
|
# set version from VERSION file
|
||||||
TARGET_INCLUDE_DIRECTORIES(comfortableswipe
|
file(STRINGS "VERSION" comfortable_swipe_version)
|
||||||
PUBLIC
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/comfortable_swipe"
|
# set project variables
|
||||||
|
set(comfortable_swipe_exe_source "${CMAKE_CURRENT_SOURCE_DIR}/comfortable-swipe.cpp")
|
||||||
|
set(comfortable_swipe_exe_path "${comfortable_swipe_bin}/comfortable-swipe")
|
||||||
|
set(comfortable_swipe_conf_path "/usr/local/share/comfortable-swipe/comfortable-swipe.conf")
|
||||||
|
|
||||||
|
# C++ definitions
|
||||||
|
add_definitions(
|
||||||
|
-DCMAKE_BUILD 1
|
||||||
|
-DCOMFORTABLE_SWIPE_VERSION="${comfortable_swipe_version}"
|
||||||
|
-DCOMFORTABLE_SWIPE_PROGRAM="${comfortable_swipe_exe_path}"
|
||||||
|
-DCOMFORTABLE_SWIPE_CONFIG="${comfortable_swipe_conf_path}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# add comfortable-swipe command line program
|
# add our own comfortable-swipe library
|
||||||
ADD_EXECUTABLE(comfortable-swipe command_line.cpp)
|
add_library(comfortable-swipe.a STATIC "${CMAKE_CURRENT_SOURCE_DIR}/src/comfortable_swipe.cpp")
|
||||||
|
target_include_directories(comfortable-swipe.a PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||||
|
set_target_properties(comfortable-swipe.a PROPERTIES OUTPUT_NAME "comfortable-swipe")
|
||||||
|
|
||||||
# link target libraries for program
|
# register comfortable-swipe command line program
|
||||||
TARGET_LINK_LIBRARIES(comfortable-swipe comfortableswipe)
|
add_executable("comfortable-swipe" "${comfortable_swipe_exe_source}")
|
||||||
TARGET_LINK_LIBRARIES(comfortable-swipe "${XDO_LIB}")
|
|
||||||
|
|
||||||
INSTALL(TARGETS comfortable-swipe
|
# add libraries to target
|
||||||
COMPONENT linapp
|
target_link_libraries(comfortable-swipe.a "${XDO_LIB}")
|
||||||
RUNTIME DESTINATION "/home/rico/cf/run"
|
target_link_libraries(comfortable-swipe comfortable-swipe.a)
|
||||||
LIBRARY DESTINATION "/home/rico/cf/run"
|
|
||||||
DESTINATION "/home/rico/cf/run"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
# perform installation
|
||||||
|
install(TARGETS comfortable-swipe DESTINATION bin)
|
||||||
|
|
||||||
SET(CPACK_GENERATOR "DEB")
|
# set platform-specific tasks
|
||||||
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "KK") #required
|
set(CPACK_GENERATOR "DEB")
|
||||||
INCLUDE(CPack)
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Rico Tiongson <thericotiongson@gmail.com>") #required
|
||||||
|
include(CPack)
|
||||||
|
|||||||
@ -16,10 +16,10 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "comfortable_swipe/lib.cpp"
|
|
||||||
#include <ios> // std::ios
|
#include <ios> // std::ios
|
||||||
#include <iostream> // std::cin, std::cout, std::cerr
|
#include <iostream> // std::cin, std::cout, std::cerr
|
||||||
#include <string> // std::string
|
#include <string> // std::string
|
||||||
|
#include "src/comfortable_swipe.cpp"
|
||||||
|
|
||||||
/* Command-line function. */
|
/* Command-line function. */
|
||||||
|
|
||||||
2
install
2
install
@ -8,7 +8,7 @@ function install {
|
|||||||
local program="comfortable-swipe"
|
local program="comfortable-swipe"
|
||||||
local program_exe="/usr/local/bin/$program"
|
local program_exe="/usr/local/bin/$program"
|
||||||
local compile_command="$dir/cpp.compile.sh"
|
local compile_command="$dir/cpp.compile.sh"
|
||||||
local compile_target="$dir/command_line.cpp"
|
local compile_target="$dir/comfortable-swipe.cpp"
|
||||||
local conf_path="/usr/local/share/$program/$program.conf"
|
local conf_path="/usr/local/share/$program/$program.conf"
|
||||||
local dconf_path="$dir/defaults.conf"
|
local dconf_path="$dir/defaults.conf"
|
||||||
local old_conf_path="${XDG_CONFIG_HOME:-$HOME/.config}/$program.conf"
|
local old_conf_path="${XDG_CONFIG_HOME:-$HOME/.config}/$program.conf"
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Add all cpp implementation files are registered here.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __COMFORTABLE_SWIPE__
|
#ifndef __COMFORTABLE_SWIPE__
|
||||||
#define __COMFORTABLE_SWIPE__
|
#define __COMFORTABLE_SWIPE__
|
||||||
|
|
||||||
@ -19,13 +23,8 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "all_headers.hpp"
|
#include "comfortable_swipe.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* Add all cpp files below to be ready for export.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "driver.cpp"
|
|
||||||
#include "gesture/keyboard_swipe_gesture.cpp"
|
#include "gesture/keyboard_swipe_gesture.cpp"
|
||||||
#include "gesture/mouse_hold_gesture.cpp"
|
#include "gesture/mouse_hold_gesture.cpp"
|
||||||
#include "gesture/swipe_gesture.cpp"
|
#include "gesture/swipe_gesture.cpp"
|
||||||
@ -43,5 +42,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "util/autostart_filename.cpp"
|
#include "util/autostart_filename.cpp"
|
||||||
#include "util/conf_filename.cpp"
|
#include "util/conf_filename.cpp"
|
||||||
#include "util/read_config_file.cpp"
|
#include "util/read_config_file.cpp"
|
||||||
|
#include "start.cpp"
|
||||||
|
|
||||||
#endif /* __COMFORTABLE_SWIPE__ */
|
#endif /* __COMFORTABLE_SWIPE__ */
|
||||||
@ -2,11 +2,11 @@
|
|||||||
* Add header files will be imported here.
|
* Add header files will be imported here.
|
||||||
* You can import this as a shorthand:
|
* You can import this as a shorthand:
|
||||||
*
|
*
|
||||||
* #include "../all_headers.hpp"
|
* #include "comfortable_swipe.h"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __COMFORTABLE_SWIPE__all_headers_hpp__
|
#ifndef __COMFORTABLE_SWIPE__comfortable_swipe_h__
|
||||||
#define __COMFORTABLE_SWIPE__all_headers_hpp__
|
#define __COMFORTABLE_SWIPE__comfortable_swipe_h__
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Comfortable Swipe
|
Comfortable Swipe
|
||||||
@ -27,14 +27,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// global defines
|
// global defines
|
||||||
#ifndef __COMFORTABLE_SWIPE__PROGRAM__
|
#ifndef COMFORTABLE_SWIPE_PROGRAM
|
||||||
#define __COMFORTABLE_SWIPE__PROGRAM__ "/usr/local/bin/comfortable-swipe"
|
#define COMFORTABLE_SWIPE_PROGRAM "/usr/local/bin/comfortable-swipe"
|
||||||
#endif /* __COMFORTABLE_SWIPE__PROGRAM__ */
|
#endif /* COMFORTABLE_SWIPE_PROGRAM */
|
||||||
|
|
||||||
#ifndef __COMFORTABLE_SWIPE__CONFIG__
|
#ifndef COMFORTABLE_SWIPE_CONFIG
|
||||||
#define __COMFORTABLE_SWIPE__CONFIG__ \
|
#define COMFORTABLE_SWIPE_CONFIG \
|
||||||
"/usr/local/share/comfortable-swipe/comfortable-swipe.conf"
|
"/usr/local/share/comfortable-swipe/comfortable-swipe.conf"
|
||||||
#endif /* __COMFORTABLE_SWIPE__CONFIG__ */
|
#endif /* COMFORTABLE_SWIPE_CONFIG */
|
||||||
|
|
||||||
#ifndef COMFORTABLE_SWIPE_VERSION
|
#ifndef COMFORTABLE_SWIPE_VERSION
|
||||||
#warning COMFORTABLE_SWIPE_VERSION is not defined
|
#warning COMFORTABLE_SWIPE_VERSION is not defined
|
||||||
@ -46,8 +46,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
namespace comfortable_swipe {
|
namespace comfortable_swipe {
|
||||||
// driver method
|
|
||||||
int driver();
|
|
||||||
// this is found in the util/ folder
|
// this is found in the util/ folder
|
||||||
namespace util {
|
namespace util {
|
||||||
const char *autostart_filename();
|
const char *autostart_filename();
|
||||||
@ -74,5 +72,6 @@ void stop();
|
|||||||
#include "gesture/mouse_hold_gesture.h"
|
#include "gesture/mouse_hold_gesture.h"
|
||||||
#include "gesture/swipe_gesture.h"
|
#include "gesture/swipe_gesture.h"
|
||||||
#include "gesture/xdo_gesture.h"
|
#include "gesture/xdo_gesture.h"
|
||||||
|
#include "start.h"
|
||||||
|
|
||||||
#endif /* __COMFORTABLE_SWIPE__all_headers_hpp__ */
|
#endif /* __COMFORTABLE_SWIPE__comfortable_swipe_h__ */
|
||||||
@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../all_headers.hpp"
|
#include "../comfortable_swipe.h"
|
||||||
#include <cstdio> // std::remove
|
#include <cstdio> // std::remove
|
||||||
#include <cstdlib> // std::system
|
#include <cstdlib> // std::system
|
||||||
#include <fstream> // std::ifstream, std::ofstream
|
#include <fstream> // std::ifstream, std::ofstream
|
||||||
@ -51,7 +51,7 @@ void autostart() {
|
|||||||
else {
|
else {
|
||||||
fout << "[Desktop Entry]\n"
|
fout << "[Desktop Entry]\n"
|
||||||
"Type=Application\n"
|
"Type=Application\n"
|
||||||
"Exec=bash -c \"" __COMFORTABLE_SWIPE__PROGRAM__ " start\"\n"
|
"Exec=bash -c \"" COMFORTABLE_SWIPE_PROGRAM " start\"\n"
|
||||||
"Hidden=false\n"
|
"Hidden=false\n"
|
||||||
"NoDisplay=false\n"
|
"NoDisplay=false\n"
|
||||||
"X-GNOME-Autostart-enabled=true\n"
|
"X-GNOME-Autostart-enabled=true\n"
|
||||||
@ -19,14 +19,13 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../all_headers.hpp"
|
#include "../start.h"
|
||||||
#include <cstdlib> // std::exit
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the comfortable-swipe service by buffering libinput debug-events.
|
* Starts the comfortable-swipe service by buffering libinput debug-events.
|
||||||
*/
|
*/
|
||||||
namespace comfortable_swipe::service {
|
namespace comfortable_swipe::service {
|
||||||
void buffer() { std::exit(comfortable_swipe::driver()); }
|
void buffer() { comfortable_swipe::start(); }
|
||||||
} // namespace comfortable_swipe::service
|
} // namespace comfortable_swipe::service
|
||||||
|
|
||||||
#endif /* __COMFORTABLE_SWIPE__service_buffer__ */
|
#endif /* __COMFORTABLE_SWIPE__service_buffer__ */
|
||||||
@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../all_headers.hpp"
|
#include "../comfortable_swipe.h"
|
||||||
#include <cstdio> // std::puts
|
#include <cstdio> // std::puts
|
||||||
|
|
||||||
namespace comfortable_swipe::service {
|
namespace comfortable_swipe::service {
|
||||||
@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../all_headers.hpp"
|
#include "../comfortable_swipe.h"
|
||||||
#include <cstdio> // std::puts, std::printf
|
#include <cstdio> // std::puts, std::printf
|
||||||
|
|
||||||
namespace comfortable_swipe::service {
|
namespace comfortable_swipe::service {
|
||||||
@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../all_headers.hpp"
|
#include "../comfortable_swipe.h"
|
||||||
#include <cstdio> // freopen, stdout
|
#include <cstdio> // freopen, stdout
|
||||||
|
|
||||||
namespace comfortable_swipe::service {
|
namespace comfortable_swipe::service {
|
||||||
@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../all_headers.hpp"
|
#include "../comfortable_swipe.h"
|
||||||
#include <cstdlib> // std::system
|
#include <cstdlib> // std::system
|
||||||
|
|
||||||
namespace comfortable_swipe::service {
|
namespace comfortable_swipe::service {
|
||||||
@ -29,8 +29,8 @@ namespace comfortable_swipe::service {
|
|||||||
* for the technical implementation.
|
* for the technical implementation.
|
||||||
*/
|
*/
|
||||||
void start() {
|
void start() {
|
||||||
(void)std::system(__COMFORTABLE_SWIPE__PROGRAM__
|
(void)std::system(COMFORTABLE_SWIPE_PROGRAM
|
||||||
" debug | " __COMFORTABLE_SWIPE__PROGRAM__ " buffer");
|
" debug | " COMFORTABLE_SWIPE_PROGRAM " buffer");
|
||||||
}
|
}
|
||||||
} // namespace comfortable_swipe::service
|
} // namespace comfortable_swipe::service
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../all_headers.hpp"
|
#include "../comfortable_swipe.h"
|
||||||
#include <array> // std::array
|
#include <array> // std::array
|
||||||
#include <cstdio> // FILE, std::feof, std::fgets, std::printf
|
#include <cstdio> // FILE, std::feof, std::fgets, std::printf
|
||||||
#include <cstdlib> // std::atoi
|
#include <cstdlib> // std::atoi
|
||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef __COMFORTABLE_SWIPE__driver__
|
#ifndef __COMFORTABLE_SWIPE__start__
|
||||||
#define __COMFORTABLE_SWIPE__driver__
|
#define __COMFORTABLE_SWIPE__start__
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Comfortable Swipe
|
Comfortable Swipe
|
||||||
@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "all_headers.hpp"
|
#include "comfortable_swipe.h"
|
||||||
#include <cstdio> // fgets_unlocked, stdin
|
#include <cstdio> // fgets_unlocked, stdin
|
||||||
#include <iostream> // std::ios, std::cout, std::cin
|
#include <iostream> // std::ios, std::cout, std::cin
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
* The main driver program.
|
* The main driver program.
|
||||||
*/
|
*/
|
||||||
namespace comfortable_swipe {
|
namespace comfortable_swipe {
|
||||||
int driver() {
|
void start() {
|
||||||
// unsync for faster IO
|
// unsync for faster IO
|
||||||
std::ios::sync_with_stdio(false);
|
std::ios::sync_with_stdio(false);
|
||||||
std::cin.tie(0);
|
std::cin.tie(0);
|
||||||
@ -45,15 +45,31 @@ int driver() {
|
|||||||
// hold3=button1 hold button 1 on 3 fingers
|
// hold3=button1 hold button 1 on 3 fingers
|
||||||
// hold4=button3 hold button 3 (right click) on 3 fingers
|
// hold4=button3 hold button 3 (right click) on 3 fingers
|
||||||
// hold3=ignore <do nothing>
|
// hold3=ignore <do nothing>
|
||||||
comfortable_swipe::gesture::mouse_hold_gesture mouse_hold(
|
const char * const hold3 = config["hold3"].c_str();
|
||||||
config["hold3"].c_str(), config["hold4"].c_str());
|
const char * const hold4 = config["hold4"].c_str();
|
||||||
|
comfortable_swipe::gesture::mouse_hold_gesture mouse_hold(hold3, hold4);
|
||||||
|
|
||||||
// initialize keyboard swipe gesture handler
|
// initialize keyboard swipe gesture handler
|
||||||
|
const float threshold = config.count("threshold") ? std::stof(config["threshold"]) : 0.0;
|
||||||
|
const char * const left3 = config["left3"].c_str();
|
||||||
|
const char * const left4 = config["left4"].c_str();
|
||||||
|
const char * const right3 = config["right3"].c_str();
|
||||||
|
const char * const right4 = config["right4"].c_str();
|
||||||
|
const char * const up3 = config["up3"].c_str();
|
||||||
|
const char * const up4 = config["up4"].c_str();
|
||||||
|
const char * const down3 = config["down3"].c_str();
|
||||||
|
const char * const down4 = config["down4"].c_str();
|
||||||
comfortable_swipe::gesture::keyboard_swipe_gesture keyboard_swipe(
|
comfortable_swipe::gesture::keyboard_swipe_gesture keyboard_swipe(
|
||||||
config.count("threshold") ? std::stof(config["threshold"]) : 0.0,
|
threshold,
|
||||||
config["left3"].c_str(), config["left4"].c_str(),
|
left3,
|
||||||
config["right3"].c_str(), config["right4"].c_str(), config["up3"].c_str(),
|
left4,
|
||||||
config["up4"].c_str(), config["down3"].c_str(), config["down4"].c_str());
|
right3,
|
||||||
|
right4,
|
||||||
|
up3,
|
||||||
|
up4,
|
||||||
|
down3,
|
||||||
|
down4
|
||||||
|
);
|
||||||
|
|
||||||
// prepare data containers
|
// prepare data containers
|
||||||
std::array<char, 256> line;
|
std::array<char, 256> line;
|
||||||
@ -62,16 +78,13 @@ int driver() {
|
|||||||
while (fgets_unlocked(line.data(), line.size(), stdin) != NULL) {
|
while (fgets_unlocked(line.data(), line.size(), stdin) != NULL) {
|
||||||
// prioritize mouse hold gesture first
|
// prioritize mouse hold gesture first
|
||||||
mouse_hold.parse_line(line.data());
|
mouse_hold.parse_line(line.data());
|
||||||
|
|
||||||
// if mouse hold fails, try keyboard hold
|
|
||||||
if (!mouse_hold.is_mousedown()) {
|
if (!mouse_hold.is_mousedown()) {
|
||||||
// attempt to parse keyboard gestures
|
// if mouse hold fails, try keyboard swipe
|
||||||
|
// attempt to parse keyboard gestures with the same line data
|
||||||
keyboard_swipe.parse_line(line.data());
|
keyboard_swipe.parse_line(line.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} // namespace comfortable_swipe
|
} // namespace comfortable_swipe
|
||||||
|
|
||||||
#endif /* __COMFORTABLE_SWIPE__driver__ */
|
#endif /* __COMFORTABLE_SWIPE__start__ */
|
||||||
8
src/start.h
Normal file
8
src/start.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef __COMFORTABLE_SWIPE__start_h__
|
||||||
|
#define __COMFORTABLE_SWIPE__start_h__
|
||||||
|
|
||||||
|
namespace comfortable_swipe {
|
||||||
|
void start();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __COMFORTABLE_SWIPE__start_h__ */
|
||||||
@ -19,13 +19,13 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../all_headers.hpp"
|
#include "../comfortable_swipe.h"
|
||||||
|
|
||||||
namespace comfortable_swipe::util {
|
namespace comfortable_swipe::util {
|
||||||
/**
|
/**
|
||||||
* The path where the configuration file is located.
|
* The path where the configuration file is located.
|
||||||
*/
|
*/
|
||||||
constexpr const char *conf_filename() { return __COMFORTABLE_SWIPE__CONFIG__; }
|
constexpr const char *conf_filename() { return COMFORTABLE_SWIPE_CONFIG; }
|
||||||
} // namespace comfortable_swipe::util
|
} // namespace comfortable_swipe::util
|
||||||
|
|
||||||
#endif /* __COMFORTABLE_SWIPE__util_conf_filename__ */
|
#endif /* __COMFORTABLE_SWIPE__util_conf_filename__ */
|
||||||
Loading…
Reference in New Issue
Block a user