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
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
# CMake
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
|
||||
# CPack
|
||||
CPack*
|
||||
# Build
|
||||
build/
|
||||
|
||||
# Library
|
||||
.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`
|
||||
* Bugfix `comfortable-swipe stop`
|
||||
* 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`
|
||||
* Separate `swipe_gesture.cpp` from `keyboard_swipe_gesture.cpp`
|
||||
* Update compiler scripts
|
||||
|
||||
@ -1,44 +1,61 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.10.2)
|
||||
# find external libraries here
|
||||
FIND_LIBRARY(XDO_LIB libxdo)
|
||||
# HEADER: versions
|
||||
cmake_minimum_required(VERSION 3.10.2)
|
||||
project(comfortable-swipe)
|
||||
|
||||
# set comfortable swipe version
|
||||
FILE(STRINGS "VERSION" VERSION)
|
||||
ADD_DEFINITIONS(-DCOMFORTABLE_SWIPE_VERSION="${VERSION}")
|
||||
# link external C++ libraries here
|
||||
find_library(XDO_LIB libxdo.a)
|
||||
|
||||
# set project
|
||||
PROJECT (comfortable-swipe)
|
||||
# CMAKE variables
|
||||
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
|
||||
ADD_LIBRARY(comfortableswipe STATIC comfortable_swipe/lib.cpp)
|
||||
# set flags to use C++ 11
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_CXX_FLAGS_DISTRIBUTION "-O2")
|
||||
|
||||
# set our target library output
|
||||
#SET_TARGET_PROPERTIES(comfortableswipe
|
||||
# PROPERTIES
|
||||
# LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/library
|
||||
#)
|
||||
# set main directories
|
||||
set(comfortable_swipe_bin "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
||||
set(comfortable_swipe_lib "${CMAKE_CURRENT_BINARY_DIR}/lib")
|
||||
set(comfortable_swipe_share "${CMAKE_CURRENT_BINARY_DIR}/share")
|
||||
set(comfortable_swipe_include "${CMAKE_CURRENT_BINARY_DIR}/include")
|
||||
|
||||
# set our library includes
|
||||
TARGET_INCLUDE_DIRECTORIES(comfortableswipe
|
||||
PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/comfortable_swipe"
|
||||
# set version from VERSION file
|
||||
file(STRINGS "VERSION" comfortable_swipe_version)
|
||||
|
||||
# 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_EXECUTABLE(comfortable-swipe command_line.cpp)
|
||||
# add our own comfortable-swipe library
|
||||
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
|
||||
TARGET_LINK_LIBRARIES(comfortable-swipe comfortableswipe)
|
||||
TARGET_LINK_LIBRARIES(comfortable-swipe "${XDO_LIB}")
|
||||
# register comfortable-swipe command line program
|
||||
add_executable("comfortable-swipe" "${comfortable_swipe_exe_source}")
|
||||
|
||||
INSTALL(TARGETS comfortable-swipe
|
||||
COMPONENT linapp
|
||||
RUNTIME DESTINATION "/home/rico/cf/run"
|
||||
LIBRARY DESTINATION "/home/rico/cf/run"
|
||||
DESTINATION "/home/rico/cf/run"
|
||||
)
|
||||
# add libraries to target
|
||||
target_link_libraries(comfortable-swipe.a "${XDO_LIB}")
|
||||
target_link_libraries(comfortable-swipe comfortable-swipe.a)
|
||||
|
||||
# perform installation
|
||||
install(TARGETS comfortable-swipe DESTINATION bin)
|
||||
|
||||
SET(CPACK_GENERATOR "DEB")
|
||||
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "KK") #required
|
||||
INCLUDE(CPack)
|
||||
# set platform-specific tasks
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "comfortable_swipe/lib.cpp"
|
||||
#include <ios> // std::ios
|
||||
#include <iostream> // std::cin, std::cout, std::cerr
|
||||
#include <string> // std::string
|
||||
#include "src/comfortable_swipe.cpp"
|
||||
|
||||
/* Command-line function. */
|
||||
|
||||
2
install
2
install
@ -8,7 +8,7 @@ function install {
|
||||
local program="comfortable-swipe"
|
||||
local program_exe="/usr/local/bin/$program"
|
||||
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 dconf_path="$dir/defaults.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__
|
||||
#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/>.
|
||||
*/
|
||||
|
||||
#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/mouse_hold_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/conf_filename.cpp"
|
||||
#include "util/read_config_file.cpp"
|
||||
#include "start.cpp"
|
||||
|
||||
#endif /* __COMFORTABLE_SWIPE__ */
|
||||
@ -2,11 +2,11 @@
|
||||
* Add header files will be imported here.
|
||||
* You can import this as a shorthand:
|
||||
*
|
||||
* #include "../all_headers.hpp"
|
||||
* #include "comfortable_swipe.h"
|
||||
*/
|
||||
|
||||
#ifndef __COMFORTABLE_SWIPE__all_headers_hpp__
|
||||
#define __COMFORTABLE_SWIPE__all_headers_hpp__
|
||||
#ifndef __COMFORTABLE_SWIPE__comfortable_swipe_h__
|
||||
#define __COMFORTABLE_SWIPE__comfortable_swipe_h__
|
||||
|
||||
/*
|
||||
Comfortable Swipe
|
||||
@ -27,14 +27,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// global defines
|
||||
#ifndef __COMFORTABLE_SWIPE__PROGRAM__
|
||||
#define __COMFORTABLE_SWIPE__PROGRAM__ "/usr/local/bin/comfortable-swipe"
|
||||
#endif /* __COMFORTABLE_SWIPE__PROGRAM__ */
|
||||
#ifndef COMFORTABLE_SWIPE_PROGRAM
|
||||
#define COMFORTABLE_SWIPE_PROGRAM "/usr/local/bin/comfortable-swipe"
|
||||
#endif /* COMFORTABLE_SWIPE_PROGRAM */
|
||||
|
||||
#ifndef __COMFORTABLE_SWIPE__CONFIG__
|
||||
#define __COMFORTABLE_SWIPE__CONFIG__ \
|
||||
#ifndef COMFORTABLE_SWIPE_CONFIG
|
||||
#define COMFORTABLE_SWIPE_CONFIG \
|
||||
"/usr/local/share/comfortable-swipe/comfortable-swipe.conf"
|
||||
#endif /* __COMFORTABLE_SWIPE__CONFIG__ */
|
||||
#endif /* COMFORTABLE_SWIPE_CONFIG */
|
||||
|
||||
#ifndef COMFORTABLE_SWIPE_VERSION
|
||||
#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" {
|
||||
namespace comfortable_swipe {
|
||||
// driver method
|
||||
int driver();
|
||||
// this is found in the util/ folder
|
||||
namespace util {
|
||||
const char *autostart_filename();
|
||||
@ -74,5 +72,6 @@ void stop();
|
||||
#include "gesture/mouse_hold_gesture.h"
|
||||
#include "gesture/swipe_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/>.
|
||||
*/
|
||||
|
||||
#include "../all_headers.hpp"
|
||||
#include "../comfortable_swipe.h"
|
||||
#include <cstdio> // std::remove
|
||||
#include <cstdlib> // std::system
|
||||
#include <fstream> // std::ifstream, std::ofstream
|
||||
@ -51,7 +51,7 @@ void autostart() {
|
||||
else {
|
||||
fout << "[Desktop Entry]\n"
|
||||
"Type=Application\n"
|
||||
"Exec=bash -c \"" __COMFORTABLE_SWIPE__PROGRAM__ " start\"\n"
|
||||
"Exec=bash -c \"" COMFORTABLE_SWIPE_PROGRAM " start\"\n"
|
||||
"Hidden=false\n"
|
||||
"NoDisplay=false\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/>.
|
||||
*/
|
||||
|
||||
#include "../all_headers.hpp"
|
||||
#include <cstdlib> // std::exit
|
||||
#include "../start.h"
|
||||
|
||||
/**
|
||||
* Starts the comfortable-swipe service by buffering libinput debug-events.
|
||||
*/
|
||||
namespace comfortable_swipe::service {
|
||||
void buffer() { std::exit(comfortable_swipe::driver()); }
|
||||
void buffer() { comfortable_swipe::start(); }
|
||||
} // namespace comfortable_swipe::service
|
||||
|
||||
#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/>.
|
||||
*/
|
||||
|
||||
#include "../all_headers.hpp"
|
||||
#include "../comfortable_swipe.h"
|
||||
#include <cstdio> // std::puts
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "../all_headers.hpp"
|
||||
#include "../comfortable_swipe.h"
|
||||
#include <cstdio> // std::puts, std::printf
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "../all_headers.hpp"
|
||||
#include "../comfortable_swipe.h"
|
||||
#include <cstdio> // freopen, stdout
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "../all_headers.hpp"
|
||||
#include "../comfortable_swipe.h"
|
||||
#include <cstdlib> // std::system
|
||||
|
||||
namespace comfortable_swipe::service {
|
||||
@ -29,8 +29,8 @@ namespace comfortable_swipe::service {
|
||||
* for the technical implementation.
|
||||
*/
|
||||
void start() {
|
||||
(void)std::system(__COMFORTABLE_SWIPE__PROGRAM__
|
||||
" debug | " __COMFORTABLE_SWIPE__PROGRAM__ " buffer");
|
||||
(void)std::system(COMFORTABLE_SWIPE_PROGRAM
|
||||
" debug | " COMFORTABLE_SWIPE_PROGRAM " buffer");
|
||||
}
|
||||
} // 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/>.
|
||||
*/
|
||||
|
||||
#include "../all_headers.hpp"
|
||||
#include "../comfortable_swipe.h"
|
||||
#include <array> // std::array
|
||||
#include <cstdio> // FILE, std::feof, std::fgets, std::printf
|
||||
#include <cstdlib> // std::atoi
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __COMFORTABLE_SWIPE__driver__
|
||||
#define __COMFORTABLE_SWIPE__driver__
|
||||
#ifndef __COMFORTABLE_SWIPE__start__
|
||||
#define __COMFORTABLE_SWIPE__start__
|
||||
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "all_headers.hpp"
|
||||
#include "comfortable_swipe.h"
|
||||
#include <cstdio> // fgets_unlocked, stdin
|
||||
#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.
|
||||
*/
|
||||
namespace comfortable_swipe {
|
||||
int driver() {
|
||||
void start() {
|
||||
// unsync for faster IO
|
||||
std::ios::sync_with_stdio(false);
|
||||
std::cin.tie(0);
|
||||
@ -45,15 +45,31 @@ int driver() {
|
||||
// hold3=button1 hold button 1 on 3 fingers
|
||||
// hold4=button3 hold button 3 (right click) on 3 fingers
|
||||
// hold3=ignore <do nothing>
|
||||
comfortable_swipe::gesture::mouse_hold_gesture mouse_hold(
|
||||
config["hold3"].c_str(), config["hold4"].c_str());
|
||||
const char * const hold3 = config["hold3"].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
|
||||
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(
|
||||
config.count("threshold") ? std::stof(config["threshold"]) : 0.0,
|
||||
config["left3"].c_str(), config["left4"].c_str(),
|
||||
config["right3"].c_str(), config["right4"].c_str(), config["up3"].c_str(),
|
||||
config["up4"].c_str(), config["down3"].c_str(), config["down4"].c_str());
|
||||
threshold,
|
||||
left3,
|
||||
left4,
|
||||
right3,
|
||||
right4,
|
||||
up3,
|
||||
up4,
|
||||
down3,
|
||||
down4
|
||||
);
|
||||
|
||||
// prepare data containers
|
||||
std::array<char, 256> line;
|
||||
@ -62,16 +78,13 @@ int driver() {
|
||||
while (fgets_unlocked(line.data(), line.size(), stdin) != NULL) {
|
||||
// prioritize mouse hold gesture first
|
||||
mouse_hold.parse_line(line.data());
|
||||
|
||||
// if mouse hold fails, try keyboard hold
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // 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/>.
|
||||
*/
|
||||
|
||||
#include "../all_headers.hpp"
|
||||
#include "../comfortable_swipe.h"
|
||||
|
||||
namespace comfortable_swipe::util {
|
||||
/**
|
||||
* 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
|
||||
|
||||
#endif /* __COMFORTABLE_SWIPE__util_conf_filename__ */
|
||||
Loading…
Reference in New Issue
Block a user