diff options
author | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-21 20:59:49 +0000 |
---|---|---|
committer | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-21 20:59:49 +0000 |
commit | cbd76ae138c4f34cd272ee9c0ac4facbe90fed90 (patch) | |
tree | 14217b544d759f4455855f127308d4275f04b391 /include/views | |
parent | 76d6de0845910f18306125bbcaef7edf6e8f6649 (diff) |
Utils must not depend on Views.
http://codereview.appspot.com/5867051/
git-svn-id: http://skia.googlecode.com/svn/trunk@3459 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/views')
-rw-r--r-- | include/views/android/AndroidKeyToSkKey.h | 35 | ||||
-rw-r--r-- | include/views/unix/XkeysToSkKeys.h | 38 | ||||
-rw-r--r-- | include/views/unix/keysym2ucs.h | 15 |
3 files changed, 88 insertions, 0 deletions
diff --git a/include/views/android/AndroidKeyToSkKey.h b/include/views/android/AndroidKeyToSkKey.h new file mode 100644 index 0000000000..6bcb148b46 --- /dev/null +++ b/include/views/android/AndroidKeyToSkKey.h @@ -0,0 +1,35 @@ + +/* + * Copyright 2011 Skia + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#ifndef _ANDROID_TO_SKIA_KEYCODES_H +#define _ANDROID_TO_SKIA_KEYCODES_H + +#include "android/keycodes.h" +#include "SkKey.h" + +// Convert an Android keycode to an SkKey. This is an incomplete list, only +// including keys used by the sample app. +SkKey AndroidKeycodeToSkKey(int keycode) { + switch (keycode) { + case AKEYCODE_DPAD_LEFT: + return kLeft_SkKey; + case AKEYCODE_DPAD_RIGHT: + return kRight_SkKey; + case AKEYCODE_DPAD_UP: + return kUp_SkKey; + case AKEYCODE_DPAD_DOWN: + return kDown_SkKey; + case AKEYCODE_BACK: + return kBack_SkKey; + default: + return kNONE_SkKey; + } +} + +#endif diff --git a/include/views/unix/XkeysToSkKeys.h b/include/views/unix/XkeysToSkKeys.h new file mode 100644 index 0000000000..30eb97d396 --- /dev/null +++ b/include/views/unix/XkeysToSkKeys.h @@ -0,0 +1,38 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "X11/Xlib.h" +#include "X11/keysym.h" + +#include "SkKey.h" + +#ifndef XKEYS_TOSKKEYS_H +#define XKEYS_TOSKKEYS_H + +SkKey XKeyToSkKey(KeySym keysym) { + switch (keysym) { + case XK_BackSpace: + return kBack_SkKey; + case XK_Return: + return kOK_SkKey; + case XK_Home: + return kHome_SkKey; + case XK_End: + return kEnd_SkKey; + case XK_Right: + return kRight_SkKey; + case XK_Left: + return kLeft_SkKey; + case XK_Down: + return kDown_SkKey; + case XK_Up: + return kUp_SkKey; + default: + return kNONE_SkKey; + } +} +#endif diff --git a/include/views/unix/keysym2ucs.h b/include/views/unix/keysym2ucs.h new file mode 100644 index 0000000000..255a930539 --- /dev/null +++ b/include/views/unix/keysym2ucs.h @@ -0,0 +1,15 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +/* + * This module converts keysym values into the corresponding ISO 10646-1 + * (UCS, Unicode) values. + */ + +#include <X11/X.h> + +long keysym2ucs(KeySym keysym); |