aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2015-03-13 14:46:15 +0100
committerAlex Auvolat <alex@adnab.me>2015-03-13 14:59:44 +0100
commitd0dc9f38184956af49379d7e2585756523cfa4c1 (patch)
tree0c3014986187038b16141c2ef58dfb4799ec74ff
parent243e6d72928d1fc4cf20366eab9007980b945458 (diff)
downloadkogata-d0dc9f38184956af49379d7e2585756523cfa4c1.tar.gz
kogata-d0dc9f38184956af49379d7e2585756523cfa4c1.zip
Fix keyboard handling.
-rw-r--r--res/keymaps/fr.c12
-rw-r--r--src/lib/include/keyboard.h1
-rw-r--r--src/lib/include/proto/keymap_file.h1
-rw-r--r--src/lib/libkogata/keyboard.c15
4 files changed, 23 insertions, 6 deletions
diff --git a/res/keymaps/fr.c b/res/keymaps/fr.c
index f039142..04f086e 100644
--- a/res/keymaps/fr.c
+++ b/res/keymaps/fr.c
@@ -25,10 +25,20 @@ keymap_t fr_keymap = {
},
{ // caps
/* 0x00 */ 0, 0, '&', L'É', '"', '\'', '(', '-', L'È', '_', L'Ç', L'À', ')', '=', 0, 0,
- /* 0x10 */ 'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', L'¨', '$', 0, 0, 'Q', 'S',
+ /* 0x10 */ 'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '^', '$', 0, 0, 'Q', 'S',
/* 0x20 */ 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', L'Ù', L'²', 0, '*', 'W', 'X', 'C', 'V',
/* 0x30 */ 'B', 'N', ',', ';', ':', '!', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0,
/* 0x40 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0,
+ /* 0x50 */ 0, 0, 0, 0, 0, 0, '<', 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0x60 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 0x70 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ },
+ { // shift caps
+ /* 0x00 */ 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', L'°', '+', 0, 0,
+ /* 0x10 */ 'a', 'z', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', L'¨', L'£', 0, 0, 'q', 's',
+ /* 0x20 */ 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', '%', L'³', 0, L'µ', 'w', 'x', 'c', 'v',
+ /* 0x30 */ 'b', 'n', '?', '.', '/', L'§', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0,
+ /* 0x40 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0,
/* 0x50 */ 0, 0, 0, 0, 0, 0, '>', 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x60 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x70 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
diff --git a/src/lib/include/keyboard.h b/src/lib/include/keyboard.h
index 0d5a97a..63c6c2c 100644
--- a/src/lib/include/keyboard.h
+++ b/src/lib/include/keyboard.h
@@ -22,6 +22,7 @@ typedef struct {
typedef struct {
keymap_t km;
+ int key_char[256];
uint32_t status; // mask of alt/ctrl/super
} keyboard_t;
diff --git a/src/lib/include/proto/keymap_file.h b/src/lib/include/proto/keymap_file.h
index 53ffeb7..281b147 100644
--- a/src/lib/include/proto/keymap_file.h
+++ b/src/lib/include/proto/keymap_file.h
@@ -8,6 +8,7 @@ typedef struct {
int normal[128];
int shift[128];
int caps[128];
+ int shiftcaps[128];
int mod[128];
int shiftmod[128];
bool ralt_is_mod; // true: right alt = alt-gr
diff --git a/src/lib/libkogata/keyboard.c b/src/lib/libkogata/keyboard.c
index 7e3c376..505c048 100644
--- a/src/lib/libkogata/keyboard.c
+++ b/src/lib/libkogata/keyboard.c
@@ -85,7 +85,7 @@ int key_chr(keyboard_t *kb, int k) {
return kb->km.mod[k];
}
} else if ((kb->status & KBD_CAPS) && (kb->status & KBD_SHIFT)) {
- return kb->km.normal[k];
+ return kb->km.shiftcaps[k];
} else if (kb->status & KBD_SHIFT) {
return kb->km.shift[k];
} else if (kb->status & KBD_CAPS) {
@@ -95,7 +95,7 @@ int key_chr(keyboard_t *kb, int k) {
}
}
-key_t make_key(keyboard_t *kb, int k) {
+key_t make_key(keyboard_t *kb, int k, bool down) {
key_t x;
x.flags = kb->status;
@@ -106,7 +106,12 @@ key_t make_key(keyboard_t *kb, int k) {
if (x.key != 0) return x;
x.flags |= KBD_CHAR;
- x.chr = key_chr(kb, k);
+ if (down) {
+ x.chr = key_chr(kb, k);
+ kb->key_char[k] = x.chr;
+ } else {
+ x.chr = kb->key_char[k];
+ }
return x;
}
@@ -126,7 +131,7 @@ key_t keyboard_press(keyboard_t *kb, int k) {
kb->status ^= KBD_CAPS;
}
- return make_key(kb, k);
+ return make_key(kb, k, true);
}
key_t keyboard_release(keyboard_t *kb, int k) {
@@ -142,7 +147,7 @@ key_t keyboard_release(keyboard_t *kb, int k) {
kb->status &= ~KBD_MOD;
}
- return make_key(kb, k);
+ return make_key(kb, k, false);
}
/* vim: set ts=4 sw=4 tw=0 noet :*/