Skip to content

Commit

Permalink
JoystickDisplay.cs now checks for d-pad
Browse files Browse the repository at this point in the history
D-Pad input is displayed as regular joystick input.
  • Loading branch information
TurtleMan64 authored Aug 17, 2017
1 parent 42ca485 commit da4abda
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions JoystickDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ public void setControllerDataSA2(int buttons, int newX, int newY)

joyX = newX;
joyY = newY;

//D-Pad
int up = buttons & 8;
int down = buttons & 4;
int left = buttons & 1;
int right = buttons & 2;

if (right != 0)
{
joyX = 127;
}
else if (left != 0)
{
joyX = -128;
}

if (up != 0)
{
joyY = 127;
}
else if (down != 0)
{
joyY = -128;
}
}

public void setControllerDataSADX(int buttons, int newX, int newY)
Expand All @@ -84,6 +108,30 @@ public void setControllerDataSADX(int buttons, int newX, int newY)

joyX = newX;
joyY = newY;

//D-Pad
int up = buttons & 16;
int down = buttons & 32;
int left = buttons & 64;
int right = buttons & 128;

if (right != 0)
{
joyX = 127;
}
else if (left != 0)
{
joyX = -128;
}

if (up != 0)
{
joyY = 127;
}
else if (down != 0)
{
joyY = -128;
}
}

protected override void OnPaint(PaintEventArgs e)
Expand Down

0 comments on commit da4abda

Please sign in to comment.