summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJengHyun Kang <jhyuni.kang@samsung.com>2016-04-25 18:17:10 +0900
committerSung-Jin Park <sj76.park@samsung.com>2016-04-25 02:49:47 -0700
commit9b0b64d2a8638948942771c008bc9885040fc883 (patch)
tree99c93cbd391b8c5f8a1cd895d539fd51154b3edd
parent3244f0cd6b0db658150fa5057c8ad5f5b37d7f57 (diff)
downloadxkeyboard-config-9b0b64d2a8638948942771c008bc9885040fc883.tar.gz
xkeyboard-config-9b0b64d2a8638948942771c008bc9885040fc883.tar.bz2
xkeyboard-config-9b0b64d2a8638948942771c008bc9885040fc883.zip
-rw-r--r--cache/cache.c52
1 files changed, 44 insertions, 8 deletions
diff --git a/cache/cache.c b/cache/cache.c
index 03e7a2ae..f5a4b125 100644
--- a/cache/cache.c
+++ b/cache/cache.c
@@ -2,20 +2,53 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#define DFLT_RULES "evdev"
#define DFLT_MODEL "pc105"
#define DFLT_LAYOUT "us"
+#define KEYMAP_LAYOUT "/usr/share/X11/xkb/tizen_key_layout.txt"
+
#define STRLEN(s) (s ? strlen(s) : 0)
#define STR(s) (s ? s : "")
+void parseKeymapFile(struct xkb_keymap *map)
+{
+ FILE *file;
+ int res, keycode;
+ char *tmp, *ret, buf[1024] = {0, };
+ file = fopen(KEYMAP_LAYOUT, "r");
+ if (!file) return;
+
+ while (!feof(file))
+ {
+ ret = fgets(buf, 1024, file);
+
+ if (!ret) continue;
+
+ if ((strstr(buf, "keyboard") > 0) && (strstr(buf, "repeat") > 0))
+ {
+ tmp = strtok(buf, " ");
+ tmp = strtok(NULL, " ");
+ if (!tmp) continue;
+ keycode = atoi(tmp) + 8;
+
+ res = xkb_keymap_key_set_repeats(map, keycode, 0);
+ printf("Set key(%d) to disable repeat: %d\n", keycode, res);
+ }
+ }
+
+ fclose(file);
+
+ return;
+}
+
void parseArgs(int argc, char **argv, struct xkb_rule_names *names)
{
- int i;
+ int i, res;
char *tmp, *rule_path;
FILE *file;
- int len_rule_path;
char buf[1024] = {0, };
if (argc < 2)
@@ -35,7 +68,8 @@ void parseArgs(int argc, char **argv, struct xkb_rule_names *names)
while (!feof(file))
{
- fscanf(file, "%s", buf);
+ res = fscanf(file, "%s", buf);
+ if (res < 0) break;
if (strstr(buf, "rules") > 0)
{
tmp = strtok(buf, "=");
@@ -175,6 +209,8 @@ int main(int argc, char **argv)
map = xkb_map_new_from_names(ctx, &names, 0);
+ parseKeymapFile(map);
+
keymap_string = xkb_map_get_as_string(map);
if (!keymap_string) {
@@ -199,11 +235,11 @@ int main(int argc, char **argv)
fclose(file);
}
- if (names.rules) free(names.rules);
- if (names.model) free(names.model);
- if (names.layout) free(names.layout);
- if (names.variant) free(names.variant);
- if (names.options) free(names.options);
+ if (names.rules) free((char *)names.rules);
+ if (names.model) free((char *)names.model);
+ if (names.layout) free((char *)names.layout);
+ if (names.variant) free((char *)names.variant);
+ if (names.options) free((char *)names.options);
if (cache_path) free(cache_path);
xkb_keymap_unref(map);
xkb_context_unref(ctx);