#pragma once
using namespace System;
using namespace System::ComponentModel;
#include "Device.h"
#include "ActionMap.h"
namespace Sunlight
{
namespace DirectX
{
namespace Input
{
__gc public class DirectInputEventArgs : public EventArgs
{
public:
DirectInputEventArgs(int ID, int Data)
{
this->ID = ID;
this->AxisPosition = Data;
ButtonPressed = (Data & 0x80) ? true : false;
}
int ID;
int AxisPosition;
bool ButtonPressed;
};
__gc public class DirectInput
{
protected:
IDirectInput8 __nogc *m_pDI;
DIACTION __nogc *m_pActions;
DIACTIONFORMAT m_diaf;
Collections::ArrayList *m_pDeviceArray;
bool m_bCreated;
System::Windows::Forms::Form *m_pParentWindow;
virtual void EnumDevices();
virtual void BuildDIAF();
void OnFormActivated(Object *sender, EventArgs *e);
void OnFormDeactivated(Object *sender, EventArgs *e);
void Create();
public:
__delegate bool DIEnumDevicesBySemanticsCallbackDelegate(int lpddi, int lpdid, int dwFlags, int dwRemaining, int pvRef);
bool EnumDevicesBySemanticsCallback(int nddi, int ndid, int dwFlags, int dwRemaining, int pvRef);
__delegate void DIConfigureDevicesCallbackDelegate(int lpDDSTarget, int pvRef);
void ConfigureDevicesCallback(int lpDDSTarget, int pvRef);
public:
__gc class Device
{
public:
Device(IDirectInputDevice8 __nogc *pDevice)
{
m_pDevice = pDevice;
m_pDevice->AddRef();
}
~Device()
{
m_pDevice->Release();
}
IDirectInputDevice8 __nogc *m_pDevice;
};
public:
DirectInput();
~DirectInput();
void Acquire();
void Unacquire();
void Check();
void Configure();
void Display();
Guid AppID;
Genres Genre;
String *ActionMapName;
__property System::Windows::Forms::Form *get_ParentWindow();
__property void set_ParentWindow(System::Windows::Forms::Form *pParentWindow);
Sunlight::DirectX::Graphics::Device *Direct3DDevice;
__delegate void ActionEventHandler(DirectInput *sender, DirectInputEventArgs *args);
__event ActionEventHandler *Action;
ActionMap *Actions;
};
}
}
}