/include/ui/VirtualKeyMap.h

http://github.com/CyanogenMod/android_frameworks_base · C++ Header · 79 lines · 41 code · 17 blank · 21 comment · 0 complexity · 9d46b1453830317a16c2267429d6c292 MD5 · raw file

  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 _UI_VIRTUAL_KEY_MAP_H
  17. #define _UI_VIRTUAL_KEY_MAP_H
  18. #include <stdint.h>
  19. #include <ui/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. class VirtualKeyMap {
  40. public:
  41. ~VirtualKeyMap();
  42. static status_t load(const String8& filename, VirtualKeyMap** outMap);
  43. inline const Vector<VirtualKeyDefinition>& getVirtualKeys() const {
  44. return mVirtualKeys;
  45. }
  46. private:
  47. class Parser {
  48. VirtualKeyMap* mMap;
  49. Tokenizer* mTokenizer;
  50. public:
  51. Parser(VirtualKeyMap* map, Tokenizer* tokenizer);
  52. ~Parser();
  53. status_t parse();
  54. private:
  55. bool consumeFieldDelimiterAndSkipWhitespace();
  56. bool parseNextIntField(int32_t* outValue);
  57. };
  58. Vector<VirtualKeyDefinition> mVirtualKeys;
  59. VirtualKeyMap();
  60. };
  61. } // namespace android
  62. #endif // _UI_KEY_CHARACTER_MAP_H