svn commit: r197247 - head/sys/sys

Ed Schouten ed at FreeBSD.org
Wed Sep 16 07:01:12 UTC 2009


Author: ed
Date: Wed Sep 16 07:01:11 2009
New Revision: 197247
URL: http://svn.freebsd.org/changeset/base/197247

Log:
  Extend the keyboard character size to 24 bits.
  
  Because we use an int to store keyboard chacacters and their flags, we
  can easily store the flags in the top byte instead of the second byte.
  This means it's a lot easier to make Unicode work.
  
  The only change that still needs to be made, is that keyent_t's map is
  extended to u_int.
  
  Obtained from:	//depot/projects/newcons/sys/sys/kbio.h

Modified:
  head/sys/sys/kbio.h

Modified: head/sys/sys/kbio.h
==============================================================================
--- head/sys/sys/kbio.h	Wed Sep 16 06:32:23 2009	(r197246)
+++ head/sys/sys/kbio.h	Wed Sep 16 07:01:11 2009	(r197247)
@@ -229,16 +229,22 @@ typedef struct fkeyarg	fkeyarg_t;
 
 /* flags set to the return value in the KD_XLATE mode */
 
-#define NOKEY		0x100		/* no key pressed marker 	*/
-#define FKEY		0x200		/* function key marker 		*/
-#define MKEY		0x400		/* meta key marker (prepend ESC)*/
-#define BKEY		0x800		/* backtab (ESC [ Z)		*/
+#define	NOKEY		0x01000000	/* no key pressed marker 	*/
+#define	FKEY		0x02000000	/* function key marker 		*/
+#define	MKEY		0x04000000	/* meta key marker (prepend ESC)*/
+#define	BKEY		0x08000000	/* backtab (ESC [ Z)		*/
 
-#define SPCLKEY		0x8000		/* special key			*/
-#define RELKEY		0x4000		/* key released			*/
-#define ERRKEY		0x2000		/* error			*/
+#define	SPCLKEY		0x80000000	/* special key			*/
+#define	RELKEY		0x40000000	/* key released			*/
+#define	ERRKEY		0x20000000	/* error			*/
 
-#define KEYCHAR(c)	((c) & 0x00ff)
-#define KEYFLAGS(c)	((c) & ~0x00ff)
+/*
+ * The top byte is used to store the flags.  This means there are 24
+ * bits left to store the actual character.  Because UTF-8 can encode
+ * 2^21 different characters, this is good enough to get Unicode
+ * working.
+ */
+#define KEYCHAR(c)	((c) & 0x00ffffff)
+#define KEYFLAGS(c)	((c) & ~0x00ffffff)
 
 #endif /* !_SYS_KBIO_H_ */


More information about the svn-src-all mailing list