| 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 // For now we just keep this simple. There are | |
| 18 // no click events or mouseover events. | |
| 19 switch (event) { | |
| 20 case kMotionDown: | |
| 21 function = "onMouseDown_"; | |
| 22 break; | |
| 23 case kMotionUp: | |
| 24 function = "onMouseUp_"; | |
| 25 break; | |
| 26 case kMotionMove: | |
| 27 function = "onMouseMove_"; | |
| 28 break; | |
| 29 case kMotionCancel: | |
| 30 break; | |
| 31 case kMotionOutside: | |
| 32 break; | |
| 33 case kMotionPointerDown: | |
| 34 break; | |
| 35 case kMotionPointerUp: | |
| 36 break; | |
| 37 default: | |
| 38 return -1; | |
| 39 } | |
| 40 if (function == NULL) { | |
| 41 return 0; | |
| 42 } else { | |
| 43 return vm_glue_->OnMotionEvent(function, when, x, y); | |
| 44 } | |
| 45 } | |
| 46 | |
| 47 int InputHandler::OnKeyEvent(KeyEvent event, | |
| 48 int64_t when, | |
| 49 int32_t key_code, | |
| 50 bool isAltKeyDown, | |
| 51 bool isCtrlKeyDown, | |
| 52 bool isShiftKeyDown, | |
| 53 int32_t repeat) { | |
| 54 const char *function = NULL; | |
| 55 switch (event) { | |
| 56 case kKeyDown: | |
| 57 function = "onKeyDown_"; | |
| 58 break; | |
| 59 case kKeyUp: | |
| 60 function = "onKeyUp_"; | |
| 61 break; | |
| 62 case kKeyMultiple: | |
| 63 return -1; // TODO(gram): handle this. | |
| 64 break; | |
| 65 default: | |
| 66 return -1; | |
| 67 } | |
| 68 return vm_glue_->OnKeyEvent(function, when, key_code, | |
| 69 isAltKeyDown, isCtrlKeyDown, isShiftKeyDown, | |
| 70 repeat); | |
| 71 } | |
| 72 | |
| 73 void InputHandler::OnAccelerometerEvent(float x, float y, float z) { | |
| 74 vm_glue_->OnAccelerometerEvent(x, y, z); | |
| 75 } | |
| 76 | |
| OLD | NEW |