Commit graph

73 commits

Author SHA1 Message Date
Elyes Haouas 338d9c35d5 kbdcontrol: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
2024-04-28 21:24:47 -06:00
Jessica Clarke 968a3db715 kbdcontrol: Support building as a bootstrap tool on old and non-FreeBSD
Systems that predate 971bac5ace ("kbd: consolidate kb interfaces
(phase one)") cannot build kbdcontrol since kbdelays and kbrates moved
to sys/kbio.h. Moreover, on non-FreeBSD, it requires all kinds of ioctls
and sysctls that are highly FreeBSD-specific to build, but we use it as
a bootstrap tool to generate the keymaps used by some kernels (LINT ones
in particular). Thus, when bootstrapping kbdcontrol, disable everything
that's not needed for that singular use, and use the in-tree kbio.h to
get the definitions of the necessary structures.

This allows KBDMUX_DFLT_KEYMAP, UKBD_DFLT_KEYMAP and ATKBD_DFLT_KEYMAP
to be enabled when building on non-FreeBSD, and thus LINT kernels.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D41541
2023-08-22 21:00:28 +01:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 761ab48d6a kbdcontrol: Remove compat code for 4.x -> 5.x transition
I think we're safely past that now...

Sponsored by:		Netflix
2023-07-06 23:10:18 -06:00
Michael 971bac5ace kbd: consolidate kb interfaces (phase one)
Refactor to eliminate duplicated rate and delay tables, with minor style
tweaks for changed lines.  Remove an obsolete comment about needing to
convert from microseconds to ticks (that's done elsewhere). Remove
traiing whitespace in kbdcontrol.c.

Except for the new warning, no change in behavior

Sponsored by: 		DSS GmbH
Reviewed by:		imp [minor style tweaks as well]
Pull Request:		https://github.com/freebsd/pull/683
Differential Revision: 	https://reviews.freebsd.org/D38818
2023-07-06 23:10:18 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Stefan Eßer b4eab621f2 kbdcontrol.c: make pre-Unicode compatibility conditional
Support for the full range of Unicode character codes has been added
to the main keymap back in 2009, with compatibility shims added in
2011 (to support an older kbdcontrol command on a new kernel during
an upgrade from FreeBSD-8 to FreeBSD-9).

Unicode support for accented characters that are reached via dead key
combinations has been added just recently, again with compatibility
shims to allow all combinations of old/new kernel and old/new
kbdcontrol command to load and display the keymaps including the dead
key table. (But full Unicode in the dead key table requires both a new
kernel and kbdcontrol command.)

This commit makes the compatibility shims depend on the respective
compatibility ioctls (OGIO_KEYMAP, OPIO_KEYMAP, OGIO_DEADKEYMAP, and
OPIO_DEADKEYMAP) being defined in sys/kbio.h. This is true for all of
them in 13-STABLE, none in 12-STABLE (as of now), and will become
optional due to a follow-up commit to sys/kbio.h in -CURRENT.

This commit is the only part of review D38465 that should be merged
back to 12-STABLE and 13-STABLE.

MFC after:	1 month
2023-02-14 13:27:27 +01:00
Stefan Eßer b92f8e5c0d usr.sbin/kbdcontrol.c: Add backwards compatibility functions
This commit allows a kbdcontrol binary built with a version of kbio.h
that supports Unicode characters in dead key maps to load and display
keymaps including the dead key tables on a kernel built with a
previous version of kbio.h (that only supported 8 bit characters in
the dead key map).

This commit is meant as a temporary compatibility shim that will be
reverted when it can be assumed that all relevant systems have been
upgraded to a kernel that uses the updated kbio.h.

MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38388
2023-02-06 23:56:44 +01:00
Warner Losh 73701bbe9d kbdcontrol -h prints two error messages.
We loop through getopt(3) twice. Once for -P args and once for the
rest. Catch '?' and print usage when that happens.
2019-06-24 21:05:14 +00:00
Stefan Eßer 96329ce7e2 Silence Clang Scan warning about use of unitialized variable.
While the warning is a false positive, it is possible to clarify the code by
always initializing the variable. This does also allow to make the sending
of the "beep" control sequence depend on the validity of its parameters.

I have left the redundant assignment of 0 to the now initialized variables
in place since this makes the code simpler to understand and does not add
any run-time overhead (the compiler completely removes the "else if" test
and the assignments).

There was an embedded literal escape character in a string, which messes up
diplaying the source code on a terminal that interprets ANSI sequences. The
literal escape has been replaced by \e (non-standard, but supported by all
relevant compilers, and already used in other source files in base).

MFC after:	2 weeks
2019-01-23 10:05:27 +00:00
Pedro F. Giffuni 1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Ed Maste 8c0d1b4798 kbdcontrol: add -P path option to add keymap search paths
PR:		193865
Reviewed by:	cem
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5645
2016-03-16 04:05:02 +00:00
Stefan Eßer 0ae9426c10 Remove band.aid that made kbdcontrol lookup keymap files in the syscons
path even under vt, which is no longer useful, since the syscons keymap
files have been converted and committed for use by vt.
2014-08-26 09:37:43 +00:00
Stefan Eßer 895a99ef10 The previous commit (r269119) introduced a regression: It removed the
ability to specify the the full path name of the keymap file.

Instead leave the original search order intact, but insert the path for
newcons-specific fonts (if run on a system using newcons):

	- KEYMAP_PATH in environment
	- full path name
	- /usr/share/vt/keymaps		(only if newcons is in use!)
	- /usr/share/syscons/keymaps	(also as fall-back for newcons)

MFC after:	1 week
2014-07-26 13:14:28 +00:00
Stefan Eßer e34c3e1817 Fix obvious off by one error: prefix[1] should be set to the path of the
newcons specific keymap files, not prefix[2]. The result of this bug was
that kbdcontrol ignored the files in the syscons keymap directory, which
apparently still work under newcons, for most locales.

MFC after:	1 week
2014-07-26 12:17:26 +00:00
Ed Maste 6c79f78813 Fix vt(4) detection in kbdcontrol and vidcontrol
As sc(4) and vt(4) coexist and are both enabled in GENERIC, the existence
of a vt(4) sysctl is not sufficient to determine that vt(4) is in use.

Reported by:	Trond Endrestøl
2014-07-02 20:40:59 +00:00
Aleksandr Rybalko 2f11ee6205 Enable kbdcontrol(1) to use maps from vt(4) keymaps dir /usr/share/vt/keymaps
if vt(4) is present.

MFC after:	7 days
Sponsored by:	The FreeBSD Foundation
2014-05-29 14:39:25 +00:00
Ulrich Spörlein f76b319989 Reencode files to UTF-8. Drop CP1252 em-dash. 2011-12-30 00:59:08 +00:00
Ed Schouten 4d9a3537ff Add missing static and const keywords to kbdcontrol.
None of the symbols provided by kbdcontrol.c are used by other source
files of this binary. Slightly reduce the binary size and make much more
symbols read-only by adding proper static and const keywords.
2011-12-12 12:33:38 +00:00
Ed Schouten 9a958de54c ANSIfy some more tools in usr.sbin/.
Most of these tools build with WARNS=6, except for their use of K&R
function declarations.
2010-01-02 11:05:34 +00:00
Ed Schouten b05f9c86d1 Make the keyboard layer Unicode aware.
Just take keyent_t to use an u_int to store the Unicode codepoints.
Unfortunately the keymap is now too big to be loaded using an ioctl
argument, so change the ioctl to pick a pointer.

This change breaks kbdcontrol ABI. It doesn't break X11, because X11
doesn't do anything with syscons keymaps. It just switches the device
out of K_XLATE.

Obtained from:	//depot/user/ed/newcons/...
2009-09-19 17:56:26 +00:00
Ed Schouten daf4075a30 Unhardcode 0x100 inside kbdcontrol.
In preparation for Unicode support for the keyboard layer, we'd better
get rid of all the hardcoded 0x100/0xff constants in kbdcontrol.
Instead, add a flag called SPECIAL stored in the top bit of the integer.

Adding Unicode support is very simple now; just change u_char map[] to
u_int map[] in keyent_t, change the bounds checking in kbdcontrol to
0x1FFFFF and modify the ioctls to allow loading these new keymaps.
2009-08-24 09:17:01 +00:00
Ruslan Ermilov 5a66b66324 Replace magic numbers for console bell types with defines. 2006-11-16 12:27:51 +00:00
Maksim Yevmenkin eb65c05e44 Make op parameter to mux_keyboard() u_int instead of int.
This should fix sparc64 messages like

Sep 15 11:17:39 peahi kernel: WARNING pid 5477 (kbdcontrol): ioctl sign-extension ioctl ffffffff80244b45

PR:		sparc64/96798
MFC after:	1 week
2006-09-15 18:41:12 +00:00
Maksim Yevmenkin 4673ea01e3 kbdmux(4) keyboard multiplexer integration
o Slightly change KBADDKBD and KBRELKBD ioctl() interface. Instead of passing
  keyboard index pass keyboard_info_t structure with populated 'kb_unit' and
  'kb_name' fields. Keyboard index is not very user-friendly and is not very
  easy to obtain. Keyboard driver name and unit, on the other hand, is much
  more user friendly and known almost all the time;

o Move definition of keyboard_info_t structure up;

o Teach kbdcontrol(1) how to attach/detach keyboards to/from the keyboard
  multiplexor;

o Update kbdcontrol(1) man page and document new functionality.

To attach/detach keyboard to/from keyboard multiplexor one needs to use
keyboard device name (i.e. ukbd0).

MFC after:	1 week
2005-07-14 22:43:20 +00:00
John-Mark Gurney 37a0f3914b fix bug which prevented programming function keys that were exactly 16
characters long..  strcpy was coping over the length...

PR:		52960
Submitted by:	Dmitry Sivachenko
MFC after:	1 week
2004-08-09 04:27:58 +00:00
David E. O'Brien b728350ee6 Use __FBSDID over rcsid[]. Protect copyright[] where needed. 2003-05-03 21:06:42 +00:00
Alfred Perlstein 4f5d913371 WARNS?=4 cleanup. 2002-07-11 21:12:18 +00:00
Alfred Perlstein b6528e647b de-__P() 2002-07-11 20:53:56 +00:00
Jens Schweikhardt 21dc7d4f57 Fix typo in the BSD copyright: s/withough/without/
Spotted and suggested by:	des
MFC after:	3 weeks
2002-06-02 20:05:59 +00:00
Ruslan Ermilov 2619d7c271 FreeBSD 4.1 bootstrapping aid (HALT and PDWN are not defined there). 2002-02-08 09:37:12 +00:00
David E. O'Brien bdcfaae4cc Repeat after me: "when reporting `file not found', perform a little bit of
useful HCI consideration and tell which file was being looked for".
2001-07-13 16:30:11 +00:00
Maxim Sobolev 13edc2540c - Syncronizes command line syntax warnings with manpage (bin/27010);
- silence gcc(1) warnings (sobomax).

PR:		27010
Submitted by:	Alex Kapranoff <alex@kapran.bitmcnit.bryansk.su>, sobomax
MFC after:	10 days
2001-05-29 13:59:02 +00:00
Dag-Erling Smørgrav 031c57af94 Move the scrollback controls from kbdcontrol to vidcontrol.
Also fix some style bugs in the code and poor language in the man pages.

Reviewed by:	sobomax
2001-05-28 11:05:28 +00:00
Dima Dorfman 50eb7c28e9 Instead of defining CONS_CLRHIST if it isn't defined, simply disable
the -c option [when CONS_CLRHIST isn't defined].  This is okay since
the only time CONS_CLRHIST wouldn't be defined is when kbdcontrol is
being built in bootstrap-tools, and -c isn't needed then.

Submitted by:	imp
2001-05-27 06:28:08 +00:00
Dima Dorfman 68c805eb99 A la rev. 1.36, define CONS_CLRHIST here if it isn't already since
this is a build tool, so it has to build on 4.x with the old headers.
2001-05-27 04:03:52 +00:00
Dima Dorfman 84d337151e Add a -c option which clears the history buffer using the new
CONS_CLRHIST ioctl.

PR:		27616
Reviewed by:	ru
2001-05-27 00:47:38 +00:00
Warner Losh f83a28e05b If PASTE isn't defined, define it as a transitional measure. This
allows me to complete make buildworld on my stable machine.

Also change termination case to be clearer what is going on while
searching for map files.
2001-05-15 22:53:05 +00:00
Maxim Sobolev 8e21e585dc Fix a possible segfault introduced in my previous commit. 2001-05-14 06:15:07 +00:00
Maxim Sobolev b010fac286 Allow path where keyboard maps are looked for to be altered using environment
variable.
2001-05-12 09:16:09 +00:00
Andrey A. Chernov 4629b5e0fb Implement keyboard paste
PR:		25499
Submitted by:	Gaspar Chilingarov <nm@web.am>
2001-03-11 22:51:05 +00:00
Poul-Henning Kamp 00d25f512c Initiate deorbit burn sequence for <machine/console.h>.
Replace all in-tree uses with necessary subset of <sys/{fb,kb,cons}io.h>.
This is also the appropriate fix for exo-tree sources.

Put warnings in <machine/console.h> to discourage use.
November 15th 2000 the warnings will be converted to errors.
January 15th 2001 the <machine/console.h> files will be removed.
2000-10-08 21:34:00 +00:00
David Malone 1c06ce6197 Add the ability to define a "shutdown" and "shutdown and poweroff" key
to syscons. I have a man page to follow describing the format of the
kbdmap file.

PR:		19273
Reviewed by:	sheldonh
2000-09-11 20:37:42 +00:00
Kazutaka YOKOTA 52990a39d0 Define some more function keys in the keymap: panic, lshifta, rshifta, etc. 1999-12-10 04:24:27 +00:00
Peter Wemm e46b89dc93 Fix warning: return type of main' is not int' 1999-09-15 01:58:44 +00:00
Peter Wemm 97d92980a9 $Id$ -> $FreeBSD$ 1999-08-28 01:35:59 +00:00
Kazutaka YOKOTA 39c33d76ab - Add new argument off' to the -b' option. This will turn off
the bell.
- Document it in the man page.
- Fix a couple of typo in the man page.

Submitted by: cpiazza
1999-07-22 14:19:14 +00:00
Kazutaka YOKOTA ac80d4b498 Reflect recent changes in syscons. 1999-06-22 14:15:46 +00:00
Kazutaka YOKOTA f64191e962 Added backward compatibility to set key repeat rate.
Requested by: bde
1999-05-09 04:57:51 +00:00
Gary Palmer 27e62f6737 Fix builds for the AXP
Submitted by:	Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
1999-03-17 11:42:18 +00:00