Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

73 rindas
1.6 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. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include "core.h"
  14. #ifdef LOL_INPUT_V2
  15. #include "input/inputdevice_internal.h"
  16. namespace lol
  17. {
  18. Array<InputDevice*> InputDevice::devices;
  19. bool InputDevice::m_capturemouse;
  20. void InputDeviceInternal::AddKey(const char* name)
  21. {
  22. m_keynames.Push(name);
  23. m_keys.Push(false);
  24. }
  25. void InputDeviceInternal::AddAxis(const char* name, float sensitivity)
  26. {
  27. m_axisnames.Push(name);
  28. m_axis.Push(0.0f, sensitivity);
  29. }
  30. void InputDeviceInternal::AddCursor(const char* name)
  31. {
  32. m_cursornames.Push(name);
  33. m_cursors.Push(vec2(0.0), ivec2(0));
  34. }
  35. InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard()
  36. {
  37. InputDeviceInternal* keyboard = new InputDeviceInternal("Keyboard");
  38. # define KEY_FUNC(key, value) keyboard->AddKey(#key);
  39. # include "input/keys.h"
  40. # undef KEY_FUNC
  41. return keyboard;
  42. }
  43. InputDeviceInternal* InputDeviceInternal::CreateStandardMouse()
  44. {
  45. InputDeviceInternal* mouse = new InputDeviceInternal("Mouse");
  46. mouse->AddKey("ButtonLeft");
  47. mouse->AddKey("ButtonMiddle");
  48. mouse->AddKey("ButtonRight");
  49. mouse->AddAxis("X");
  50. mouse->AddAxis("Y");
  51. mouse->AddCursor("Cursor");
  52. // TODO: extended button, and wheel (as axis or as buttons? or both?)
  53. return mouse;
  54. }
  55. } /* namespace lol */
  56. #endif // LOL_INPUT_V2