From: Dinar valeev <k0da@opensuse.org>
To: linuxppc-dev@lists.ozlabs.org
Cc: Dinar Valeev <dvaleev@suse.com>
Subject: [PATCH] Caps in not always shift
Date: Fri, 29 May 2015 11:58:23 +0200 [thread overview]
Message-ID: <1432893503-19197-1-git-send-email-k0da@opensuse.org> (raw)
From: Dinar Valeev <dvaleev@suse.com>
Caps behaves like shift only for latin characters.
In case we're typing - for example with caps enabled, SLOF picks _ char
from shifted table.
Threat caps as shift only for letters.
Signed-off-by: Dinar Valeev <dvaleev@suse.com>
---
lib/libusb/usb-hid.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/lib/libusb/usb-hid.c b/lib/libusb/usb-hid.c
index f0cab8a..9e14cf5 100644
--- a/lib/libusb/usb-hid.c
+++ b/lib/libusb/usb-hid.c
@@ -83,6 +83,8 @@ uint8_t set_leds;
const uint8_t *key_std = NULL;
const uint8_t *key_std_shift = NULL;
+uint8_t ctrl; /* modifiers */
+
/**
* read character from Keyboard-Buffer
*
@@ -120,22 +122,27 @@ static void write_key(uint8_t key)
static void get_char(uint8_t ctrl, uint8_t keypos)
{
uint8_t ch;
+ int caps = 0;
+//key position for latin letters
+#define KEYP_LATIN_A 4
+#define KEYP_LATIN_Z 29
#ifdef KEY_DEBUG
printf("pos %02X\n", keypos);
#endif
if (set_leds & LED_CAPS_LOCK) /* is CAPS Lock set ? */
- ctrl |= MODIFIER_SHIFT; /* simulate shift */
+ caps = 1;
- if (ctrl == 0) {
+ /* caps is a shift only for latin chars */
+ if ((caps == 0 && ctrl == 0) || (caps == 1 && (keypos < KEYP_LATIN_A || keypos > KEYP_LATIN_Z))) {
ch = key_std[keypos];
if (ch != 0)
write_key(ch);
return;
}
- if (ctrl & MODIFIER_SHIFT) {
+ if ((ctrl & MODIFIER_SHIFT) || caps == 1) {
ch = key_std_shift[keypos];
if (ch != 0)
write_key(ch);
@@ -187,6 +194,12 @@ static void check_key_code(uint8_t *buf)
set_leds ^= LED_CAPS_LOCK;
break;
+ case 0x36: /*Shift pressed*/
+ ctrl |= MODIFIER_SHIFT;
+ break;
+ case 0xb6: /*Shift unpressed*/
+ ctrl &= ~MODIFIER_SHIFT;
+ break;
case 0x3a: /* F1 */
write_key(0x1b);
write_key(0x5b);
--
2.1.4
next reply other threads:[~2015-05-29 9:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 9:58 Dinar valeev [this message]
2015-07-06 5:57 ` [PATCH] Caps in not always shift Nikunj A Dadhania
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432893503-19197-1-git-send-email-k0da@opensuse.org \
--to=k0da@opensuse.org \
--cc=dvaleev@suse.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).