Skip to content
Permalink
Browse files

Analog test screen: Fix drawing of the X marks

  • Loading branch information...
hrydgard committed Sep 2, 2019
1 parent 6ff110d commit 90de634d1ed203a7064a15fee7cdabd0c205c0b0
Showing with 19 additions and 17 deletions.
  1. +16 −17 UI/ControlMappingScreen.cpp
  2. +3 −0 UI/DevScreens.cpp
@@ -432,9 +432,7 @@ class JoystickHistoryView : public UI::InertView {
JoystickHistoryView(int xAxis, int xDevice, int xDir, int yAxis, int yDevice, int yDir, UI::LayoutParams *layoutParams = nullptr)
: UI::InertView(layoutParams),
xAxis_(xAxis), xDir_(xDir),
yAxis_(yAxis), yDir_(yDir),
curX_(0.0f), curY_(0.0f),
maxCount_(500) {}
yAxis_(yAxis), yDir_(yDir) {}
void Draw(UIContext &dc) override;
void Update() override;
void Axis(const AxisInput &input) override {
@@ -448,8 +446,6 @@ class JoystickHistoryView : public UI::InertView {

private:
struct Location {
Location() : x(0.0f), y(0.0f) {}
Location(float xx, float yy) : x(xx), y(yy) {}
float x;
float y;
};
@@ -459,40 +455,44 @@ class JoystickHistoryView : public UI::InertView {
int yAxis_;
int yDir_;

float curX_;
float curY_;
float curX_ = 0.0f;
float curY_ = 0.0f;

std::deque<Location> locations_;
int maxCount_;
int maxCount_ = 500;
};

void JoystickHistoryView::Draw(UIContext &dc) {
if (xAxis_ > -1 && yAxis_ > -1) {
const AtlasImage &image = dc.Draw()->GetAtlas()->images[I_CROSS];
float minRadius = std::min(bounds_.w, bounds_.h) * 0.5f - image.w;

dc.Begin();
int a = maxCount_ - (int)locations_.size();
for (auto iter = locations_.begin(); iter != locations_.end(); ++iter) {
float x = bounds_.centerX() + minRadius * iter->x;
float y = bounds_.centerY() - minRadius * iter->y;
float alpha = (float)a / maxCount_;
if (alpha < 0.0f) alpha = 0.0f;
if (alpha < 0.0f) {
alpha = 0.0f;
}
dc.Draw()->DrawImage(I_CROSS, x, y, 0.8f, colorAlpha(0xFFFFFF, alpha), ALIGN_CENTER);
a++;
}
dc.Flush();
dc.BeginNoTex();
dc.Draw()->RectOutline(bounds_.centerX() - minRadius, bounds_.centerY() - minRadius, minRadius * 2, minRadius * 2, 0x80FFFFFF);
dc.Draw()->RectOutline(bounds_.centerX() - minRadius, bounds_.centerY() - minRadius, minRadius * 2.0f, minRadius * 2.0f, 0x80FFFFFF);
dc.Flush();
dc.Begin();
} else {
dc.DrawText("N/A", bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER);
}
}

void JoystickHistoryView::Update() {
locations_.push_back(Location(curX_, curY_));
if ((int)locations_.size() > maxCount_) {
locations_.pop_front();
if (xAxis_ > -1 && yAxis_ > -1) {
locations_.push_back(Location{ curX_, curY_ });
if ((int)locations_.size() > maxCount_) {
locations_.pop_front();
}
}
}

@@ -521,12 +521,11 @@ bool AnalogTestScreen::axis(const AxisInput &axis) {
// This is mainly to catch axis events that would otherwise get translated
// into arrow keys, since seeing keyboard arrow key events appear when using
// a controller would be confusing for the user.
char buf[512];

if (IgnoreAxisForMapping(axis.axisId))
return false;

if (axis.value > AXIS_BIND_THRESHOLD || axis.value < -AXIS_BIND_THRESHOLD) {
char buf[512];
snprintf(buf, sizeof(buf), "Axis: %d (value %1.3f) Device ID: %d",
axis.axisId, axis.value, axis.deviceId);
// Null-check just in case they weren't created yet.
@@ -439,6 +439,9 @@ void SystemInfoScreen::CreateViews() {

deviceSpecs->Add(new ItemHeader(si->T("System Information")));
deviceSpecs->Add(new InfoItem(si->T("System Name", "Name"), System_GetProperty(SYSPROP_NAME)));
#if PPSSPP_PLATFORM(ANDROID)
deviceSpecs->Add(new InfoItem(si->T("System Version"), StringFromInt(System_GetPropertyInt(SYSPROP_SYSTEMVERSION))));
#endif
deviceSpecs->Add(new InfoItem(si->T("Lang/Region"), System_GetProperty(SYSPROP_LANGREGION)));
std::string board = System_GetProperty(SYSPROP_BOARDNAME);
if (!board.empty())

0 comments on commit 90de634

Please sign in to comment.
You can’t perform that action at this time.