summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Antti K2014-08-02 18:10:22 +0200
committerGravatar Antti K2014-08-02 18:10:22 +0200
commite1e84630314fe01e96e9846078e7557ed2277b83 (patch)
treea60fac790f1c6c9dab77854ac0b87c222cff07d2
parentda8a1a9955de5c5d429b1bc29687a13afe7cb95c (diff)
downloadxkbcat-e1e84630314fe01e96e9846078e7557ed2277b83.tar.gz
xkbcat-e1e84630314fe01e96e9846078e7557ed2277b83.zip
Move keypress print func to before main
Means we need no separate declaration, and it's a lot easier to infer that the function is pure.
-rw-r--r--xkbcat.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/xkbcat.c b/xkbcat.c
index 4fd31a5..7a39a99 100644
--- a/xkbcat.c
+++ b/xkbcat.c
@@ -31,7 +31,18 @@ USAGE: xkbcat [-display <display>] [-delay <nanosec>] [-up] [-time]\n\
exit(0);
}
-void printKeyPress(Display * disp, int code, bool down, bool printKeyUps, long time, bool printTimes);
+// Since `XKeysymToString` returns a string of unknown length that shouldn't be
+// modified, so it makes more sense to just `printf` it in-place.
+void printKeyPress(Display * disp, int code, bool down, bool printKeyUps, long timestamp, bool printTimes) {
+
+ KeySym s = XkbKeycodeToKeysym(disp, code, 0, 0); if (NoSymbol == s) return;
+ char * str = XKeysymToString(s); if (NULL == str) return;
+
+ if (printKeyUps) printf("%s ", (down ? "+" : "-"));
+ printf("%s", str);
+ if (printTimes) printf(" %ld", timestamp);
+ printf("\n");
+}
int main(int argc, char * argv[]) {
@@ -89,16 +100,3 @@ int main(int argc, char * argv[]) {
nanosleep(&sleepTime, NULL);
}
}
-
-// Since `XKeysymToString` returns a string of unknown length that shouldn't be
-// modified, so it makes more sense to just `printf` it in-place.
-void printKeyPress(Display * disp, int code, bool down, bool printKeyUps, long timestamp, bool printTimes) {
-
- KeySym s = XkbKeycodeToKeysym(disp, code, 0, 0); if (NoSymbol == s) return;
- char * str = XKeysymToString(s); if (NULL == str) return;
-
- if (printKeyUps) printf("%s ", (down ? "+" : "-"));
- printf("%s", str);
- if (printTimes) printf(" %ld", timestamp);
- printf("\n");
-}