2012-11-01 15:19:01 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2012-11-04 22:01:49 +00:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "input/input_state.h"
|
|
|
|
#include "gfx_es2/draw_buffer.h"
|
|
|
|
|
2013-07-20 10:06:06 +00:00
|
|
|
#include "ui/view.h"
|
|
|
|
#include "ui/viewgroup.h"
|
|
|
|
|
|
|
|
class MultiTouchButton : public UI::View {
|
|
|
|
public:
|
|
|
|
MultiTouchButton(int bgImg, int img, float scale, UI::LayoutParams *layoutParams)
|
2013-10-21 05:13:54 +00:00
|
|
|
: UI::View(layoutParams), pointerDownMask_(0), scale_(scale), bgImg_(bgImg), img_(img), angle_(0.0f), flipImageH_(false) {
|
2013-07-20 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2015-02-02 23:11:51 +00:00
|
|
|
virtual bool Key(const KeyInput &input) { return false; }
|
2013-07-20 10:06:06 +00:00
|
|
|
virtual void Update(const InputState &input) {}
|
|
|
|
virtual void Touch(const TouchInput &input);
|
|
|
|
virtual void Draw(UIContext &dc);
|
|
|
|
virtual void GetContentDimensions(const UIContext &dc, float &w, float &h) const;
|
2013-07-20 18:48:21 +00:00
|
|
|
virtual bool IsDown() { return pointerDownMask_ != 0; }
|
2013-07-20 12:05:07 +00:00
|
|
|
// chainable
|
|
|
|
MultiTouchButton *FlipImageH(bool flip) { flipImageH_ = flip; return this; }
|
|
|
|
MultiTouchButton *SetAngle(float angle) { angle_ = angle; return this; }
|
2013-07-20 10:06:06 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
uint32_t pointerDownMask_;
|
2013-10-09 20:15:56 +00:00
|
|
|
float scale_;
|
2013-07-20 10:06:06 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int bgImg_;
|
|
|
|
int img_;
|
2013-07-20 12:05:07 +00:00
|
|
|
float angle_;
|
2013-07-20 10:06:06 +00:00
|
|
|
bool flipImageH_;
|
|
|
|
};
|
|
|
|
|
2013-07-20 12:05:07 +00:00
|
|
|
class BoolButton : public MultiTouchButton {
|
|
|
|
public:
|
|
|
|
BoolButton(bool *value, int bgImg, int img, float scale, UI::LayoutParams *layoutParams)
|
|
|
|
: MultiTouchButton(bgImg, img, scale, layoutParams), value_(value) {
|
|
|
|
|
|
|
|
}
|
2015-02-02 23:11:51 +00:00
|
|
|
virtual void Touch(const TouchInput &input) override;
|
2013-07-20 12:05:07 +00:00
|
|
|
virtual bool IsDown() { return *value_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool *value_;
|
|
|
|
};
|
|
|
|
|
2013-07-20 10:06:06 +00:00
|
|
|
class PSPButton : public MultiTouchButton {
|
|
|
|
public:
|
|
|
|
PSPButton(int pspButtonBit, int bgImg, int img, float scale, UI::LayoutParams *layoutParams)
|
|
|
|
: MultiTouchButton(bgImg, img, scale, layoutParams), pspButtonBit_(pspButtonBit) {
|
|
|
|
}
|
2015-02-02 23:11:51 +00:00
|
|
|
void Touch(const TouchInput &input) override;
|
2013-07-20 10:06:06 +00:00
|
|
|
virtual bool IsDown();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int pspButtonBit_;
|
|
|
|
};
|
|
|
|
|
2013-12-02 14:15:19 +00:00
|
|
|
class PSPDpad : public UI::View {
|
2013-07-20 10:06:06 +00:00
|
|
|
public:
|
2013-12-02 14:15:19 +00:00
|
|
|
PSPDpad(int arrowIndex, int overlayIndex, float scale, float spacing, UI::LayoutParams *layoutParams);
|
2013-07-20 10:06:06 +00:00
|
|
|
|
2015-02-02 23:11:51 +00:00
|
|
|
bool Key(const KeyInput &input) override { return false; }
|
|
|
|
void Update(const InputState &input) override {}
|
|
|
|
void Touch(const TouchInput &input) override;
|
|
|
|
void Draw(UIContext &dc) override;
|
|
|
|
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
2013-07-20 10:06:06 +00:00
|
|
|
|
|
|
|
private:
|
2013-07-20 10:54:33 +00:00
|
|
|
void ProcessTouch(float x, float y, bool down);
|
2013-07-20 10:06:06 +00:00
|
|
|
int arrowIndex_;
|
|
|
|
int overlayIndex_;
|
2013-07-20 10:54:33 +00:00
|
|
|
|
2013-07-20 18:48:21 +00:00
|
|
|
float scale_;
|
2013-12-02 14:15:19 +00:00
|
|
|
float spacing_;
|
2013-07-20 18:48:21 +00:00
|
|
|
|
2013-07-20 10:54:33 +00:00
|
|
|
int dragPointerId_;
|
2013-07-20 10:06:06 +00:00
|
|
|
int down_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PSPStick : public UI::View {
|
|
|
|
public:
|
2013-07-20 12:05:07 +00:00
|
|
|
PSPStick(int bgImg, int stickImg, int stick, float scale, UI::LayoutParams *layoutParams);
|
|
|
|
|
2015-02-02 23:11:51 +00:00
|
|
|
bool Key(const KeyInput &input) override { return false; }
|
|
|
|
void Update(const InputState &input) override {}
|
|
|
|
void Touch(const TouchInput &input) override;
|
|
|
|
void Draw(UIContext &dc) override;
|
|
|
|
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
2013-07-20 10:06:06 +00:00
|
|
|
|
|
|
|
private:
|
2013-07-20 12:05:07 +00:00
|
|
|
void ProcessTouch(float x, float y, bool down);
|
|
|
|
|
|
|
|
int dragPointerId_;
|
|
|
|
int bgImg_;
|
2013-07-20 10:06:06 +00:00
|
|
|
int stickImageIndex_;
|
|
|
|
int stick_;
|
2013-07-20 12:05:07 +00:00
|
|
|
float stick_size_;
|
2013-07-20 10:06:06 +00:00
|
|
|
float scale_;
|
|
|
|
bool dragging_[MAX_POINTERS];
|
|
|
|
bool lastPointerDown_[MAX_POINTERS];
|
2015-03-05 09:58:25 +00:00
|
|
|
|
|
|
|
float centerX_;
|
|
|
|
float centerY_;
|
2013-07-20 10:06:06 +00:00
|
|
|
};
|
|
|
|
|
2013-10-09 20:15:56 +00:00
|
|
|
//initializes the layout from Config. if a default layout does not exist,
|
|
|
|
//it sets up default values
|
2014-02-10 14:55:21 +00:00
|
|
|
void InitPadLayout(float xres, float yres, float globalScale = 1.15f);
|
|
|
|
UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause);
|
2013-12-02 14:15:19 +00:00
|
|
|
|
|
|
|
const int D_pad_Radius = 50;
|
|
|
|
const int baseActionButtonSpacing = 60;
|
|
|
|
|