epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
Scroggo | f33d153 | 2011-05-31 17:10:21 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Skia |
Scroggo | f33d153 | 2011-05-31 17:10:21 +0000 | [diff] [blame] | 4 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
Scroggo | f33d153 | 2011-05-31 17:10:21 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
Scroggo | f33d153 | 2011-05-31 17:10:21 +0000 | [diff] [blame] | 10 | #ifndef _ANDROID_TO_SKIA_KEYCODES_H |
| 11 | #define _ANDROID_TO_SKIA_KEYCODES_H |
| 12 | |
djsollen@google.com | e32b583 | 2011-06-13 16:58:40 +0000 | [diff] [blame] | 13 | #include "android/keycodes.h" |
Scroggo | f33d153 | 2011-05-31 17:10:21 +0000 | [diff] [blame] | 14 | #include "SkKey.h" |
| 15 | |
| 16 | // Convert an Android keycode to an SkKey. This is an incomplete list, only |
| 17 | // including keys used by the sample app. |
| 18 | SkKey AndroidKeycodeToSkKey(int keycode) { |
| 19 | switch (keycode) { |
| 20 | case AKEYCODE_DPAD_LEFT: |
| 21 | return kLeft_SkKey; |
| 22 | case AKEYCODE_DPAD_RIGHT: |
| 23 | return kRight_SkKey; |
| 24 | case AKEYCODE_DPAD_UP: |
| 25 | return kUp_SkKey; |
| 26 | case AKEYCODE_DPAD_DOWN: |
| 27 | return kDown_SkKey; |
djsollen@google.com | e32b583 | 2011-06-13 16:58:40 +0000 | [diff] [blame] | 28 | case AKEYCODE_BACK: |
| 29 | return kBack_SkKey; |
Scroggo | f33d153 | 2011-05-31 17:10:21 +0000 | [diff] [blame] | 30 | default: |
| 31 | return kNONE_SkKey; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | #endif |