Skip to content

Commit 400aced

Browse files
committed
add files from old project. No more compile error (except have to comment out bindale attribute of CheatData.cpp). Still lots of compile error.
1 parent 6e40ea4 commit 400aced

File tree

150 files changed

+65734
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+65734
-27
lines changed

CXBOXController.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "CXBOXController.h"
2+
3+
namespace VBA10
4+
{
5+
CXBOXController::CXBOXController(int playerNumber)
6+
: controllerNumber(playerNumber - 1)
7+
{ }
8+
9+
XINPUT_STATE CXBOXController::GetState(void)
10+
{
11+
ZeroMemory(&this->state, sizeof(XINPUT_STATE));
12+
XInputGetState(this->controllerNumber, &this->state);
13+
14+
return this->state;
15+
}
16+
17+
bool CXBOXController::IsConnected(void)
18+
{
19+
//ZeroMemory(&this->state, sizeof(XINPUT_STATE));
20+
21+
DWORD result = XInputGetState(this->controllerNumber, &this->state);
22+
23+
return (result == ERROR_SUCCESS);
24+
}
25+
26+
void CXBOXController::Vibrate(int leftVal, int rightVal)
27+
{
28+
XINPUT_VIBRATION vibration;
29+
ZeroMemory(&vibration, sizeof(XINPUT_VIBRATION));
30+
31+
vibration.wLeftMotorSpeed = leftVal;
32+
vibration.wRightMotorSpeed = rightVal;
33+
34+
XInputSetState(this->controllerNumber, &vibration);
35+
}
36+
}

CXBOXController.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef CXBOXCONTROLLER_H_
2+
#define CXBOXCONTROLLER_H_
3+
4+
#include <Windows.h>
5+
#include <Xinput.h>
6+
7+
namespace VBA10
8+
{
9+
class CXBOXController
10+
{
11+
private:
12+
XINPUT_STATE state;
13+
int controllerNumber;
14+
15+
public:
16+
CXBOXController (int playerNumber);
17+
XINPUT_STATE GetState(void);
18+
bool IsConnected();
19+
void Vibrate(int leftVal = 0, int rightVal = 0);
20+
};
21+
}
22+
23+
#endif

CheatData.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "CheatData.h"

CheatData.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef CHEATDATA_H_
2+
#define CHEATDATA_H_
3+
4+
namespace VBA10
5+
{
6+
//[Windows::UI::Xaml::Data::BindableAttribute]
7+
public ref class CheatData sealed
8+
{
9+
public:
10+
property Platform::String ^CheatCode;
11+
property Platform::String ^Description;
12+
property bool Enabled;
13+
};
14+
}
15+
16+
#endif

Color.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#ifndef COLOR_H_
2+
#define COLOR_H_
3+
4+
namespace Engine
5+
{
6+
struct Color
7+
{
8+
union
9+
{
10+
struct
11+
{
12+
float R;
13+
float G;
14+
float B;
15+
float A;
16+
};
17+
float RGBA[4];
18+
};
19+
20+
public:
21+
Color()
22+
: R(0.0f), G(0.0f), B(0.0f), A(0.0f)
23+
{ }
24+
25+
Color(float r, float g, float b, float a)
26+
: R(r), B(b), G(g), A(a)
27+
{ }
28+
};
29+
30+
struct Color4i
31+
{
32+
union
33+
{
34+
struct
35+
{
36+
UCHAR R;
37+
UCHAR G;
38+
UCHAR B;
39+
UCHAR A;
40+
};
41+
UINT RGBA;
42+
UCHAR Array[4];
43+
};
44+
};
45+
}
46+
47+
#endif

ControllerInput.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include "ControllerInput.h"
2+
3+
namespace VBA10
4+
{
5+
ControllerInput::ControllerInput(int index)
6+
: xboxPad(new CXBOXController(index))
7+
{
8+
ZeroMemory(&state, sizeof(ControllerState));
9+
}
10+
11+
ControllerInput::~ControllerInput(void)
12+
{
13+
delete this->xboxPad;
14+
}
15+
16+
const ControllerState *ControllerInput::GetControllerState(void)
17+
{
18+
return &this->state;
19+
}
20+
21+
void ControllerInput::Update(void)
22+
{
23+
if(this->xboxPad->IsConnected())
24+
{
25+
XINPUT_STATE state = this->xboxPad->GetState();
26+
27+
this->state.LeftPressed = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) || (state.Gamepad.sThumbLX < (-XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)));
28+
this->state.RightPressed = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) || (state.Gamepad.sThumbLX > (XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)));
29+
this->state.UpPressed = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) || (state.Gamepad.sThumbLY > (XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)));
30+
this->state.DownPressed = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) || (state.Gamepad.sThumbLY < (-XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)));
31+
32+
this->state.StartPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_START);
33+
this->state.SelectPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK);
34+
35+
this->state.APressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_B);
36+
this->state.BPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_A);
37+
this->state.YPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_X);
38+
this->state.XPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_Y);
39+
this->state.LPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER);
40+
this->state.RPressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER);
41+
42+
this->state.TurboPressed = ((state.Gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD) || (state.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD));
43+
this->state.TurboTogglePressed = this->state.XPressed || this->state.YPressed;
44+
}else
45+
{
46+
ZeroMemory(&this->state, sizeof(ControllerState));
47+
}
48+
}
49+
50+
}

ControllerInput.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
3+
#include "Input.h"
4+
#include "CXBOXController.h"
5+
#include "EmulatorInput.h"
6+
7+
namespace VBA10
8+
{
9+
class ControllerInput
10+
: public EmulatorInput
11+
{
12+
public:
13+
ControllerInput(int index);
14+
~ControllerInput(void);
15+
16+
const ControllerState *GetControllerState(void);
17+
void Update(void);
18+
19+
private:
20+
ControllerState state;
21+
CXBOXController *xboxPad;
22+
};
23+
}

0 commit comments

Comments
 (0)