VirtualKeyMap.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (C) 2010 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _LIBINPUT_VIRTUAL_KEY_MAP_H
  17. #define _LIBINPUT_VIRTUAL_KEY_MAP_H
  18. #include <stdint.h>
  19. #include <input/Input.h>
  20. #include <utils/Errors.h>
  21. #include <utils/KeyedVector.h>
  22. #include <utils/Tokenizer.h>
  23. #include <utils/String8.h>
  24. #include <utils/Unicode.h>
  25. namespace android {
  26. /* Describes a virtual key. */
  27. struct VirtualKeyDefinition {
  28. int32_t scanCode;
  29. // configured position data, specified in display coords
  30. int32_t centerX;
  31. int32_t centerY;
  32. int32_t width;
  33. int32_t height;
  34. };
  35. /**
  36. * Describes a collection of virtual keys on a touch screen in terms of
  37. * virtual scan codes and hit rectangles.
  38. *
  39. * This object is immutable after it has been loaded.
  40. */
  41. class VirtualKeyMap {
  42. public:
  43. ~VirtualKeyMap();
  44. static status_t load(const String8& filename, VirtualKeyMap** outMap);
  45. inline const Vector<VirtualKeyDefinition>& getVirtualKeys() const {
  46. return mVirtualKeys;
  47. }
  48. private:
  49. class Parser {
  50. VirtualKeyMap* mMap;
  51. Tokenizer* mTokenizer;
  52. public:
  53. Parser(VirtualKeyMap* map, Tokenizer* tokenizer);
  54. ~Parser();
  55. status_t parse();
  56. private:
  57. bool consumeFieldDelimiterAndSkipWhitespace();
  58. bool parseNextIntField(int32_t* outValue);
  59. };
  60. Vector<VirtualKeyDefinition> mVirtualKeys;
  61. VirtualKeyMap();
  62. };
  63. } // namespace android
  64. #endif // _LIBINPUT_KEY_CHARACTER_MAP_H