summaryrefslogtreecommitdiffstatshomepage
path: root/xkbcat.c
Commit message (Collapse)AuthorAgeFilesLines
* Always clean up event dataGravatar Tom Willemse2025-09-011-4/+6
| | | | | Finally, a use case for ‘goto’ that I think solves the issue pretty nicely. Not so evil after all, perhaps.
* Skip any normal letter keysGravatar Tom Willemse2025-09-011-0/+8
| | | | | | | | I want to know specifically which keys I use the most that _aren't_ just letters. I have a keyboard layout that I like just fine, but I want to know which special keys I actually use the most.
* ReformatGravatar Tom Willemse2025-09-011-132/+139
|
* Use group 0 if current group contains no keysymGravatar Antti Korpimäki2021-12-131-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #5, perhaps fully this time. It seems non-zero keysym groups work such that if no keysym is defined in it, the default 0 group's keysym is assumed. In other words, common keys that would otherwise just be duplicated in the group's definition, such as Return, Backspace, Delete, Shift, Space, or the numpad keys, just have no symbol mapped to them at all in the group (XkbKeycodeToKeysym returns NoSymbol). In such cases, it seems the receiving program is expected to just fall back to group 0 and read the keysym from there instead. This is about XKeycodeToKeysym, but XkbKeycodeToKeysym which we're using (note the different prefix) seems to function the same: https://stackoverflow.com/questions/54483276/xkeysymtokeycode-and-keyboard-layout This seems to be correct with the keyboard layouts I've tested. - - - Other Xlib users have replaced XKeycodeToKeysym with XGetKeyboardMapping instead. These patches to that effect imply XKeycodeToKeysym is deprecated: - https://lists.freedesktop.org/archives/piglit/2012-January/001795.html - https://github.com/ArcticaProject/nx-libs/commit/c79f2d289004d419d8bb76cf8bf731980d40da5d XkbKeycodeToKeysym is not deprecated though, and seems a much better fit here than doing heap allocations in a loop, so I'll go with it.
* Support switching keyboard layoutsGravatar Antti Korpimäki2021-12-071-11/+47
| | | | | | | | | | | | | | As noted in issue #5, xkbcat would previously not react at all to keyboard layout changes; it would continue to print keysyms according to the first keyboard layout X was started with. Keyboard keysym group changes (i.e. keyboard layout changes) are listened to as separate events, so if you only use 1 layout, this causes no performance overhead. Closes #5. Thanks to @unxed for very helpful research.
* Error when -display option is given without valueGravatar Antti Korpimäki2021-10-011-1/+10
| | | | | | | | This was always invalid input, but there was no special handling, so if the `-display` option was given in the last position, the value could be read 1 entry off the end of the `argv` array. This catches that, and gives an informative error.
* Quote user-supplied portion in display open errorGravatar Antti Korpimäki2021-10-011-1/+1
| | | | Clearer.
* Tidy: Better comments, scope tempvars, better errsGravatar Antti Korpimäki2021-06-251-29/+32
| | | | Maintenance. No functionality changes.
* Only fflush on loop iterations that printGravatar Antti Korpi2020-03-221-1/+1
| | | | Saves cycles.
* Select for XI_RawKeyRelease at mask, not mainloopGravatar Antti Korpi2020-03-221-2/+2
| | | | Saves cycles.
* Tidy main loop formattingGravatar Antti Korpi2020-03-221-6/+5
|
* Query for specific XInput2 versionGravatar Antti Korpi2020-03-221-4/+14
| | | | | | | | | | | | This is necessary to guarantee the same API in case future versions of XInput decide to break backward compatibility in their defaults. Quoting `man 3 xiqueryversion`: > Clients are required to use XIQueryVersion instead of > XGetExtensionVersion if they use XI2 calls. The server may treat a > client differently depending on the supported version announced by the > client.
* Refactor: Avoid underscores in non-const var namesGravatar Antti Korpi2020-03-221-3/+3
|
* Use XInput2 raw master device instead of pollingGravatar Antti Korpi2016-04-221-48/+44
| | | | Neater implementation, better performance.
* Remove "-time": instead recommend an external toolGravatar An Ko2016-02-161-13/+4
| | | | Undoing my unnecessary feature creep.
* Flush on writeGravatar Antti K2014-08-051-0/+3
| | | | Ensures that all output is received immediately if it's being piped.
* Unextract printKeyPressGravatar Antti K2014-08-021-19/+17
| | | | | | This is clearer to read, as the amount of state being passed into the utility function caused more distracting boilerplate than having a separate function was worth.
* Document keyState functionGravatar Antti K2014-08-021-0/+4
| | | | Yeah, that did look a bit arcane.
* Move keypress print func to before mainGravatar Antti K2014-08-021-14/+12
| | | | | Means we need no separate declaration, and it's a lot easier to infer that the function is pure.
* Also document timestamp flag in usage printGravatar Antti K2014-08-021-1/+1
|
* Print epoch timestamps given `-time`Gravatar Antti K2014-08-011-12/+20
| | | | | | | It's seconds since epoch. People tend to type faster than that, but this is a standard format. Existing options work the same way.
* Report exact unexpected argumentGravatar Antti K2014-07-301-1/+1
|
* `puts` when `printf`ing a string onlyGravatar Antti K2014-07-301-2/+1
| | | | | Easier to read. (Compilers would probably optimise the `printf` into a `puts` anyway.)
* Small clarificationsGravatar Antti K2014-07-301-6/+6
| | | | | | | Improved comments. Moved declaration of `printKeyPress` further down to decrease cognitive load.
* Remove extraneous bracketsGravatar Antti K2014-07-301-1/+1
|
* Consistency: Make default display a const char *Gravatar Antti K2014-07-301-6/+6
| | | | | | | Yep, `hostname` is a `const char *` too, even though it's potentially being assigned to. This is [unintuitive](http://stackoverflow.com/a/9834194/777586), but intentional.
* Minor spacing and arrangementGravatar Antti K2014-07-301-10/+7
|
* Prune includesGravatar Antti K2014-07-301-2/+0
| | | | | Since XKBlib pulls in all of our other X dependencies, there's no need to separately `#include` them.
* Simplify result printingGravatar Antti K2014-07-301-26/+14
| | | | | | | | | There's no need to copy strings around when all we want is to print it anyway. This is faster and easier to read. Also made the output format adapt to whether `printKeyUps` is set: There's no need to print `+` and `-` if all that we're printing is keydowns anyway.
* Conciser global-description commentGravatar Antti K2014-07-301-6/+1
|
* Move keysym length constant to where neededGravatar Antti K2014-07-301-1/+1
| | | | Easier to read `main` when this state isn't there.
* Indentation and spacing fixesGravatar Antti K2014-07-301-15/+15
|
* Clarify key state buffer handlingGravatar Antti K2014-07-301-15/+22
| | | | | | | | | | The typedef makes stuff a little more readable and introduces to the typechecker that its size must be 32 elements. Naming clarifications too. The logic in the inner conditionals was often `fflush`ing even when there had been no `printf`.
* Setup buffers only once necessaryGravatar Antti K2014-07-301-4/+3
| | | | | This also somewhat clarifies the relationships between the `char` arrays and the pointers to them.
* Separate variables that have opt-set valuesGravatar Antti K2014-07-301-4/+5
| | | | Simpler to read. Also makes it clearer what the default values are.
* Scope temporary variable (for swapping) further inGravatar Antti K2014-07-301-5/+5
| | | | Less to remember when reading.
* Clean up argument handlingGravatar Antti K2014-07-301-10/+4
| | | | Easier on the eyes this way.
* More explicit name for usage printer functionGravatar Antti K2014-07-301-3/+3
|
* Remove globals in favour of arg passingGravatar Antti K2014-07-301-11/+10
| | | | | | | | Makes the code easier to read: Less state to remember. This also "accidentally" fixes a bug where `-help` would report the wrong default value for the `-up` argument if `-up` had was set previously in the same command.
* Convert single-line comments to C99Gravatar Antti K2014-07-301-9/+9
|
* Document origin and inspiration in a separate fileGravatar Antti K2014-07-301-10/+2
| | | | This keeps source separate from history.
* Rename stringification functionGravatar Antti K2014-07-301-4/+3
| | | | | It's not just converting a keycode, but also the key's down-state, so this is a better name. Also converted down-state arg to `bool`.
* Replace deprecated XKeycodeToKeysymGravatar Antti K2014-07-301-1/+2
| | | | | | ...with XKB's equivalent. `-Wall` without warnings, yey.
* Shorter struct initGravatar Antti K2014-07-301-4/+1
| | | | Somewhat more readable this way.
* Nicer constant formattingGravatar Antti K2014-07-301-5/+3
|
* Use nanosecond parameterGravatar Antti K2014-07-301-4/+4
| | | | Might as well expose that precision to the user.
* Use nanosleep instead of usleepGravatar Antti K2014-07-291-4/+10
| | | | `usleep` is removed from POSIX C11.
* Convert BIT macro to inlined functionGravatar Antti K2014-07-291-1/+3
| | | | Inlined just like a macro, but has typechecking to prevent bloopers.
* Remove compilation instructions from source fileGravatar Antti K2014-07-291-1/+0
| | | | The `compile`-script already documents this sufficiently.
* Use C99 booleansGravatar Antti K2014-07-291-7/+4
| | | | No need for TRUE/FALSE macros anymore.