Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

82 строки
2.0 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Benjamin Litzelmann
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. #include <lol/engine-internal.h>
  11. #include "input/input_internal.h"
  12. namespace lol
  13. {
  14. array<InputDevice*> InputDevice::devices;
  15. bool InputDevice::m_capturemouse;
  16. array<String> InputDevice::GetAvailableDevices()
  17. {
  18. array<String> result;
  19. for (int i = 0; i < devices.Count(); ++i)
  20. {
  21. result.Push(devices[i]->m_name);
  22. }
  23. return result;
  24. }
  25. void InputDeviceInternal::AddKey(const char* name)
  26. {
  27. m_keynames.Push(name);
  28. m_keys.Push(false);
  29. }
  30. void InputDeviceInternal::AddAxis(const char* name, float sensitivity)
  31. {
  32. m_axisnames.Push(name);
  33. m_axis.Push(0.0f, sensitivity);
  34. }
  35. void InputDeviceInternal::AddCursor(const char* name)
  36. {
  37. m_cursornames.Push(name);
  38. m_cursors.Push(vec2::zero, ivec2::zero);
  39. }
  40. InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard()
  41. {
  42. InputDeviceInternal* keyboard = new InputDeviceInternal(g_name_keyboard.C());
  43. /* "value" is unused, what matters is the index. */
  44. # define KEY_FUNC(key, value) \
  45. keyboard->AddKey(#key);
  46. # include "input/keys.h"
  47. # undef KEY_FUNC
  48. return keyboard;
  49. }
  50. InputDeviceInternal* InputDeviceInternal::CreateStandardMouse()
  51. {
  52. InputDeviceInternal* mouse = new InputDeviceInternal(g_name_mouse.C());
  53. mouse->AddKey("Left");
  54. mouse->AddKey("Middle");
  55. mouse->AddKey("Right");
  56. //Added to manage if mouse is in the screen or not.
  57. mouse->AddKey("InScreen");
  58. mouse->AddAxis("X");
  59. mouse->AddAxis("Y");
  60. mouse->AddAxis("XPixel");
  61. mouse->AddAxis("YPixel");
  62. mouse->AddAxis("Scroll");
  63. mouse->AddCursor("Cursor");
  64. // TODO: extended button, and wheel (as axis or as buttons? or both?)
  65. return mouse;
  66. }
  67. } /* namespace lol */