Commit 3c1f5c2c authored by kernc's avatar kernc

Major code refactoring and various fixes - all as of yet untested\!

git-svn-id: https://logkeys.googlecode.com/svn/trunk@37 c501e62c-e7d1-11de-a198-37193048d1ed
parent 82dc8c1a
......@@ -13,29 +13,10 @@ repositories, manual installation of logkeys from source is as easy as:
( become superuser now ) # you need root to install in system dir
# make install # installs binaries, manuals and scripts
That's it. If everything went through fine, you can probably start using it.
That's it.
See README file for usage instructions and notes.
To install the binaries in path other than /usr/local/bin, use configure with
--prefix switch, for example:
$ ../configure --prefix=/usr
Along with other standard configure options, you can also use:
To ever uninstall logkeys, remove accompanying scripts and manuals, issue
$ ../configure --enable-evdev-path=PATH
to have logkeys look for input event devices in PATH ( $(PATH)/eventX ) instead
of preconfigured default /dev/input (/dev/input/eventX), and
$ ../configure --enable-evdev=DEV
to have logkeys define static event device DEV (i.e. /dev/input/eventX) instead
of looking for it in default /dev/input path or custom evdev-path.
The input event device we are referring to, here, is the kernel event interface
echoing keyboard events. If using either of these two --enable-evdev*
switches, make sure you provided correct PATH/DEV.
# make uninstall # in the same logkeys-0.1.0/build dir from before
See README file for usage instructions and notes.
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src man scripts
EXTRA_DIST = build man/logkeys.8 scripts/lkl scripts/lklk
\ No newline at end of file
EXTRA_DIST = src/keytables.cc build man/logkeys.8 scripts/lkl scripts/lklk
\ No newline at end of file
......@@ -34,7 +34,7 @@ POST_UNINSTALL = :
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure COPYING INSTALL TODO depcomp \
$(top_srcdir)/configure COPYING ChangeLog INSTALL TODO depcomp \
install-sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
......@@ -190,7 +190,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src man scripts
EXTRA_DIST = build man/logkeys.8 scripts/lkl scripts/lklk
EXTRA_DIST = src/keytables.cc build man/logkeys.8 scripts/lkl scripts/lklk
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
......
......@@ -16,7 +16,7 @@
===============================================================================
logkeys is dual licensed under the terms of either GNU GPLv3 or later, or
WTFPLv2 or later. It is entirely your choice! See COPYING for further
licensing information.
information about licensing.
+------------------------------------------------
......@@ -44,34 +44,12 @@ repositories, manual installation of logkeys from source is as easy as:
( become super↙user now ) # you need root to install in system dir
# make install # installs binaries, manuals and scripts
That's it. If everything went through fine (as it mostly should, I think), you
can probably skip ahead to the next section now.
That's it.
To ever uninstall logkeys, remove accompanying scripts and manuals, issue
# make uninstall # in the same logkeys-0.1.0/build dir from before
To install the binaries in path other than /usr/local/bin, use configure with
--prefix switch, for example:
$ ../configure --prefix=/usr
Along with other standard configure options, you can also use:
$ ../configure --enable-evdev-path=PATH
to have logkeys look for input event devices in PATH ( $(PATH)/eventX ) instead
of preconfigured default /dev/input (/dev/input/eventX), and
$ ../configure --enable-evdev=DEV
to have logkeys define static event device DEV (i.e. /dev/input/eventX) instead
of looking for it in default /dev/input path or custom evdev-path.
The input event device we are referring to, here, is the kernel event interface
echoing keyboard events. If using either of these two --enable-evdev*
switches, make sure you provided correct PATH/DEV.
A copy of these instructions is in the accompanying INSTALL file.
......@@ -169,7 +147,8 @@ Report any bugs and request reasonable features on the issues list page
http://code.google.com/p/logkeys/issues .
Always provide descriptively keyworded summary and description.
When opening new issues, always provide descriptively keyworded summary and
description.
You are more than welcome to implement unreasonable features yourself, as well
as hack the program to your liking.
......
-> Add USB keyboard support.
-> Add support for sending logs via mail or POSTing them to remote server.
-> Add support for mouse events (i.e. on mouse click the focus may have changed).
-> Also log title of the focused window
-> Add support for sending logs via mail or POSTing them to remote server.
-> Add support for mouse events (i.e. on mouse click the focus may have changed).
......@@ -3,6 +3,9 @@
/* Define to 1 if you have the `atoi' function. */
#undef HAVE_ATOI
/* Define to 1 if you have the <cassert> header file. */
#undef HAVE_CASSERT
/* Define to 1 if you have the <cerrno> header file. */
#undef HAVE_CERRNO
......@@ -21,6 +24,18 @@
/* Define to 1 if you have the <cstring> header file. */
#undef HAVE_CSTRING
/* Define to 1 if you have the `error' function. */
#undef HAVE_ERROR
/* Define to 1 if you have the `error_at_line' function. */
#undef HAVE_ERROR_AT_LINE
/* Define to 1 if you have the <error.h> header file. */
#undef HAVE_ERROR_H
/* Define to 1 if you have the `exit' function. */
#undef HAVE_EXIT
/* Define to 1 if you have the `fclose' function. */
#undef HAVE_FCLOSE
......@@ -51,12 +66,12 @@
/* Define to 1 if you have the `fscanf' function. */
#undef HAVE_FSCANF
/* Define to 1 if you have the `getcwd' function. */
#undef HAVE_GETCWD
/* Define to 1 if you have the `geteuid' function. */
#undef HAVE_GETEUID
/* Define to 1 if you have the `getgid' function. */
#undef HAVE_GETGID
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
......@@ -66,6 +81,9 @@
/* Define to 1 if you have the `getpid' function. */
#undef HAVE_GETPID
/* Define to 1 if you have the `getuid' function. */
#undef HAVE_GETUID
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
......@@ -84,6 +102,9 @@
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have the `on_exit' function. */
#undef HAVE_ON_EXIT
/* Define to 1 if you have the `open' function. */
#undef HAVE_OPEN
......@@ -93,8 +114,11 @@
/* Define to 1 if you have the `remove' function. */
#undef HAVE_REMOVE
/* Define to 1 if you have the `setgid' function. */
#undef HAVE_SETGID
/* Define to 1 if you have the `setegid' function. */
#undef HAVE_SETEGID
/* Define to 1 if you have the `seteuid' function. */
#undef HAVE_SETEUID
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
......@@ -102,9 +126,6 @@
/* Define to 1 if you have the `setsid' function. */
#undef HAVE_SETSID
/* Define to 1 if you have the `setuid' function. */
#undef HAVE_SETUID
/* Define to 1 if you have the `sigaction' function. */
#undef HAVE_SIGACTION
......@@ -186,12 +207,6 @@
/* Define to 1 if the system has the type `_Bool'. */
#undef HAVE__BOOL
/* User defined input event device */
#undef INPUT_EVENT_DEVICE
/* User defined input event device path */
#undef INPUT_EVENT_PREFIX
/* Name of package */
#undef PACKAGE
......
......@@ -682,8 +682,6 @@ ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_dependency_tracking
enable_evdev_path
enable_evdev
'
ac_precious_vars='build_alias
host_alias
......@@ -1312,8 +1310,6 @@ Optional Features:
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--enable-evdev-path=PATH Search for input event devices in PATH
--enable-evdev=DEV Define input event device as DEV
Some influential environment variables:
CXX C++ compiler command
......@@ -3507,53 +3503,6 @@ if test x"$FOUND_DUMPKEYS" = xno ; then
as_fn_error "Required program dumpkeys is missing." "$LINENO" 5
fi
# Add --enable-evdev-path option
# Check whether --enable-evdev-path was given.
if test "${enable_evdev_path+set}" = set; then :
enableval=$enable_evdev_path;
cat >>confdefs.h <<_ACEOF
#define INPUT_EVENT_PREFIX "$enableval"
_ACEOF
as_ac_File=`$as_echo "ac_cv_file_$enableval" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $enableval" >&5
$as_echo_n "checking for $enableval... " >&6; }
if { as_var=$as_ac_File; eval "test \"\${$as_var+set}\" = set"; }; then :
$as_echo_n "(cached) " >&6
else
test "$cross_compiling" = yes &&
as_fn_error "cannot check for file existence when cross compiling" "$LINENO" 5
if test -r "$enableval"; then
eval "$as_ac_File=yes"
else
eval "$as_ac_File=no"
fi
fi
eval ac_res=\$$as_ac_File
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval as_val=\$$as_ac_File
if test "x$as_val" = x""yes; then :
else
as_fn_error "PATH provided in --enable-evdev-path does not exist. $enableval is not a valid directory!" "$LINENO" 5
fi
fi
# Add --enable-evdev option
# Check whether --enable-evdev was given.
if test "${enable_evdev+set}" = set; then :
enableval=$enable_evdev;
cat >>confdefs.h <<_ACEOF
#define INPUT_EVENT_DEVICE "$enableval"
_ACEOF
fi
# Checks for files
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/input" >&5
$as_echo_n "checking for /dev/input... " >&6; }
......@@ -3573,7 +3522,7 @@ $as_echo "$ac_cv_file__dev_input" >&6; }
if test "x$ac_cv_file__dev_input" = x""yes; then :
else
as_fn_error "Input event interface devices not at expected path! Use --enable-evdev-path to set the location of input event devices, e.g., ./configure --enable-evdev-path=/dev/input/ for event devices /dev/input/eventX." "$LINENO" 5
as_fn_error "Input event interface devices not found in expected location /dev/input/eventX !" "$LINENO" 5
fi
......@@ -3996,7 +3945,7 @@ fi
done
for ac_header in cstdio cerrno cstring sstream cstdlib csignal unistd.h getopt.h sys/file.h linux/input.h
for ac_header in cstdio cerrno cstring cassert sstream cstdlib csignal error.h unistd.h getopt.h sys/file.h sys/stat.h linux/input.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
......@@ -4007,7 +3956,7 @@ eval as_val=\$$as_ac_Header
_ACEOF
else
as_fn_error "Expected header missing!" "$LINENO" 5
as_fn_error "Expected header file is missing!" "$LINENO" 5
fi
......@@ -4440,7 +4389,7 @@ $as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h
fi
for ac_func in geteuid getcwd memset setlocale strerror fprintf getopt_long fopen sscanf fscanf getpid fclose remove kill strlen strcat strcpy strncat freopen feof fgets atoi sigaction fork setsid open close flock write umask setgid setuid strftime localtime fflush read sleep time
for ac_func in geteuid error error_at_line exit on_exit memset setlocale strerror fprintf getopt_long fopen sscanf fscanf getpid getuid getgid fclose remove kill strlen strcat strcpy strncat freopen feof fgets atoi sigaction fork setsid open close flock write umask setegid seteuid strftime localtime fflush read sleep time
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
......@@ -4451,7 +4400,7 @@ eval as_val=\$$as_ac_var
_ACEOF
else
as_fn_error "Expected function missing!" "$LINENO" 5
as_fn_error "Expected function is missing!" "$LINENO" 5
fi
done
......
......@@ -27,30 +27,11 @@ if test x"$FOUND_DUMPKEYS" = xno ; then
AC_MSG_ERROR([Required program dumpkeys is missing.])
fi
# Add --enable-evdev-path option
AC_ARG_ENABLE(
[evdev-path],
[ --enable-evdev-path=PATH Search for input event devices in PATH],
[AC_DEFINE_UNQUOTED([INPUT_EVENT_PREFIX], ["$enableval"], [User defined input event device path])
AC_CHECK_FILE(
[$enableval],
[],
AC_MSG_ERROR([PATH provided in --enable-evdev-path does not exist. $enableval is not a valid directory!])
)
]
)
# Add --enable-evdev option
AC_ARG_ENABLE(
[evdev],
[ --enable-evdev=DEV Define input event device as DEV],
[AC_DEFINE_UNQUOTED([INPUT_EVENT_DEVICE], ["$enableval"], [User defined input event device])],
[]
)
# Checks for files
AC_CHECK_FILE(
[/dev/input],
[],
[AC_MSG_ERROR([Input event interface devices not at expected path! Use --enable-evdev-path to set the location of input event devices, e.g., ./configure --enable-evdev-path=/dev/input/ for event devices /dev/input/eventX.])]
[AC_MSG_ERROR([Input event interface devices not found in expected location /dev/input/eventX !])]
)
AC_CHECK_FILE(
[/proc/bus/input/devices],
......@@ -60,9 +41,9 @@ AC_CHECK_FILE(
# Checks for header files.
AC_CHECK_HEADERS(
[cstdio cerrno cstring sstream cstdlib csignal unistd.h getopt.h sys/file.h linux/input.h],
[cstdio cerrno cstring cassert sstream cstdlib csignal error.h unistd.h getopt.h sys/file.h sys/stat.h linux/input.h],
[],
[AC_MSG_ERROR([Expected header missing!])]
[AC_MSG_ERROR([Expected header file is missing!])]
)
# Checks for typedefs, structures, and compiler characteristics.
......@@ -75,9 +56,9 @@ AC_TYPE_SIZE_T
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_CHECK_FUNCS(
[geteuid getcwd memset setlocale strerror fprintf getopt_long fopen sscanf fscanf getpid fclose remove kill strlen strcat strcpy strncat freopen feof fgets atoi sigaction fork setsid open close flock write umask setgid setuid strftime localtime fflush read sleep time],
[geteuid error error_at_line exit on_exit memset setlocale strerror fprintf getopt_long fopen sscanf fscanf getpid getuid getgid fclose remove kill strlen strcat strcpy strncat freopen feof fgets atoi sigaction fork setsid open close flock write umask setegid seteuid strftime localtime fflush read sleep time],
[],
[AC_MSG_ERROR([Expected function missing!])]
[AC_MSG_ERROR([Expected function is missing!])]
)
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile scripts/Makefile])
......
#ifndef _DEFAULT_KEYS_H_
#define _DEFAULT_KEYS_H_
#include <cassert>
#include <linux/input.h>
// these are ordered default US keymap keys
wchar_t char_keys[49] = L"1234567890-=qwertyuiop[]asdfghjkl;'`\\zxcvbnm,./<";
wchar_t shift_keys[49] = L"!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL:\"~|ZXCVBNM<>?>";
wchar_t altgr_keys[49] = {0}; // old, US don't use AltGr key: L"\0@\0$\0\0{[]}\\\0qwertyuiop\0~asdfghjkl\0\0\0\0zxcvbnm\0\0\0|"; // \0 on no symbol; as obtained by `loadkeys us`
// TODO: add altgr_shift_keys[]
char func_keys[][8] = {
"<Esc>", "<BckSp>", "<Tab>", "<Enter>", "<LCtrl>", "<LShft>", "<RShft>", "<KP*>", "<LAlt>", " ", "<CpsLk>", "<F1>", "<F2>", "<F3>", "<F4>", "<F5>",
"<F6>", "<F7>", "<F8>", "<F9>", "<F10>", "<NumLk>", "<ScrLk>", "<KP7>", "<KP8>", "<KP9>", "<KP->", "<KP4>", "<KP5>", "<KP6>", "<KP+>", "<KP1>",
"<KP2>", "<KP3>", "<KP0>", "<KP.>", /*"<",*/ "<F11>", "<F12>", "<KPEnt>", "<RCtrl>", "<KP/>", "<PrtSc>", "<AltGr>", "<Break>" /*linefeed?*/, "<Home>", "<Up>", "<PgUp>",
"<Left>", "<Right>", "<End>", "<Down>", "<PgDn>", "<Ins>", "<Del>", "<Pause>", "<LMeta>", "<RMeta>", "<Menu>"
};
const char char_or_func[] = // c = character key, f = function key, _ = blank/error ('_' is used, don't change); all according to KEY_* defines from <linux/input.h>
"_fccccccccccccff"
"ccccccccccccffcc"
"ccccccccccfccccc"
"ccccccffffffffff"
"ffffffffffffffff"
"ffff__cff_______"
"ffffffffffffffff"
"_______f_____fff";
#define N_KEYS_DEFINED 106 // sum of all 'c' and 'f' chars in char_or_func[]
inline bool is_char_key(unsigned int code)
{
assert(code < sizeof(char_or_func));
return (char_or_func[code] == 'c');
}
inline bool is_func_key(unsigned int code)
{
assert(code < sizeof(char_or_func));
return (char_or_func[code] == 'f');
}
inline bool is_used_key(unsigned int code)
{
assert(code < sizeof(char_or_func));
return (char_or_func[code] != '_');
}
// translates character keycodes to continuous array indices
inline int to_char_keys_index(unsigned int keycode)
{
if (keycode >= KEY_1 && keycode <= KEY_EQUAL) // keycodes 2-13: US keyboard: 1, 2, ..., 0, -, =
return keycode - 2;
if (keycode >= KEY_Q && keycode <= KEY_RIGHTBRACE) // keycodes 16-27: q, w, ..., [, ]
return keycode - 4;
if (keycode >= KEY_A && keycode <= KEY_GRAVE) // keycodes 30-41: a, s, ..., ', `
return keycode - 6;
if (keycode >= KEY_BACKSLASH && keycode <= KEY_SLASH) // keycodes 43-53: \, z, ..., ., /
return keycode - 7;
if (keycode == KEY_102ND) return 47; // key right to the left of 'Z' on US layout
return -1; // not character keycode
}
// translates function keys keycodes to continuous array indices
inline int to_func_keys_index(unsigned int keycode)
{
if (keycode == KEY_ESC) // 1
return 0;
if (keycode >= KEY_BACKSPACE && keycode <= KEY_TAB) // 14-15
return keycode - 13;
if (keycode >= KEY_ENTER && keycode <= KEY_LEFTCTRL) // 28-29
return keycode - 25;
if (keycode == KEY_LEFTSHIFT) return keycode - 37; // 42
if (keycode >= KEY_RIGHTSHIFT && keycode <= KEY_KPDOT) // 54-83
return keycode - 48;
if (keycode >= KEY_F11 && keycode <= KEY_F12) // 87-88
return keycode - 51;
if (keycode >= KEY_KPENTER && keycode <= KEY_DELETE) // 96-111
return keycode - 58;
if (keycode == KEY_PAUSE) // 119
return keycode - 65;
if (keycode >= KEY_LEFTMETA && keycode <= KEY_COMPOSE) // 125-127
return keycode - 70;
return -1; // not function key keycode
}
#endif
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment