host.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (c) 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // Mirrored in src/chrome/test/remoting/remote_test_helper.h
  5. var Action = {
  6. Error: 0,
  7. None: 1,
  8. Keydown: 2,
  9. Buttonpress: 3,
  10. Mousemove: 4,
  11. Mousewheel: 5,
  12. Drag: 6
  13. };
  14. /**
  15. * Method to handle sending keypress events to the server.
  16. * @param {Event} event The event handler event.
  17. */
  18. function handleKeyPress(event) {
  19. jsonRpc.setLastEvent(Action.Keydown, event.keyCode, 0);
  20. }
  21. /**
  22. * Method to handle sending mouse down events to the server.
  23. * @param {Event} event The event handler event.
  24. */
  25. function handleMouseDown(event) {
  26. jsonRpc.setLastEvent(Action.Buttonpress, event.button, 0);
  27. }
  28. /**
  29. * Method to handle sending mouse move events to the server.
  30. * @param {Event} event The event handler event.
  31. */
  32. function handleMouseMove(event) {
  33. jsonRpc.setLastEvent(Action.Mousemove, event.keyCode, 0);
  34. }
  35. /**
  36. * Method to handle sending mouse wheel events to the server.
  37. * @param {Event} event The event handler event.
  38. */
  39. function handleMouseWheel(event) {
  40. jsonRpc.setLastEvent(Action.Mousewheel, 0, 0);
  41. }
  42. /**
  43. * Method to handle sending drag events to the server.
  44. * @param {Event} event The event handler event.
  45. */
  46. function handleDrag(event) {
  47. jsonRpc.setLastEvent(Action.Drag, 0, 0);
  48. }
  49. window.addEventListener('keydown', handleKeyPress, false);
  50. window.addEventListener('mousedown', handleMouseDown, false);
  51. window.addEventListener('mousewheel', handleMouseWheel, false);
  52. window.addEventListener('drag', handleDrag, false);
  53. // window.addEventListener('mousemove', handleMouseMove, false)