Fixed buggy and broken KBKEY_ENCODE and KBKEY_DECODE macros.
This commit is contained in:
parent
5fde8e13ed
commit
133fb9871c
|
@ -143,19 +143,26 @@
|
||||||
|
|
||||||
#define KBKEY_ENCODE(_kbkey) \
|
#define KBKEY_ENCODE(_kbkey) \
|
||||||
({ \
|
({ \
|
||||||
int kbkey = (_kbkey); \
|
int __kbkey = (_kbkey); \
|
||||||
uint32_t codepoint = (1U<<30U) | ((unsigned) kbkey); \
|
uint32_t __codepoint = (1U<<30U) | ((unsigned) __kbkey); \
|
||||||
codepoint &= ~(1U<<31U); \
|
__codepoint &= ~(1U<<31U); \
|
||||||
codepoint; \
|
__codepoint; \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define KBKEY_DECODE(_codepoint) \
|
#define KBKEY_DECODE(_codepoint) \
|
||||||
({ \
|
({ \
|
||||||
uint32_t codepoint = (_codepoint); \
|
struct { union { int __kbkey; uint32_t __codepoint; }; } __u; \
|
||||||
if ( !(codepoint & (1U<<30U)) ) { codepoint = 0U; } \
|
__u.__codepoint = (_codepoint); \
|
||||||
if ( codepoint & (1U<<29U) ) { codepoint |= (1U<<31U); } \
|
if ( __u.__codepoint & (1U<<30U) ) \
|
||||||
int kbkey = (int) codepoint; \
|
{ \
|
||||||
kbkey; \
|
if ( __u.__codepoint & (1U<<29U) ) { __u.__codepoint |= (1U<<31U); } \
|
||||||
|
else { __u.__codepoint &= ~(1U<<30U); } \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
__u.__codepoint = 0U; \
|
||||||
|
} \
|
||||||
|
__u.__kbkey; \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue