Commit Graph

118 Commits

Author SHA1 Message Date
Martin Pulec
cf87430666 keyboard_control: improved including 2024-07-08 16:45:38 +02:00
Martin Pulec
6311f3f196 slightly reordered keyboard_control to make Coverity happy
refers to CID 464439

Actually not much important - the m_started variable is not shared across
threads but should be used only from within the main thread (start()
stop() member functions).
2024-07-08 10:20:49 +02:00
Martin Pulec
f01e4c36b7 moved around compat functions
moved compat functions from config_*h, namely:
- localtime_s/gmtime_s
- strerror_s
- mkdir Windows compat
- removed str[n]cmp from compat/misc (already in compat/strings,h,
which is the better location)

Do not use config*.h in export.c (motivation for the above changes).
2024-06-12 14:02:42 +02:00
Martin Pulec
56a6dc78b0 replace remaining WIN32 platform macros
see the commit HEAD@{2}
2024-05-13 12:56:53 +02:00
Martin Pulec
3ab94c6f75 interactive control audio clarification
Indicate the audio keybindings that are for receiver/playback as so not
to leave user in doubt.
2024-05-07 12:04:50 +02:00
Martin Pulec
70a8c1e10c keycontrol: avoid mixing stdio and POSIX read API
getchar() must not be used to read a character when there are more than
one at once because otherwise won't next select() return and the key
will remain in the stdio buffer.

Fixed:
``
(sleep 2; printf '\x18M';  sleep 50 ) | ./build/bin/uv -s testcard -r alsa --param disable-keyboard-control=no
```
when the 'M' key was not processed immediately but just at the end of
the process.
2023-09-27 09:24:47 +02:00
Martin Pulec
123b2fa6fc keycontrol: override term check with param
Run the keycontrol even if 0 is not TTY with `--param
disable-keyboard-control=no`.
2023-09-27 09:24:47 +02:00
Martin Pulec
fe999cc666 restore TIO unconditionally
the check is perhaps unneeded - restoring twice won't hurt

More importantly, it didn't restore the TIO when sequence restore_tio()
-> set_tio() is called repeatedly. Concretely, entering interactive cmds:

1. Ctrl-X - unlock control
2. 'c' - one-time command mode
3. 'help<cr>' -
4. 'c' - one-time command mode
5. 'help<cr>' -

the second "help" was not echoed, because restore_tio() was called before
3, but second run of the function was not run. Moreover, after 5, the saved TIO
will be perhaps replaced by the curend one by set_tio().
2023-09-25 16:29:04 +02:00
Martin Pulec
8a50ff4d2e audio messages: rename MUTE->MUTE_TOGGLE
* the MUTE commands are actually mute-toggle
2023-09-25 16:29:03 +02:00
Martin Pulec
f82091842b keyboard control: print elapsed time in info
+ use the thread-safe time-related functions variants
2023-08-01 16:19:46 +02:00
Martin Pulec
e1b28f83d6 keyboard_control: option to force in gdb
doesn't seem to be necessary at least since gdb 9.2 in Ubuntu 20.04
2023-06-15 16:14:08 +02:00
Martin Pulec
602095e38a fixed some further snprintf warns
fixes warnings with Xcode 14.3 as in previous commit

+ allocate +1 in Log_output buffer - snprintf(MULL, 0...) returns number
  of bytes without terminating '\0'. std::string storage isn't guaranteed
  to be NULL-terminated (std::string("").at(0) throws an exception). The
  buffer is somewhere preallocated 256 which prevents problem but it's
  better not to rely upon it.
+ comment out some unused function in LDGM that also triggered the
  warning but looked a bit suspicious so it was not clear how to fix
2023-04-12 12:52:07 +02:00
Martin Pulec
d9aa8dcb1f fixed incomp. keyboard_control::impl decl & def 2022-11-08 16:49:37 +01:00
Martin Pulec
59de3f69e8 key_control: hide implementation
termios.h would interfere with Vulkan headers otherwise (Arch Linux)

+ added missing includes in pano_gl
2022-11-03 13:16:59 +01:00
Martin Pulec
b1f0e004f4 fixed new Coverity bugs
Fixed some of (easy) newly detected Coverity bugs. Those are mostly
innocent ones (performance) and not new (detected because of new release
of Coverity).
2022-08-22 09:57:16 +02:00
Martin Pulec
65557d112d get rid of rang.hpp dependency through color_out.h
Removed indirect dependency on rang.hpp through color_out.h. Now only
remaining dependencies on rang.hpp are direct.

+ fixed escape sequence for foreground magenta
2022-08-17 17:24:34 +02:00
Martin Pulec
95b851eecb replaced \e with \033
'\e' is not standard C, see:
https://stackoverflow.com/questions/63255838/how-can-i-fix-warning-c4129-e-unrecognized-character-escape-sequence/63255920#63255920
2022-08-10 17:01:31 +02:00
Martin Piatka
e0245aeda5 host,keyboard_control: Move gdb detection to a function 2022-08-09 11:48:58 +02:00
Martin Piatka
ca0421787a keyboard_control: use getter&setter for repeat skipping 2022-08-05 13:44:35 +02:00
Martin Pulec
53caa93976 restore old tio in crash_signal_handler
In case of crash, atexit callbacks are not called, thus terminal state
is not restored (if modified by keyboard control).
2022-08-04 14:07:46 +02:00
Martin Piatka
65d7cf69b8 logging: Split timestamp and repeat functionality into its own class
This will eventually allow better integration with other formatting
functions like color_out, color_printf
2022-08-03 10:41:14 +02:00
Martin Pulec
59379869d8 key control: disable if running in GDB
Terminal control (especitally turning echo off) is probably not a best
idea if running from inside GDB.
2022-06-29 09:33:53 +02:00
Martin Pulec
69145ce011 fixed Coverity CID 383373 2022-02-21 15:32:03 +01:00
Martin Pulec
35bfc4cced Fixed warnings for -Og 2022-01-17 15:10:34 +01:00
Martin Pulec
1b3b27eb7c Updated copyright dates for modified files 2021-11-08 15:43:14 +01:00
Martin Pulec
2e13a04dff Key control: print version
May be used for quick check if not running an obsolete UG during
runtime.
2021-11-01 09:20:44 +01:00
Martin Pulec
dfe80f3348 keyboard_control.cpp: refactor a bit the audio query stuff
(related to previous commmit)
2021-10-27 14:35:07 +02:00
Martin Pulec
2ec8eec912 Audio: display muted status even if not sending
Originally mute for both sender and receiver were dispatched by the
sender, which doesn't need to be present, however.
2021-10-27 13:31:17 +02:00
Martin Pulec
50d759fc9a Audio: interactive info mute improvements
- show actual playback volume as 0 (-inf) if muted receiver
- display explicitly receiver mute status
- "Received audio volume" -> "Playback volume" - this has more clear
  semantics and is consistent with message written when '*'/'/'/'m' is
  pressed.
2021-10-04 11:55:01 +02:00
Martin Pulec
2865ea8a4c keycontrol_send_key(): improved doxy documentation 2021-08-02 15:13:58 +02:00
Martin Pulec
b97dc5ffda Fixed some Windows warnings 2021-05-13 09:08:26 +02:00
Martin Pulec
b888e09800 Key control: shortcut to control repeating of msgs 2020-11-13 14:50:29 +01:00
Martin Pulec
48895b0783 ADD_TO_PARAM: salt is no longer needed
UNIQUE_NAME is used instead of the salt
2020-06-09 14:02:37 +02:00
Martin Pulec
ea3a9deba5 Keycontrol: store tio state first
Previously the state was saved too late, eg. when display was libcaca
(over SDL) the saved state has been already modified.
2020-04-23 14:56:21 +02:00
Martin Pulec
07309035a5 Control: warn about unknown command 2020-04-21 18:27:57 +02:00
Martin Pulec
363729fbcd Keycontrol: fixes
- fixed few warnings (UTF-8 code 0 UB, read fail)
- keycodes can be up to 64-bit (some places used int)
2020-04-21 18:27:57 +02:00
Martin Pulec
1a8523f12c Keycontrol: use more user-friendly key names 2020-02-04 11:24:04 +01:00
Martin Pulec
63606f3f9d Missing Ctrl-{up,dn} string representation 2020-02-04 11:23:15 +01:00
Martin Pulec
9dba8b7bed Keycontrol: fixed parsing of "map" message
Strtoll must be used instead of strtol because long is 32-bit in Win64
API.
2020-01-29 17:09:29 +01:00
Martin Pulec
75e3b22b79 Keycontrol: deinitialize module in stop 2019-11-29 17:20:04 +01:00
Martin Pulec
5f349ea55a Support for PgUp/PgDown 2019-11-27 15:35:15 +01:00
Martin Pulec
18a5252eb8 Keycontrol: print error when re-registring the same key 2019-11-27 07:43:44 +01:00
Martin Pulec
184b51997e Keycontrol: again initailize relatively soon
Module that register their keybindings use NOSTORE option.
2019-11-27 07:43:43 +01:00
Martin Pulec
09f6bafc58 Coverity fixes 2019-11-22 13:54:51 +01:00
Martin Pulec
ee76cba241 Keycontrol: fixes
- register module only if started
- name thread in correct function
2019-11-20 22:39:18 +01:00
Martin Pulec
64a2d4bc02 Main: exit modules before common_cleanup
In MSW, pipe is emulated over network socket (used by state_uv).
Common_cleanup, however, calls WSACleanup().
2019-11-19 19:45:20 +01:00
Martin Pulec
fa51f6e33c Fixed incorrectly fixed Coverity bugs 2019-11-12 22:34:18 +01:00
Martin Pulec
4c71573a89 Fixed first series of Coverity bugs 2019-11-09 17:20:37 +01:00
Martin Pulec
3795e5a6c6 Keycontrol: updates
- support for alt
- is_utf8: fixed infinite loop when for negative number
- do not use tolower() in K_CTRL - is not constexpr
- get_keycode_name - safety check
2019-11-04 11:47:59 +01:00
Martin Pulec
dcc550d677 Keycontrol: shortened some names
This allows easier formatting - name is now at most 7 characters long.

+ assert to check if parameters to keycontrol_register_key() do not
  contain '#'-symbols.
2019-11-04 10:42:02 +01:00