2013-04-18 03:43:35 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:43:35 +00:00
|
|
|
// Refer to the license.txt file included.
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <wx/bitmap.h>
|
|
|
|
#include <wx/brush.h>
|
|
|
|
#include <wx/colour.h>
|
|
|
|
#include <wx/dcmemory.h>
|
|
|
|
#include <wx/font.h>
|
|
|
|
#include <wx/notebook.h>
|
|
|
|
#include <wx/pen.h>
|
|
|
|
#include <wx/statbmp.h>
|
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/InputConfigDiag.h"
|
|
|
|
#include "DolphinWX/WxUtils.h"
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "InputCommon/ControllerEmu.h"
|
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
|
|
|
|
2013-07-14 22:38:57 +00:00
|
|
|
struct ShapePosition
|
|
|
|
{
|
|
|
|
double max;
|
|
|
|
double diag;
|
|
|
|
double box;
|
|
|
|
double scale;
|
|
|
|
|
|
|
|
double dz;
|
|
|
|
double range;
|
|
|
|
|
|
|
|
wxCoord offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
// regular octagon
|
2015-02-04 19:19:16 +00:00
|
|
|
static void DrawOctagon(wxDC* dc, ShapePosition p)
|
2013-07-14 22:38:57 +00:00
|
|
|
{
|
|
|
|
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
|
2015-02-04 19:19:16 +00:00
|
|
|
static void DrawDodecagon(wxDC* dc, ShapePosition p)
|
2013-07-14 22:38:57 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-07-11 11:57:52 +00:00
|
|
|
static void DrawCenteredRectangle(wxDC &dc, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
x -= w / 2;
|
|
|
|
y -= h / 2;
|
|
|
|
dc.DrawRectangle(x, y, w, h);
|
|
|
|
}
|
|
|
|
|
2014-07-11 12:43:00 +00:00
|
|
|
#define VIS_BITMAP_SIZE 64
|
|
|
|
|
|
|
|
#define VIS_NORMALIZE(a) ((a / 2.0) + 0.5)
|
|
|
|
#define VIS_COORD(a) ((VIS_NORMALIZE(a)) * VIS_BITMAP_SIZE)
|
|
|
|
|
2014-07-11 11:57:52 +00:00
|
|
|
#define COORD_VIS_SIZE 4
|
|
|
|
|
2014-08-11 17:43:26 +00:00
|
|
|
static void DrawCoordinate(wxDC &dc, ControlState x, ControlState y)
|
2014-07-11 11:57:52 +00:00
|
|
|
{
|
2014-07-11 12:43:00 +00:00
|
|
|
int xc = VIS_COORD(x);
|
|
|
|
int yc = VIS_COORD(y);
|
|
|
|
DrawCenteredRectangle(dc, xc, yc, COORD_VIS_SIZE, COORD_VIS_SIZE);
|
2014-07-11 11:57:52 +00:00
|
|
|
}
|
|
|
|
|
2015-02-04 19:19:16 +00:00
|
|
|
static void DrawButton(unsigned int* const bitmasks, unsigned int buttons, unsigned int n, wxDC& dc, ControlGroupBox* g, unsigned int row)
|
2015-01-17 00:16:15 +00:00
|
|
|
{
|
|
|
|
if (buttons & bitmasks[(row * 8) + n])
|
|
|
|
{
|
|
|
|
dc.SetBrush(*wxRED_BRUSH);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned char amt = 255 - g->control_group->controls[(row * 8) + n]->control_ref->State() * 128;
|
|
|
|
dc.SetBrush(wxBrush(wxColour(amt, amt, amt)));
|
|
|
|
}
|
2015-01-27 01:24:47 +00:00
|
|
|
dc.DrawRectangle(n * 12, (row == 0) ? 0 : (row * 11), 14, 12);
|
2015-01-17 00:16:15 +00:00
|
|
|
|
|
|
|
// text
|
|
|
|
const std::string name = g->control_group->controls[(row * 8) + n]->name;
|
|
|
|
// bit of hax so ZL, ZR show up as L, R
|
2015-01-27 01:24:47 +00:00
|
|
|
dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n * 12 + 2, 1 + ((row == 0) ? 0 : (row * 11)));
|
2015-01-17 00:16:15 +00:00
|
|
|
}
|
|
|
|
|
2014-07-11 11:34:34 +00:00
|
|
|
static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
|
|
|
|
{
|
|
|
|
switch (g->control_group->type)
|
|
|
|
{
|
|
|
|
case GROUP_TYPE_TILT :
|
|
|
|
case GROUP_TYPE_STICK :
|
|
|
|
case GROUP_TYPE_CURSOR :
|
|
|
|
{
|
|
|
|
// this is starting to be a mess combining all these in one case
|
|
|
|
|
2014-08-11 17:43:26 +00:00
|
|
|
ControlState x = 0, y = 0, z = 0;
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
switch (g->control_group->type)
|
|
|
|
{
|
|
|
|
case GROUP_TYPE_STICK :
|
2014-07-11 11:18:21 +00:00
|
|
|
((ControllerEmu::AnalogStick*)g->control_group)->GetState(&x, &y);
|
2014-07-11 11:34:34 +00:00
|
|
|
break;
|
|
|
|
case GROUP_TYPE_TILT :
|
2014-07-11 11:18:21 +00:00
|
|
|
((ControllerEmu::Tilt*)g->control_group)->GetState(&x, &y);
|
2014-07-11 11:34:34 +00:00
|
|
|
break;
|
|
|
|
case GROUP_TYPE_CURSOR :
|
|
|
|
((ControllerEmu::Cursor*)g->control_group)->GetState(&x, &y, &z);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ir cursor forward movement
|
|
|
|
if (GROUP_TYPE_CURSOR == g->control_group->type)
|
|
|
|
{
|
|
|
|
if (z)
|
|
|
|
{
|
|
|
|
dc.SetPen(*wxRED_PEN);
|
|
|
|
dc.SetBrush(*wxRED_BRUSH);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dc.SetPen(*wxGREY_PEN);
|
|
|
|
dc.SetBrush(*wxGREY_BRUSH);
|
|
|
|
}
|
|
|
|
dc.DrawRectangle(0, 31 - z*31, 64, 2);
|
|
|
|
}
|
|
|
|
|
2013-07-14 22:38:57 +00:00
|
|
|
// input zone
|
2014-07-11 11:34:34 +00:00
|
|
|
dc.SetPen(*wxLIGHT_GREY_PEN);
|
|
|
|
dc.SetBrush(*wxWHITE_BRUSH);
|
|
|
|
if (GROUP_TYPE_STICK == g->control_group->type)
|
|
|
|
{
|
|
|
|
// outline and fill colors
|
|
|
|
wxBrush LightGrayBrush("#dddddd");
|
|
|
|
wxPen LightGrayPen("#bfbfbf");
|
|
|
|
dc.SetBrush(LightGrayBrush);
|
|
|
|
dc.SetPen(LightGrayPen);
|
|
|
|
|
2013-07-14 22:38:57 +00:00
|
|
|
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;
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
if (g->control_group->name == "Main Stick")
|
|
|
|
{
|
2013-07-14 22:38:57 +00:00
|
|
|
p.max = 87 * p.scale;
|
|
|
|
p.diag = 55 * p.scale;
|
2014-07-11 11:34:34 +00:00
|
|
|
}
|
|
|
|
else if (g->control_group->name == "C-Stick")
|
|
|
|
{
|
2013-07-14 22:38:57 +00:00
|
|
|
p.max = 74 * p.scale;
|
|
|
|
p.diag = 46 * p.scale;
|
2014-07-11 11:34:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-14 22:38:57 +00:00
|
|
|
p.scale = 1;
|
|
|
|
p.max = 32;
|
|
|
|
octagon = true;
|
2014-07-11 11:34:34 +00:00
|
|
|
}
|
|
|
|
|
2013-07-14 22:38:57 +00:00
|
|
|
if (octagon)
|
|
|
|
DrawOctagon(&dc, p);
|
|
|
|
else
|
|
|
|
DrawDodecagon(&dc, p);
|
2014-07-11 11:34:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dc.DrawRectangle(16, 16, 32, 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GROUP_TYPE_CURSOR != g->control_group->type)
|
|
|
|
{
|
|
|
|
// deadzone circle
|
|
|
|
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
|
|
|
dc.DrawCircle(32, 32, g->control_group->settings[SETTING_DEADZONE]->value * 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// raw dot
|
2014-07-11 12:43:00 +00:00
|
|
|
{
|
2014-08-11 17:43:26 +00:00
|
|
|
ControlState xx, yy;
|
2014-07-11 12:43:00 +00:00
|
|
|
xx = g->control_group->controls[3]->control_ref->State();
|
|
|
|
xx -= g->control_group->controls[2]->control_ref->State();
|
|
|
|
yy = g->control_group->controls[1]->control_ref->State();
|
|
|
|
yy -= g->control_group->controls[0]->control_ref->State();
|
|
|
|
|
2014-07-11 11:34:34 +00:00
|
|
|
dc.SetPen(*wxGREY_PEN);
|
|
|
|
dc.SetBrush(*wxGREY_BRUSH);
|
2014-07-11 11:57:52 +00:00
|
|
|
DrawCoordinate(dc, xx, yy);
|
2014-07-11 12:43:00 +00:00
|
|
|
}
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
// adjusted dot
|
2014-11-11 18:41:38 +00:00
|
|
|
if (x != 0 || y != 0)
|
2014-07-11 11:34:34 +00:00
|
|
|
{
|
|
|
|
dc.SetPen(*wxRED_PEN);
|
|
|
|
dc.SetBrush(*wxRED_BRUSH);
|
2014-07-11 11:57:52 +00:00
|
|
|
// XXX: The adjusted values flip the Y axis to be in the format
|
|
|
|
// the Wii expects. Should this be in WiimoteEmu.cpp instead?
|
2014-07-11 12:43:00 +00:00
|
|
|
DrawCoordinate(dc, x, -y);
|
2014-07-11 11:34:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GROUP_TYPE_FORCE :
|
|
|
|
{
|
2014-08-11 17:43:26 +00:00
|
|
|
ControlState raw_dot[3];
|
|
|
|
ControlState adj_dot[3];
|
|
|
|
const ControlState deadzone = g->control_group->settings[0]->value;
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
// adjusted
|
2014-07-11 11:18:21 +00:00
|
|
|
((ControllerEmu::Force*)g->control_group)->GetState(adj_dot);
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
// raw
|
|
|
|
for (unsigned int i=0; i<3; ++i)
|
|
|
|
{
|
2014-07-11 12:37:48 +00:00
|
|
|
raw_dot[i] = (g->control_group->controls[i*2 + 1]->control_ref->State() -
|
|
|
|
g->control_group->controls[i*2]->control_ref->State());
|
2014-07-11 11:34:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// deadzone rect for forward/backward visual
|
|
|
|
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
|
|
|
dc.SetPen(*wxLIGHT_GREY_PEN);
|
2014-07-11 12:37:48 +00:00
|
|
|
int deadzone_height = deadzone * VIS_BITMAP_SIZE;
|
|
|
|
DrawCenteredRectangle(dc, 0, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE, deadzone_height);
|
|
|
|
|
|
|
|
#define LINE_HEIGHT 2
|
|
|
|
int line_y;
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
// raw forward/background line
|
|
|
|
dc.SetPen(*wxGREY_PEN);
|
|
|
|
dc.SetBrush(*wxGREY_BRUSH);
|
2014-07-11 12:37:48 +00:00
|
|
|
line_y = VIS_COORD(raw_dot[2]);
|
|
|
|
DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, line_y, VIS_BITMAP_SIZE, LINE_HEIGHT);
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
// adjusted forward/background line
|
2014-07-11 12:37:48 +00:00
|
|
|
if (adj_dot[2] != 0.0)
|
2014-07-11 11:34:34 +00:00
|
|
|
{
|
|
|
|
dc.SetPen(*wxRED_PEN);
|
|
|
|
dc.SetBrush(*wxRED_BRUSH);
|
2014-07-11 12:37:48 +00:00
|
|
|
line_y = VIS_COORD(adj_dot[2]);
|
|
|
|
DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, line_y, VIS_BITMAP_SIZE, LINE_HEIGHT);
|
2014-07-11 11:34:34 +00:00
|
|
|
}
|
|
|
|
|
2014-07-11 12:37:48 +00:00
|
|
|
#define DEADZONE_RECT_SIZE 32
|
|
|
|
|
|
|
|
// empty deadzone square
|
2014-07-11 11:34:34 +00:00
|
|
|
dc.SetBrush(*wxWHITE_BRUSH);
|
|
|
|
dc.SetPen(*wxLIGHT_GREY_PEN);
|
2014-07-11 12:37:48 +00:00
|
|
|
DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE / 2, DEADZONE_RECT_SIZE, DEADZONE_RECT_SIZE);
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
// deadzone square
|
|
|
|
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
2014-07-11 12:37:48 +00:00
|
|
|
int dz_size = (deadzone * DEADZONE_RECT_SIZE);
|
|
|
|
DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE / 2, dz_size, dz_size);
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
// raw dot
|
|
|
|
dc.SetPen(*wxGREY_PEN);
|
|
|
|
dc.SetBrush(*wxGREY_BRUSH);
|
2014-07-11 12:37:48 +00:00
|
|
|
DrawCoordinate(dc, raw_dot[1], raw_dot[0]);
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
// adjusted dot
|
2014-07-11 12:37:48 +00:00
|
|
|
if (adj_dot[1] != 0 && adj_dot[0] != 0)
|
2014-07-11 11:34:34 +00:00
|
|
|
{
|
|
|
|
dc.SetPen(*wxRED_PEN);
|
|
|
|
dc.SetBrush(*wxRED_BRUSH);
|
2014-07-11 12:37:48 +00:00
|
|
|
DrawCoordinate(dc, adj_dot[1], adj_dot[0]);
|
2014-07-11 11:34:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GROUP_TYPE_BUTTONS :
|
|
|
|
{
|
2015-01-17 00:16:15 +00:00
|
|
|
unsigned int button_count = ((unsigned int)g->control_group->controls.size());
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
// draw the shit
|
|
|
|
dc.SetPen(*wxGREY_PEN);
|
|
|
|
|
2015-01-17 00:16:15 +00:00
|
|
|
unsigned int* const bitmasks = new unsigned int[button_count];
|
2014-07-11 11:34:34 +00:00
|
|
|
for (unsigned int n = 0; n<button_count; ++n)
|
|
|
|
bitmasks[n] = (1 << n);
|
|
|
|
|
|
|
|
unsigned int buttons = 0;
|
|
|
|
((ControllerEmu::Buttons*)g->control_group)->GetState(&buttons, bitmasks);
|
|
|
|
|
2015-01-17 00:16:15 +00:00
|
|
|
// Draw buttons in rows of 8
|
|
|
|
for (unsigned int row = 0; row < ceil((float)button_count / 8.0f); row++)
|
2014-07-11 11:34:34 +00:00
|
|
|
{
|
2015-01-17 00:16:15 +00:00
|
|
|
unsigned int buttons_to_draw = 8;
|
|
|
|
if ((button_count - row * 8) <= 8)
|
|
|
|
buttons_to_draw = button_count - row * 8;
|
|
|
|
|
|
|
|
for (unsigned int n = 0; n < buttons_to_draw; ++n)
|
2014-07-11 11:34:34 +00:00
|
|
|
{
|
2015-01-17 00:16:15 +00:00
|
|
|
DrawButton(bitmasks, buttons, n, dc, g, row);
|
2014-07-11 11:34:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] bitmasks;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GROUP_TYPE_TRIGGERS :
|
|
|
|
{
|
|
|
|
const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size()));
|
|
|
|
|
|
|
|
// draw the shit
|
|
|
|
dc.SetPen(*wxGREY_PEN);
|
|
|
|
ControlState deadzone = g->control_group->settings[0]->value;
|
|
|
|
|
2014-08-11 17:43:26 +00:00
|
|
|
ControlState* const trigs = new ControlState[trigger_count];
|
2014-07-11 11:18:21 +00:00
|
|
|
((ControllerEmu::Triggers*)g->control_group)->GetState(trigs);
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
for (unsigned int n = 0; n < trigger_count; ++n)
|
|
|
|
{
|
|
|
|
ControlState trig_r = g->control_group->controls[n]->control_ref->State();
|
|
|
|
|
|
|
|
// outline
|
|
|
|
dc.SetPen(*wxGREY_PEN);
|
|
|
|
dc.SetBrush(*wxWHITE_BRUSH);
|
|
|
|
dc.DrawRectangle(0, n*12, 64, 14);
|
|
|
|
|
|
|
|
// raw
|
|
|
|
dc.SetBrush(*wxGREY_BRUSH);
|
|
|
|
dc.DrawRectangle(0, n*12, trig_r*64, 14);
|
|
|
|
|
|
|
|
// deadzone affected
|
|
|
|
dc.SetBrush(*wxRED_BRUSH);
|
2014-07-11 11:18:21 +00:00
|
|
|
dc.DrawRectangle(0, n*12, trigs[n]*64, 14);
|
2014-07-11 11:34:34 +00:00
|
|
|
|
|
|
|
// text
|
|
|
|
dc.DrawText(StrToWxStr(g->control_group->controls[n]->name), 3, n*12 + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] trigs;
|
|
|
|
|
|
|
|
// deadzone box
|
|
|
|
dc.SetPen(*wxLIGHT_GREY_PEN);
|
|
|
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
|
|
|
dc.DrawRectangle(0, 0, deadzone*64, trigger_count*14);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GROUP_TYPE_MIXED_TRIGGERS :
|
|
|
|
{
|
|
|
|
const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size() / 2));
|
|
|
|
|
|
|
|
// draw the shit
|
|
|
|
dc.SetPen(*wxGREY_PEN);
|
|
|
|
ControlState thresh = g->control_group->settings[0]->value;
|
|
|
|
|
|
|
|
for (unsigned int n = 0; n < trigger_count; ++n)
|
|
|
|
{
|
|
|
|
dc.SetBrush(*wxRED_BRUSH);
|
|
|
|
ControlState trig_d = g->control_group->controls[n]->control_ref->State();
|
|
|
|
|
|
|
|
ControlState trig_a = trig_d > thresh ? 1
|
|
|
|
: g->control_group->controls[n+trigger_count]->control_ref->State();
|
|
|
|
|
|
|
|
dc.DrawRectangle(0, n*12, 64+20, 14);
|
|
|
|
if (trig_d <= thresh)
|
|
|
|
dc.SetBrush(*wxWHITE_BRUSH);
|
|
|
|
dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
|
|
|
|
dc.DrawRectangle(64, n*12, 32, 14);
|
|
|
|
|
|
|
|
// text
|
|
|
|
dc.DrawText(StrToWxStr(g->control_group->controls[n+trigger_count]->name), 3, n*12 + 1);
|
|
|
|
dc.DrawText(StrToWxStr(std::string(1, g->control_group->controls[n]->name[0])), 64 + 3, n*12 + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// threshold box
|
|
|
|
dc.SetPen(*wxLIGHT_GREY_PEN);
|
|
|
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
|
|
|
dc.DrawRectangle(thresh*64, 0, 128, trigger_count*14);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GROUP_TYPE_SLIDER:
|
|
|
|
{
|
|
|
|
const ControlState deadzone = g->control_group->settings[0]->value;
|
|
|
|
|
|
|
|
ControlState state = g->control_group->controls[1]->control_ref->State() - g->control_group->controls[0]->control_ref->State();
|
|
|
|
dc.SetPen(*wxGREY_PEN);
|
|
|
|
dc.SetBrush(*wxGREY_BRUSH);
|
|
|
|
dc.DrawRectangle(31 + state * 30, 0, 2, 14);
|
|
|
|
|
2014-08-11 17:43:26 +00:00
|
|
|
ControlState adj_state;
|
2014-07-11 11:18:21 +00:00
|
|
|
((ControllerEmu::Slider*)g->control_group)->GetState(&adj_state);
|
2014-07-11 11:34:34 +00:00
|
|
|
if (state)
|
|
|
|
{
|
|
|
|
dc.SetPen(*wxRED_PEN);
|
|
|
|
dc.SetBrush(*wxRED_BRUSH);
|
2014-07-11 11:18:21 +00:00
|
|
|
dc.DrawRectangle(31 + adj_state * 30, 0, 2, 14);
|
2014-07-11 11:34:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// deadzone box
|
|
|
|
dc.SetPen(*wxLIGHT_GREY_PEN);
|
|
|
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
|
|
|
dc.DrawRectangle(32 - deadzone * 32, 0, deadzone * 64, 14);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-12 18:45:39 +00:00
|
|
|
void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-07-10 06:48:24 +00:00
|
|
|
wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
g_controller_interface.UpdateInput();
|
2011-03-05 06:11:26 +00:00
|
|
|
|
2010-10-09 07:24:33 +00:00
|
|
|
GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage(m_pad_notebook->GetSelection());
|
|
|
|
|
2014-03-03 05:25:15 +00:00
|
|
|
for (ControlGroupBox* g : current_page->control_groups)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-04-29 18:51:04 +00:00
|
|
|
// if this control group has a bitmap
|
2014-03-03 05:25:15 +00:00
|
|
|
if (g->static_bitmap)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-04-29 18:51:04 +00:00
|
|
|
wxMemoryDC dc;
|
2014-03-03 05:25:15 +00:00
|
|
|
wxBitmap bitmap(g->static_bitmap->GetBitmap());
|
2010-04-29 18:51:04 +00:00
|
|
|
dc.SelectObject(bitmap);
|
|
|
|
dc.Clear();
|
|
|
|
|
2010-07-10 06:48:24 +00:00
|
|
|
dc.SetFont(small_font);
|
|
|
|
dc.SetTextForeground(0xC0C0C0);
|
|
|
|
|
2014-07-11 11:34:34 +00:00
|
|
|
DrawControlGroupBox(dc, g);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-04-29 18:51:04 +00:00
|
|
|
// box outline
|
|
|
|
// Windows XP color
|
2014-05-17 17:17:28 +00:00
|
|
|
dc.SetPen(wxPen("#7f9db9"));
|
2010-04-29 18:51:04 +00:00
|
|
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
|
|
|
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
|
|
|
|
|
2013-07-14 22:38:57 +00:00
|
|
|
// label for sticks and stuff
|
|
|
|
if (64 == bitmap.GetHeight())
|
|
|
|
dc.DrawText(StrToWxStr(g->control_group->name).Upper(), 4, 2);
|
|
|
|
|
2010-04-29 18:51:04 +00:00
|
|
|
dc.SelectObject(wxNullBitmap);
|
2014-03-03 05:25:15 +00:00
|
|
|
g->static_bitmap->SetBitmap(bitmap);
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|