| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "embedders/openglui/common/input_handler.h" | 5 #include "embedders/openglui/common/input_handler.h" |
| 6 #include "embedders/openglui/common/log.h" | 6 #include "embedders/openglui/common/log.h" |
| 7 | 7 |
| 8 InputHandler::InputHandler(VMGlue* vm_glue) | 8 InputHandler::InputHandler(VMGlue* vm_glue) |
| 9 : vm_glue_(vm_glue) { | 9 : vm_glue_(vm_glue) { |
| 10 } | 10 } |
| 11 | 11 |
| 12 int InputHandler::OnMotionEvent(MotionEvent event, | 12 int InputHandler::OnMotionEvent(MotionEvent event, |
| 13 int64_t when, | 13 int64_t when, |
| 14 float x, | 14 float x, |
| 15 float y) { | 15 float y) { |
| 16 const char *function = NULL; | 16 const char *function = NULL; |
| 17 // For now we just keep this simple. There are |
| 18 // no click events or mouseover events. |
| 17 switch (event) { | 19 switch (event) { |
| 18 case kMotionDown: | 20 case kMotionDown: |
| 19 function = "onMotionDown"; | 21 function = "onMouseDown_"; |
| 20 break; | 22 break; |
| 21 case kMotionUp: | 23 case kMotionUp: |
| 22 function = "onMotionUp"; | 24 function = "onMouseUp_"; |
| 23 break; | 25 break; |
| 24 case kMotionMove: | 26 case kMotionMove: |
| 25 function = "onMotionMove"; | 27 function = "onMouseMove_"; |
| 26 break; | 28 break; |
| 27 case kMotionCancel: | 29 case kMotionCancel: |
| 28 function = "onMotionCancel"; | |
| 29 break; | 30 break; |
| 30 case kMotionOutside: | 31 case kMotionOutside: |
| 31 function = "onMotionOutside"; | |
| 32 break; | 32 break; |
| 33 case kMotionPointerDown: | 33 case kMotionPointerDown: |
| 34 function = "onMotionPointerDown"; | |
| 35 break; | 34 break; |
| 36 case kMotionPointerUp: | 35 case kMotionPointerUp: |
| 37 function = "onMotionPointerUp"; | |
| 38 break; | 36 break; |
| 39 default: | 37 default: |
| 40 return -1; | 38 return -1; |
| 41 } | 39 } |
| 42 return vm_glue_->OnMotionEvent(function, when, x, y); | 40 if (function == NULL) { |
| 41 return 0; |
| 42 } else { |
| 43 return vm_glue_->OnMotionEvent(function, when, x, y); |
| 44 } |
| 43 } | 45 } |
| 44 | 46 |
| 45 int InputHandler::OnKeyEvent(KeyEvent event, | 47 int InputHandler::OnKeyEvent(KeyEvent event, |
| 46 int64_t when, | 48 int64_t when, |
| 47 int32_t flags, | |
| 48 int32_t key_code, | 49 int32_t key_code, |
| 49 int32_t meta_state, | 50 bool isAltKeyDown, |
| 51 bool isCtrlKeyDown, |
| 52 bool isShiftKeyDown, |
| 50 int32_t repeat) { | 53 int32_t repeat) { |
| 51 const char *function = NULL; | 54 const char *function = NULL; |
| 52 switch (event) { | 55 switch (event) { |
| 53 case kKeyDown: | 56 case kKeyDown: |
| 54 function = "onKeyDown"; | 57 function = "onKeyDown_"; |
| 55 break; | 58 break; |
| 56 case kKeyUp: | 59 case kKeyUp: |
| 57 function = "onKeyUp"; | 60 function = "onKeyUp_"; |
| 58 break; | 61 break; |
| 59 case kKeyMultiple: | 62 case kKeyMultiple: |
| 60 function = "onKeyMultiple"; | 63 return -1; // TODO(gram): handle this. |
| 61 break; | 64 break; |
| 62 default: | 65 default: |
| 63 return -1; | 66 return -1; |
| 64 } | 67 } |
| 65 return vm_glue_->OnKeyEvent(function, when, flags, key_code, | 68 return vm_glue_->OnKeyEvent(function, when, key_code, |
| 66 meta_state, repeat); | 69 isAltKeyDown, isCtrlKeyDown, isShiftKeyDown, |
| 70 repeat); |
| 67 } | 71 } |
| 68 | 72 |
| OLD | NEW |