OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #include "embedders/openglui/common/input_handler.h" |
| 6 #include "embedders/openglui/common/log.h" |
| 7 |
| 8 InputHandler::InputHandler(VMGlue* vm_glue) |
| 9 : vm_glue_(vm_glue) { |
| 10 } |
| 11 |
| 12 int InputHandler::OnMotionEvent(MotionEvent event, |
| 13 int64_t when, |
| 14 float x, |
| 15 float y) { |
| 16 const char *function = NULL; |
| 17 switch (event) { |
| 18 case kMotionDown: |
| 19 function = "onMotionDown"; |
| 20 break; |
| 21 case kMotionUp: |
| 22 function = "onMotionUp"; |
| 23 break; |
| 24 case kMotionMove: |
| 25 function = "onMotionMove"; |
| 26 break; |
| 27 case kMotionCancel: |
| 28 function = "onMotionCancel"; |
| 29 break; |
| 30 case kMotionOutside: |
| 31 function = "onMotionOutside"; |
| 32 break; |
| 33 case kMotionPointerDown: |
| 34 function = "onMotionPointerDown"; |
| 35 break; |
| 36 case kMotionPointerUp: |
| 37 function = "onMotionPointerUp"; |
| 38 break; |
| 39 default: |
| 40 return -1; |
| 41 } |
| 42 return vm_glue_->OnMotionEvent(function, when, x, y); |
| 43 } |
| 44 |
| 45 int InputHandler::OnKeyEvent(KeyEvent event, |
| 46 int64_t when, |
| 47 int32_t flags, |
| 48 int32_t key_code, |
| 49 int32_t meta_state, |
| 50 int32_t repeat) { |
| 51 const char *function = NULL; |
| 52 switch (event) { |
| 53 case kKeyDown: |
| 54 function = "onKeyDown"; |
| 55 break; |
| 56 case kKeyUp: |
| 57 function = "onKeyUp"; |
| 58 break; |
| 59 case kKeyMultiple: |
| 60 function = "onKeyMultiple"; |
| 61 break; |
| 62 default: |
| 63 return -1; |
| 64 } |
| 65 return vm_glue_->OnKeyEvent(function, when, flags, key_code, |
| 66 meta_state, repeat); |
| 67 } |
| 68 |
OLD | NEW |