key_map.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "core/hle/service/hid.h"
  6. namespace KeyMap {
  7. /**
  8. * Represents a key for a specific host device.
  9. */
  10. struct HostDeviceKey {
  11. int key_code;
  12. int device_id; ///< Uniquely identifies a host device
  13. bool operator < (const HostDeviceKey &other) const {
  14. if (device_id == other.device_id) {
  15. return key_code < other.key_code;
  16. }
  17. return device_id < other.device_id;
  18. }
  19. bool operator == (const HostDeviceKey &other) const {
  20. return device_id == other.device_id && key_code == other.key_code;
  21. }
  22. };
  23. /**
  24. * Generates a new device id, which uniquely identifies a host device within KeyMap.
  25. */
  26. int NewDeviceId();
  27. /**
  28. * Maps a device-specific key to a PadState.
  29. */
  30. void SetKeyMapping(HostDeviceKey key, HID_User::PadState padState);
  31. /**
  32. * Gets the PadState that's mapped to the provided device-specific key.
  33. */
  34. HID_User::PadState GetPadKey(HostDeviceKey key);
  35. }