Modify it to adjust Tizen IVI enviroment
[platform/upstream/kmscon.git] / src / uterm_input.h
index 0798ff3..1d5d1f0 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * uterm - Linux User-Space Terminal
+ * uterm - Linux User-Space Terminal Input Handling
  *
- * Copyright (c) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
+ * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@googlemail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-/* Internal definitions */
+/*
+ * Input Devices
+ * This input object can combine multiple linux input devices into a single
+ * device and notifies the application about events. It has several different
+ * keyboard backends so the full XKB feature set is available.
+ */
 
-#ifndef UTERM_INPUT_H
-#define UTERM_INPUT_H
+#ifndef UTERM_UTERM_INPUT_H
+#define UTERM_UTERM_INPUT_H
 
+#include <eloop.h>
 #include <inttypes.h>
-#include <limits.h>
 #include <stdbool.h>
 #include <stdlib.h>
-#include <xkbcommon/xkbcommon-keysyms.h>
-#include "eloop.h"
-#include "shl_dlist.h"
-#include "uterm.h"
-
-struct uterm_input_dev {
-       struct shl_dlist list;
-       struct uterm_input *input;
-
-       unsigned int features;
-       int rfd;
-       char *node;
-       struct ev_fd *fd;
-       struct xkb_state *state;
-
-       struct uterm_input_event event;
-       unsigned int num_syms;
+
+struct uterm_input;
+
+typedef void (*uterm_input_log_t) (void *data,
+                                  const char *file,
+                                  int line,
+                                  const char *func,
+                                  const char *subs,
+                                  unsigned int sev,
+                                  const char *format,
+                                  va_list args);
+
+/* keep in sync with shl_xkb_mods */
+enum uterm_input_modifier {
+       UTERM_SHIFT_MASK        = (1 << 0),
+       UTERM_LOCK_MASK         = (1 << 1),
+       UTERM_CONTROL_MASK      = (1 << 2),
+       UTERM_ALT_MASK          = (1 << 3),
+       UTERM_LOGO_MASK         = (1 << 4),
 };
 
-struct uterm_input {
-       unsigned long ref;
-       struct ev_eloop *eloop;
-       int awake;
+/* keep in sync with TSM_VTE_INVALID */
+#define UTERM_INPUT_INVALID 0xffffffff
 
-       struct shl_hook *hook;
-       struct xkb_context *ctx;
-       struct xkb_keymap *keymap;
+struct uterm_input_event {
+       bool handled;           /* user-controlled, default is false */
+       uint16_t keycode;       /* linux keycode - KEY_* - linux/input.h */
+       uint32_t ascii;         /* ascii keysym for @keycode */
+       unsigned int mods;      /* active modifiers - uterm_modifier mask */
 
-       struct shl_dlist devices;
+       unsigned int num_syms;  /* number of keysyms */
+       uint32_t *keysyms;      /* XKB-common keysym-array - XKB_KEY_* */
+       uint32_t *codepoints;   /* ucs4 unicode value or UTERM_INPUT_INVALID */
 };
 
-static inline bool input_bit_is_set(const unsigned long *array, int bit)
-{
-       return !!(array[bit / LONG_BIT] & (1LL << (bit % LONG_BIT)));
-}
-
-int uxkb_desc_init(struct uterm_input *input,
-                  const char *layout,
-                  const char *variant,
-                  const char *options);
-void uxkb_desc_destroy(struct uterm_input *input);
-
-int uxkb_dev_init(struct uterm_input_dev *dev);
-void uxkb_dev_destroy(struct uterm_input_dev *dev);
-int uxkb_dev_process(struct uterm_input_dev *dev,
-                    uint16_t key_state,
-                    uint16_t code);
-void uxkb_dev_reset(struct uterm_input_dev *dev, const unsigned long *ledbits);
-
-#endif /* UTERM_INPUT_H */
+#define UTERM_INPUT_HAS_MODS(_ev, _mods) (((_ev)->mods & (_mods)) == (_mods))
+
+typedef void (*uterm_input_cb) (struct uterm_input *input,
+                               struct uterm_input_event *ev,
+                               void *data);
+
+int uterm_input_new(struct uterm_input **out, struct ev_eloop *eloop,
+                   const char *model, const char *layout, const char *variant,
+                   const char *options, const char *keymap,
+                   unsigned int repeat_delay, unsigned int repeat_rate,
+                   uterm_input_log_t log, void *log_data);
+void uterm_input_ref(struct uterm_input *input);
+void uterm_input_unref(struct uterm_input *input);
+
+void uterm_input_add_dev(struct uterm_input *input, const char *node);
+void uterm_input_remove_dev(struct uterm_input *input, const char *node);
+
+int uterm_input_register_cb(struct uterm_input *input, uterm_input_cb cb,
+                           void *data);
+void uterm_input_unregister_cb(struct uterm_input *input, uterm_input_cb cb,
+                              void *data);
+
+void uterm_input_sleep(struct uterm_input *input);
+void uterm_input_wake_up(struct uterm_input *input);
+bool uterm_input_is_awake(struct uterm_input *input);
+
+#endif /* UTERM_UTERM_INPUT_H */