Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #659 from Parlane/classic_controller_fix2
Classic controller fix
  • Loading branch information
delroth committed Jul 29, 2014
2 parents 9f86d3e + cee07ff commit 062bce8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.cpp
Expand Up @@ -92,8 +92,8 @@ void Classic::GetState(u8* const data)
double x, y;
m_left_stick->GetState(&x, &y);

ccdata->lx = (x * 0x1F) + 0x20;
ccdata->ly = (y * 0x1F) + 0x20;
ccdata->lx = Classic::LEFT_STICK_CENTER_X + (x * Classic::LEFT_STICK_RADIUS);
ccdata->ly = Classic::LEFT_STICK_CENTER_Y + (y * Classic::LEFT_STICK_RADIUS);
}

// right stick
Expand All @@ -102,8 +102,8 @@ void Classic::GetState(u8* const data)
u8 x_, y_;
m_right_stick->GetState(&x, &y);

x_ = (x * 0x1F) + 0x20;
y_ = (y * 0x1F) + 0x20;
x_ = Classic::RIGHT_STICK_CENTER_X + (x * Classic::RIGHT_STICK_RADIUS);
y_ = Classic::RIGHT_STICK_CENTER_Y + (y * Classic::RIGHT_STICK_RADIUS);

ccdata->rx1 = x_;
ccdata->rx2 = x_ >> 1;
Expand All @@ -117,8 +117,8 @@ void Classic::GetState(u8* const data)
u8 lt, rt;
m_triggers->GetState(&ccdata->bt, classic_trigger_bitmasks, trigs);

lt = trigs[0] * 0x1F;
rt = trigs[1] * 0x1F;
lt = trigs[0] * Classic::LEFT_TRIGGER_RANGE;
rt = trigs[1] * Classic::RIGHT_TRIGGER_RANGE;

ccdata->lt1 = lt;
ccdata->lt2 = lt >> 3;
Expand Down
11 changes: 11 additions & 0 deletions Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.h
Expand Up @@ -35,6 +35,17 @@ class Classic : public Attachment
PAD_UP = 0x0100,
};

static const u8 LEFT_STICK_CENTER_X = 0x20;
static const u8 LEFT_STICK_CENTER_Y = 0x20;
static const u8 LEFT_STICK_RADIUS = 0x1F;

static const u8 RIGHT_STICK_CENTER_X = 0x10;
static const u8 RIGHT_STICK_CENTER_Y = 0x10;
static const u8 RIGHT_STICK_RADIUS = 0x0F;

static const u8 LEFT_TRIGGER_RANGE = 0x1F;
static const u8 RIGHT_TRIGGER_RANGE = 0x1F;

private:
Buttons* m_buttons;
MixedTriggers* m_triggers;
Expand Down

0 comments on commit 062bce8

Please sign in to comment.