summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp
diff options
context:
space:
mode:
authorJohn Sebastian Peterson <john.s.peterson@live.com>2013-07-15 00:38:57 +0200
committerJohn Sebastian Peterson <john.s.peterson@live.com>2015-01-18 17:25:50 +0100
commit3f8e5cc9299e73c8d1ae9278df10f02d4632cddb (patch)
tree7c085ed1ee0c9a1062de21c09bc4190a0431a43e /Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp
parent9d9ffa5b8321b371edd40547232852ff81d309bd (diff)
Fix the input zone drawing in input settings
Diffstat (limited to 'Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp')
-rw-r--r--Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp113
1 files changed, 83 insertions, 30 deletions
diff --git a/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp b/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp
index 4b838a8ab6..63df59e129 100644
--- a/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp
+++ b/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp
@@ -27,6 +27,66 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/Device.h"
+struct ShapePosition
+{
+ double max;
+ double diag;
+ double box;
+ double scale;
+
+ double dz;
+ double range;
+
+ wxCoord offset;
+};
+
+// regular octagon
+void DrawOctagon(wxDC* dc, ShapePosition p)
+{
+ const int vertices = 8;
+ double radius = p.max;
+
+ wxPoint point[vertices];
+
+ double angle = 2.0 * M_PI / vertices;
+
+ for (int i = 0; i < vertices; i++)
+ {
+ double a = (angle * i);
+ double x = radius * cos(a);
+ double y = radius * sin(a);
+ point[i].x = x;
+ point[i].y = y;
+ }
+
+ dc->DrawPolygon(vertices, point, p.offset, p.offset);
+}
+
+// irregular dodecagon
+void DrawDodecagon(wxDC* dc, ShapePosition p)
+{
+ const int vertices = 12;
+
+ wxPoint point[vertices];
+ point[0].x = p.dz; point[0].y = p.max;
+ point[1].x = p.diag; point[1].y = p.diag;
+ point[2].x = p.max; point[2].y = p.dz;
+
+ point[3].x = p.max; point[3].y = -p.dz;
+ point[4].x = p.diag; point[4].y = -p.diag;
+ point[5].x = p.dz; point[5].y = -p.max;
+
+ point[6].x = -p.dz; point[6].y = -p.max;
+ point[7].x = -p.diag; point[7].y = -p.diag;
+ point[8].x = -p.max; point[8].y = -p.dz;
+
+ point[9].x = -p.max; point[9].y = p.dz;
+ point[10].x = -p.diag; point[10].y = p.diag;
+ point[11].x = -p.dz; point[11].y = p.max;
+
+ dc->DrawPolygon(vertices, point, p.offset, p.offset);
+}
+
static void DrawCenteredRectangle(wxDC &dc, int x, int y, int w, int h)
{
x -= w / 2;
@@ -89,7 +149,7 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
dc.DrawRectangle(0, 31 - z*31, 64, 2);
}
- // octagon for visual aid for diagonal adjustment
+ // input zone
dc.SetPen(*wxLIGHT_GREY_PEN);
dc.SetBrush(*wxWHITE_BRUSH);
if (GROUP_TYPE_STICK == g->control_group->type)
@@ -100,42 +160,35 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
dc.SetBrush(LightGrayBrush);
dc.SetPen(LightGrayPen);
- // polygon offset
- ControlState max
- , diagonal
- , box = 64
- , d_of = box / 256.0
- , x_of = box / 2.0;
+ ShapePosition p;
+ p.box = 64;
+ p.offset = p.box / 2;
+ p.range = 256;
+ p.scale = p.box / p.range;
+ p.dz = 15 * p.scale;
+ bool octagon = false;
if (g->control_group->name == "Main Stick")
{
- max = (87.0 / 127.0) * 100;
- diagonal = (55.0 / 127.0) * 100;
+ p.max = 87 * p.scale;
+ p.diag = 55 * p.scale;
}
else if (g->control_group->name == "C-Stick")
{
- max = (74.0 / 127.0) * 100;
- diagonal = (46.0 / 127.0) * 100;
+ p.max = 74 * p.scale;
+ p.diag = 46 * p.scale;
}
else
{
- max = (82.0 / 127.0) * 100;
- diagonal = (58.0 / 127.0) * 100;
+ p.scale = 1;
+ p.max = 32;
+ octagon = true;
}
- // polygon corners
- wxPoint Points[8];
- Points[0].x = (int)(0.0 * d_of + x_of); Points[0].y = (int)(max * d_of + x_of);
- Points[1].x = (int)(diagonal * d_of + x_of); Points[1].y = (int)(diagonal * d_of + x_of);
- Points[2].x = (int)(max * d_of + x_of); Points[2].y = (int)(0.0 * d_of + x_of);
- Points[3].x = (int)(diagonal * d_of + x_of); Points[3].y = (int)(-diagonal * d_of + x_of);
- Points[4].x = (int)(0.0 * d_of + x_of); Points[4].y = (int)(-max * d_of + x_of);
- Points[5].x = (int)(-diagonal * d_of + x_of); Points[5].y = (int)(-diagonal * d_of + x_of);
- Points[6].x = (int)(-max * d_of + x_of); Points[6].y = (int)(0.0 * d_of + x_of);
- Points[7].x = (int)(-diagonal * d_of + x_of); Points[7].y = (int)(diagonal * d_of + x_of);
-
- // draw polygon
- dc.DrawPolygon(8, Points);
+ if (octagon)
+ DrawOctagon(&dc, p);
+ else
+ DrawDodecagon(&dc, p);
}
else
{
@@ -407,10 +460,6 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
dc.SetFont(small_font);
dc.SetTextForeground(0xC0C0C0);
- // label for sticks and stuff
- if (64 == bitmap.GetHeight())
- dc.DrawText(StrToWxStr(g->control_group->name).Upper(), 4, 2);
-
DrawControlGroupBox(dc, g);
// box outline
@@ -419,6 +468,10 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
+ // label for sticks and stuff
+ if (64 == bitmap.GetHeight())
+ dc.DrawText(StrToWxStr(g->control_group->name).Upper(), 4, 2);
+
dc.SelectObject(wxNullBitmap);
g->static_bitmap->SetBitmap(bitmap);
}