input: shuffle headers and includes

Just some renames/moving/prefixing to conform to the style of the
other files.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
Ran Benita 2011-12-30 18:46:20 +02:00 committed by David Herrmann
parent 553dfddc27
commit c3912b23a2
8 changed files with 82 additions and 61 deletions

View File

@ -28,7 +28,7 @@ libkmscon_core_la_SOURCES = \
src/eloop.c src/eloop.h \
src/vt.c src/vt.h \
src/input.c src/input.h \
src/input-xkb.c src/input-private.h \
src/input_xkb.c src/input_xkb.h \
external/imKStoUCS.c external\imKStoUCS.h \
src/vte.c src/vte.h \
src/terminal.c src/terminal.h

View File

@ -62,7 +62,7 @@
* - Changed the return type to uint32_t to match libxkbcommon.
*/
#include <X11/extensions/XKBcommon.h>
#include "imKStoUCS.h"
static unsigned short const keysym_to_unicode_1a1_1ff[] = {
0x0104, 0x02d8, 0x0141, 0x0000, 0x013d, 0x015a, 0x0000, /* 0x01a0-0x01a7 */

View File

@ -62,6 +62,11 @@
* - Changed the return type to uint32_t to match libxkbcommon.
*/
#include <stdint.h>
#ifndef KMSCON_IMKSTOUCS_H
#define KMSCON_IMKSTOUCS_H
#include <inttypes.h>
uint32_t KeysymToUcs4(uint32_t keysym);
#endif

View File

@ -50,7 +50,7 @@
#include "eloop.h"
#include "input.h"
#include "input-private.h"
#include "input_xkb.h"
#include "log.h"
enum input_state {
@ -99,8 +99,8 @@ static void notify_key(struct kmscon_input_device *device,
return;
input = device->input;
has_event = process_evdev_key(input->xkb_desc, &device->xkb_state,
value, code, &ev);
has_event = kmscon_xkb_process_evdev_key(input->xkb_desc,
&device->xkb_state, value, code, &ev);
if (has_event)
input->cb(input, &ev, input->data);
@ -156,7 +156,7 @@ int kmscon_input_device_wake_up(struct kmscon_input_device *device)
}
/* this rediscovers the xkb state if sth changed during sleep */
reset_xkb_state(device->input->xkb_desc, &device->xkb_state,
kmscon_xkb_reset_state(device->input->xkb_desc, &device->xkb_state,
device->rfd);
ret = kmscon_eloop_new_fd(device->input->eloop, &device->fd,
@ -259,7 +259,7 @@ int kmscon_input_new(struct kmscon_input **out)
input->ref = 1;
input->state = INPUT_ASLEEP;
ret = new_xkb_desc(layout, variant, options, &input->xkb_desc);
ret = kmscon_xkb_new_desc(layout, variant, options, &input->xkb_desc);
if (ret) {
log_warning("input: cannot create xkb description\n");
goto err_free;
@ -302,7 +302,7 @@ err_monitor:
err_udev:
udev_unref(input->udev);
err_xkb:
free_xkb_desc(input->xkb_desc);
kmscon_xkb_free_desc(input->xkb_desc);
err_free:
free(input);
return ret;
@ -327,7 +327,7 @@ void kmscon_input_unref(struct kmscon_input *input)
kmscon_input_disconnect_eloop(input);
udev_monitor_unref(input->monitor);
udev_unref(input->udev);
free_xkb_desc(input->xkb_desc);
kmscon_xkb_free_desc(input->xkb_desc);
free(input);
log_debug("input: destroying input object\n");
}

View File

@ -50,8 +50,6 @@
#include <inttypes.h>
#include <stdbool.h>
#include <X11/extensions/XKBcommon.h>
#include <X11/keysym.h>
#include "eloop.h"
struct kmscon_input;
@ -66,6 +64,17 @@ struct kmscon_input_event {
typedef void (*kmscon_input_cb) (struct kmscon_input *input,
struct kmscon_input_event *ev, void *data);
/*
* These are the values sent by the kernel in the /value/ field of the
* /input_event/ struct.
* See Documentation/input/event-codes.txt in the kernel tree.
*/
enum kmscon_key_state {
KMSCON_KEY_RELEASED = 0,
KMSCON_KEY_PRESSED = 1,
KMSCON_KEY_REPEATED = 2,
};
int kmscon_input_new(struct kmscon_input **out);
void kmscon_input_ref(struct kmscon_input *input);
void kmscon_input_unref(struct kmscon_input *input);

View File

@ -58,12 +58,14 @@
* /usr/include/X11/keysymdef.h
*/
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
#include <sys/ioctl.h>
#include <linux/input.h>
#include "input-private.h"
#include "input_xkb.h"
#include "log.h"
#include "imKStoUCS.h"
@ -87,13 +89,13 @@ static uint8_t virtual_to_real_mods(struct xkb_desc *desc, uint16_t vmods);
static void init_action(struct xkb_desc *desc, union xkb_action *action);
static bool process_action(struct xkb_desc *desc, struct xkb_state *state,
KeyCode keycode, enum key_state key_state,
union xkb_action *action);
KeyCode keycode, enum kmscon_key_state key_state,
union xkb_action *action);
static bool process_mod_action(struct xkb_desc *desc, struct xkb_state *state,
KeyCode keycode, enum key_state key_state,
KeyCode keycode, enum kmscon_key_state key_state,
struct xkb_mod_action *action);
static bool process_group_action(struct xkb_desc *desc, struct xkb_state *state,
KeyCode keycode, enum key_state key_state,
KeyCode keycode, enum kmscon_key_state key_state,
struct xkb_group_action *action);
static bool should_key_repeat(struct xkb_desc *desc, KeyCode keycode);
@ -111,7 +113,8 @@ static struct xkb_indicator_map *find_indicator_map(struct xkb_desc *desc,
* Create a ready-to-use xkb description object. This is used in most places
* having to do with XKB.
*/
int new_xkb_desc(const char *layout, const char *variant, const char *options,
int kmscon_xkb_new_desc(const char *layout, const char *variant,
const char *options,
struct xkb_desc **out)
{
struct xkb_desc *desc;
@ -139,7 +142,7 @@ int new_xkb_desc(const char *layout, const char *variant, const char *options,
return 0;
}
void free_xkb_desc(struct xkb_desc *desc)
void kmscon_xkb_free_desc(struct xkb_desc *desc)
{
if (!desc)
return;
@ -544,7 +547,7 @@ static uint8_t virtual_and_real_to_mask(struct xkb_desc *desc,
* We don't reset the locked group, this should survive a VT switch, etc. The
* locked modifiers are reset according to the keyboard LEDs.
*/
void reset_xkb_state(struct xkb_desc *desc, struct xkb_state *state,
void kmscon_xkb_reset_state(struct xkb_desc *desc, struct xkb_state *state,
int evdev_fd)
{
int i;
@ -657,9 +660,11 @@ static uint16_t find_shift_level(struct xkb_desc *desc, KeyCode keycode,
* (e.g. a key release). The return value indicated whether the input_event
* was filled out or not.
*/
bool process_evdev_key(struct xkb_desc *desc, struct xkb_state *state,
enum key_state key_state, uint16_t code,
struct kmscon_input_event *out)
bool kmscon_xkb_process_evdev_key(struct xkb_desc *desc,
struct xkb_state *state,
enum kmscon_key_state key_state,
uint16_t code,
struct kmscon_input_event *out)
{
KeyCode keycode;
uint8_t group;
@ -677,7 +682,7 @@ bool process_evdev_key(struct xkb_desc *desc, struct xkb_state *state,
if (XkbKeyNumSyms(desc, keycode) == 0)
return false;
/* Unwanted repeat. */
if (key_state == KEY_STATE_REPEATED &&
if (key_state == KMSCON_KEY_REPEATED &&
!should_key_repeat(desc, keycode))
return false;
@ -686,19 +691,19 @@ bool process_evdev_key(struct xkb_desc *desc, struct xkb_state *state,
sym = XkbKeySymEntry(desc, keycode, shift_level, group);
state_changed = false;
if (key_state != KEY_STATE_REPEATED) {
if (key_state != KMSCON_KEY_REPEATED) {
action = XkbKeyActionEntry(desc, keycode, shift_level, group);
state_changed = process_action(desc, state, keycode,
key_state, action);
}
event_filled = false;
if (key_state != KEY_STATE_RELEASED) {
if (key_state != KMSCON_KEY_RELEASED) {
out->keycode = code;
out->keysym = sym;
out->modifiers = state->mods;
out->unicode = KeysymToUcs4(sym);
event_filled = true;
}
@ -718,7 +723,7 @@ bool process_evdev_key(struct xkb_desc *desc, struct xkb_state *state,
* was changed.
*/
static bool process_action(struct xkb_desc *desc, struct xkb_state *state,
KeyCode keycode, enum key_state key_state,
KeyCode keycode, enum kmscon_key_state key_state,
union xkb_action *action)
{
if (!action)
@ -756,7 +761,7 @@ static bool process_action(struct xkb_desc *desc, struct xkb_state *state,
* See [Lib] Table 17.1 for logic.
* */
static bool process_mod_action(struct xkb_desc *desc, struct xkb_state *state,
KeyCode keycode, enum key_state key_state,
KeyCode keycode, enum kmscon_key_state key_state,
struct xkb_mod_action *action)
{
uint8_t mods;
@ -775,9 +780,9 @@ static bool process_mod_action(struct xkb_desc *desc, struct xkb_state *state,
switch (action->type) {
case XkbSA_SetMods:
if (key_state == KEY_STATE_PRESSED) {
if (key_state == KMSCON_KEY_PRESSED) {
state->base_mods |= mods;
} else if (key_state == KEY_STATE_RELEASED) {
} else if (key_state == KMSCON_KEY_RELEASED) {
state->base_mods &= ~mods;
if (flags & XkbSA_ClearLocks)
state->locked_mods &= ~mods;
@ -785,9 +790,9 @@ static bool process_mod_action(struct xkb_desc *desc, struct xkb_state *state,
break;
case XkbSA_LatchMods:
if (key_state == KEY_STATE_PRESSED) {
if (key_state == KMSCON_KEY_PRESSED) {
state->base_mods |= mods;
} else if (key_state == KEY_STATE_RELEASED) {
} else if (key_state == KMSCON_KEY_RELEASED) {
if (flags & XkbSA_ClearLocks) {
saved_mods = state->locked_mods;
state->locked_mods &= ~mods;
@ -806,10 +811,10 @@ static bool process_mod_action(struct xkb_desc *desc, struct xkb_state *state,
break;
case XkbSA_LockMods:
/* We fake a little here and toggle both on and off on keypress. */
if (key_state == KEY_STATE_PRESSED) {
if (key_state == KMSCON_KEY_PRESSED) {
state->base_mods |= mods;
state->locked_mods ^= mods;
} else if (key_state == KEY_STATE_RELEASED) {
} else if (key_state == KMSCON_KEY_RELEASED) {
state->base_mods &= ~mods;
}
@ -825,7 +830,7 @@ static bool process_mod_action(struct xkb_desc *desc, struct xkb_state *state,
* See [Lib] Table 17.4 for logic.
*/
static bool process_group_action(struct xkb_desc *desc, struct xkb_state *state,
KeyCode keycode, enum key_state key_state,
KeyCode keycode, enum kmscon_key_state key_state,
struct xkb_group_action *action)
{
int16_t group = action->group;
@ -848,24 +853,24 @@ static bool process_group_action(struct xkb_desc *desc, struct xkb_state *state,
switch (action->type) {
case XkbSA_SetGroup:
if (key_state == KEY_STATE_PRESSED) {
if (key_state == KMSCON_KEY_PRESSED) {
if (flags & XkbSA_GroupAbsolute)
base_group = group;
else
base_group += group;
} else if (key_state == KEY_STATE_RELEASED) {
} else if (key_state == KMSCON_KEY_RELEASED) {
if (flags & XkbSA_ClearLocks)
locked_group = 0;
}
break;
case XkbSA_LatchGroup:
if (key_state == KEY_STATE_PRESSED) {
if (key_state == KMSCON_KEY_PRESSED) {
if (flags & XkbSA_GroupAbsolute)
base_group = group;
else
base_group += group;
} else if (key_state == KEY_STATE_RELEASED) {
} else if (key_state == KMSCON_KEY_RELEASED) {
if ((flags & XkbSA_LatchToLock) && latched_group) {
locked_group += group;
latched_group -= group;
@ -876,7 +881,7 @@ static bool process_group_action(struct xkb_desc *desc, struct xkb_state *state,
break;
case XkbSA_LockGroup:
if (key_state == KEY_STATE_PRESSED) {
if (key_state == KMSCON_KEY_PRESSED) {
if (flags & XkbSA_GroupAbsolute)
locked_group = group;
else

View File

@ -22,28 +22,27 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdint.h>
#ifndef KMSCON_INPUT_XKB_H
#define KMSCON_INPUT_XKB_H
#include <inttypes.h>
#include <X11/extensions/XKBcommon.h>
#include "input.h"
/*
* These are the values sent by the kernel in the /value/ field of the
* /input_event/ struct.
* See Documentation/input/event-codes.txt in the kernel tree.
*/
enum key_state {
KEY_STATE_RELEASED = 0,
KEY_STATE_PRESSED = 1,
KEY_STATE_REPEATED = 2,
};
int kmscon_xkb_new_desc(const char *layout, const char *variant,
const char *options,
struct xkb_desc **out);
void kmscon_xkb_free_desc(struct xkb_desc *desc);
int new_xkb_desc(const char *layout, const char *variant, const char *options,
struct xkb_desc **out);
void free_xkb_desc(struct xkb_desc *desc);
void kmscon_xkb_reset_state(struct xkb_desc *desc,
struct xkb_state *state,
int evdev_fd);
void reset_xkb_state(struct xkb_desc *desc, struct xkb_state *state,
int evdev_fd);
bool kmscon_xkb_process_evdev_key(struct xkb_desc *desc,
struct xkb_state *state,
enum kmscon_key_state key_state,
uint16_t code,
struct kmscon_input_event *out);
bool process_evdev_key(struct xkb_desc *desc, struct xkb_state *state,
enum key_state key_state, uint16_t code,
struct kmscon_input_event *out);
#endif /* KMSCON_INPUT_XKB_H */

View File

@ -34,6 +34,9 @@
#include <unistd.h>
#include <wchar.h>
#include <X11/extensions/XKBcommon.h>
#include <X11/keysym.h>
#include "eloop.h"
#include "input.h"
#include "log.h"