summaryrefslogtreecommitdiff
path: root/include/input/KeyLayoutMap.h
diff options
context:
space:
mode:
author Chris Ye <lzye@google.com> 2020-08-18 12:50:12 -0700
committer Chris Ye <lzye@google.com> 2020-08-28 22:13:25 -0700
commit1abffbd101f77f100789dc7fb8b33f729bb64dc9 (patch)
treeb9383e94b8ddff48dfa831e14df094ffa258863b /include/input/KeyLayoutMap.h
parent6ab8a005235a0270afb507bb9349abc13276fb79 (diff)
Move KeyLayoutMap from RefBase to shared_ptr.
Move KeyLayoutMap from inheriting RefBase and use shared_ptr to store in owner class like KeyMap. Bug: 160010896 Test: atest inputflinger, atest libinput_tests Change-Id: I565e07bdc501af644df5ebb8388fce10af185bce
Diffstat (limited to 'include/input/KeyLayoutMap.h')
-rw-r--r--include/input/KeyLayoutMap.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/input/KeyLayoutMap.h b/include/input/KeyLayoutMap.h
index 26f35012e2..872dd45c73 100644
--- a/include/input/KeyLayoutMap.h
+++ b/include/input/KeyLayoutMap.h
@@ -17,11 +17,12 @@
#ifndef _LIBINPUT_KEY_LAYOUT_MAP_H
#define _LIBINPUT_KEY_LAYOUT_MAP_H
+#include <android-base/result.h>
#include <stdint.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
-#include <utils/Tokenizer.h>
#include <utils/RefBase.h>
+#include <utils/Tokenizer.h>
namespace android {
@@ -60,9 +61,12 @@ struct AxisInfo {
*
* This object is immutable after it has been loaded.
*/
-class KeyLayoutMap : public RefBase {
+class KeyLayoutMap {
public:
- static status_t load(const std::string& filename, sp<KeyLayoutMap>* outMap);
+ static base::Result<std::shared_ptr<KeyLayoutMap>> load(const std::string& filename);
+ static base::Result<std::shared_ptr<KeyLayoutMap>> load(Tokenizer* tokenizer);
+ static base::Result<std::shared_ptr<KeyLayoutMap>> loadContents(const std::string& filename,
+ const char* contents);
status_t mapKey(int32_t scanCode, int32_t usageCode,
int32_t* outKeyCode, uint32_t* outFlags) const;
@@ -71,8 +75,8 @@ public:
status_t findUsageCodeForLed(int32_t ledCode, int32_t* outUsageCode) const;
status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const;
+ const std::string getLoadFileName() const;
-protected:
virtual ~KeyLayoutMap();
private:
@@ -91,6 +95,7 @@ private:
KeyedVector<int32_t, AxisInfo> mAxes;
KeyedVector<int32_t, Led> mLedsByScanCode;
KeyedVector<int32_t, Led> mLedsByUsageCode;
+ std::string mLoadFileName;
KeyLayoutMap();