2010-12-23 17:50:18 -08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _UI_POINTER_CONTROLLER_H
|
|
|
|
#define _UI_POINTER_CONTROLLER_H
|
|
|
|
|
2020-06-26 20:25:34 +01:00
|
|
|
#include <PointerControllerInterface.h>
|
|
|
|
#include <gui/DisplayEventReceiver.h>
|
2018-12-18 17:39:43 +08:00
|
|
|
#include <input/DisplayViewport.h>
|
2013-07-01 19:07:15 -07:00
|
|
|
#include <input/Input.h>
|
2012-05-11 12:24:35 -07:00
|
|
|
#include <utils/BitSet.h>
|
2011-03-02 14:41:58 -08:00
|
|
|
#include <utils/Looper.h>
|
2020-06-26 20:25:34 +01:00
|
|
|
#include <utils/RefBase.h>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2020-07-17 19:48:24 +00:00
|
|
|
#include "MouseCursorController.h"
|
|
|
|
#include "PointerControllerContext.h"
|
2020-06-26 20:25:34 +01:00
|
|
|
#include "SpriteController.h"
|
2020-07-17 19:48:24 +00:00
|
|
|
#include "TouchSpotController.h"
|
2011-01-02 16:37:43 -08:00
|
|
|
|
2010-12-23 17:50:18 -08:00
|
|
|
namespace android {
|
|
|
|
|
2011-01-02 16:37:43 -08:00
|
|
|
/*
|
|
|
|
* Tracks pointer movements and draws the pointer sprite to a surface.
|
|
|
|
*
|
|
|
|
* Handles pointer acceleration and animation.
|
|
|
|
*/
|
2020-06-26 20:25:34 +01:00
|
|
|
class PointerController : public PointerControllerInterface {
|
2011-01-02 16:37:43 -08:00
|
|
|
public:
|
2020-06-26 20:25:34 +01:00
|
|
|
static std::shared_ptr<PointerController> create(
|
|
|
|
const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper,
|
|
|
|
const sp<SpriteController>& spriteController);
|
2011-03-02 14:41:58 -08:00
|
|
|
|
2020-07-17 19:48:24 +00:00
|
|
|
virtual ~PointerController() = default;
|
2011-01-02 16:37:43 -08:00
|
|
|
|
2020-07-17 19:48:24 +00:00
|
|
|
virtual bool getBounds(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const;
|
2011-01-02 16:37:43 -08:00
|
|
|
virtual void move(float deltaX, float deltaY);
|
2011-05-06 18:20:01 -07:00
|
|
|
virtual void setButtonState(int32_t buttonState);
|
|
|
|
virtual int32_t getButtonState() const;
|
2011-01-02 16:37:43 -08:00
|
|
|
virtual void setPosition(float x, float y);
|
|
|
|
virtual void getPosition(float* outX, float* outY) const;
|
2018-12-18 17:39:43 +08:00
|
|
|
virtual int32_t getDisplayId() const;
|
2011-05-25 18:23:38 -07:00
|
|
|
virtual void fade(Transition transition);
|
|
|
|
virtual void unfade(Transition transition);
|
2020-01-09 11:30:04 -08:00
|
|
|
virtual void setDisplayViewport(const DisplayViewport& viewport);
|
2011-01-02 16:37:43 -08:00
|
|
|
|
2011-04-12 22:39:53 -07:00
|
|
|
virtual void setPresentation(Presentation presentation);
|
2020-07-17 19:48:24 +00:00
|
|
|
virtual void setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex,
|
|
|
|
BitSet32 spotIdBits, int32_t displayId);
|
2011-04-12 22:39:53 -07:00
|
|
|
virtual void clearSpots();
|
|
|
|
|
2016-05-13 17:44:16 +01:00
|
|
|
void updatePointerIcon(int32_t iconId);
|
2015-10-30 15:54:33 -07:00
|
|
|
void setCustomPointerIcon(const SpriteIcon& icon);
|
2011-04-12 22:39:53 -07:00
|
|
|
void setInactivityTimeout(InactivityTimeout inactivityTimeout);
|
2020-07-17 19:48:24 +00:00
|
|
|
void doInactivityTimeout();
|
2015-11-24 11:25:52 -08:00
|
|
|
void reloadPointerResources();
|
2020-07-17 19:48:24 +00:00
|
|
|
void onDisplayViewportsUpdated(std::vector<DisplayViewport>& viewports);
|
2011-01-02 16:37:43 -08:00
|
|
|
|
|
|
|
private:
|
2020-07-17 19:48:24 +00:00
|
|
|
friend PointerControllerContext::LooperCallback;
|
|
|
|
friend PointerControllerContext::MessageHandler;
|
2011-04-12 22:39:53 -07:00
|
|
|
|
2020-07-17 19:48:24 +00:00
|
|
|
mutable std::mutex mLock;
|
2011-03-02 14:41:58 -08:00
|
|
|
|
2020-07-17 19:48:24 +00:00
|
|
|
PointerControllerContext mContext;
|
2020-06-26 20:25:34 +01:00
|
|
|
|
2020-07-17 19:48:24 +00:00
|
|
|
MouseCursorController mCursorController;
|
2011-04-12 22:39:53 -07:00
|
|
|
|
2011-01-02 16:37:43 -08:00
|
|
|
struct Locked {
|
2011-04-12 22:39:53 -07:00
|
|
|
Presentation presentation;
|
2015-09-11 18:08:31 -07:00
|
|
|
|
2020-07-17 19:48:24 +00:00
|
|
|
std::unordered_map<int32_t /* displayId */, TouchSpotController> spotControllers;
|
2018-12-18 17:39:43 +08:00
|
|
|
} mLocked GUARDED_BY(mLock);
|
2011-03-02 14:41:58 -08:00
|
|
|
|
2020-06-26 20:25:34 +01:00
|
|
|
PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper,
|
|
|
|
const sp<SpriteController>& spriteController);
|
2020-07-17 19:48:24 +00:00
|
|
|
void clearSpotsLocked();
|
2011-01-02 16:37:43 -08:00
|
|
|
};
|
|
|
|
|
2010-12-23 17:50:18 -08:00
|
|
|
} // namespace android
|
|
|
|
|
|
|
|
#endif // _UI_POINTER_CONTROLLER_H
|