#ifndef TEST_H#define TEST_H#include <d3dx11.h>#include <QtGui/QMainWindow>#include <QTimer>#include <xnamath.h>#include <dinput.h>#include "DIMPUT.h"#include <QLIST>struct ConstantBuffer{ XMMATRIX mWorld; // Матрица мира XMMATRIX mView; // Матрица вида XMMATRIX mProjection; // Матрица проекции};#ifndef SAFE_RELEASE#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } }#endifDEFINE_GUID(DIGUID, 0xd1e5da1b, 0x64dc, 0x41ae, 0xbc, 0xa9, 0x5a, 0xfc, 0xf9, 0x29, 0x77, 0xcc);enum { MOUSE_X, MOUSE_Y, MOUSE_L, MOUSE_R, MOUSE_C, NumEnum,};DIACTION action_[] ={ {VK_LEFT, DIKEYBOARD_LEFT,0,L"Влево"}, {MOUSE_Y, DIMOUSE_YAXIS, 0, L"Мышка по Y"}, {MOUSE_X, DIMOUSE_XAXIS, 0, L"Мышка по X"}, {MOUSE_L, DIMOUSE_BUTTON0, 0, L"Кнопка мыши левая"}, };typedef struct DeviceDI{ IDirectInputDevice8 *pDIDevice; bool Axsis; bool Mapped[ARRAYSIZE(action_)]; int Imput[ARRAYSIZE(action_)];} DeviceDI;class test : public QMainWindow{ Q_OBJECTpublic: test(QWidget *parent = 0, Qt::WFlags flags = 0); ~test(); bool getError(); void AddDevice(LPCDIDEVICEINSTANCE, LPDIRECTINPUTDEVICE8);private: BOOL InitializeDirect3d11App(); void ReleaseObjects(); bool InitScene(); void initImput(); //BOOL CALLBACK EnumDevices(LPCDIDEVICEINSTANCE pdInst, LPVOID pvRef);private slots: void DrawScene(); void PrintFPS();protected: virtual void keyPressEvent(QKeyEvent *); virtual void mouseMoveEvent(QMouseEvent*);private: float m; struct Vertex { XMFLOAT3 pos; XMFLOAT2 tex; Vertex(float x, float y, float z, float tx, float ty) : pos(x,y,z), tex(tx, ty){} }; int FPS; QTimer t; QTimer RenderTimer; bool error; IDXGISwapChain* SwapChain; ID3D11Device* Device; ID3D11DeviceContext* DeviceContext; ID3D11RenderTargetView* RenderTargetView; ID3D11Buffer* VertexBuffer; ID3D11Buffer* IndexBuffer; ID3D11VertexShader* VS; ID3D11PixelShader* PS; ID3D10Blob* VS_Buffer; ID3D10Blob* PS_Buffer; ID3D11InputLayout* vertLayout; ID3D11ShaderResourceView* colorMap_; ID3D11SamplerState* colorMapSampler_; D3D11_VIEWPORT viewport; ID3D11Buffer* g_pConstantBuffer; // Константный буфер ID3D11RasterizerState * RasterizerState; XMMATRIX g_World; // Матрица мира XMMATRIX g_View; // Матрица вида XMMATRIX g_Projection; // Матрица проекции IDirectInput8 * DirectInput; QList<DeviceDI> DevID;};#endif // TEST_H
C++ (Qt)// test.hDIACTION action_[]; // предварительное описание // test.cpp или в любом cppDIACTION action_[] = // полное описание{ {VK_LEFT, DIKEYBOARD_LEFT,0,L"Влево"},...};
file1.h:#ifndef FILE1_H.....#endiffile2.h:#ifndef FILE2_H#define FILE2_H#include "file1.hpp".....#endiffile3.h:#ifndef FILE3_H#define FILE3_H#include "file1.hpp".....#endiffile.cpp:#include "file1.h"#include "file2.h".....
fileN.cpp:#include "file1.h".....
C++ (Qt)// test.hstatic DIACTION action_[] = { {VK_LEFT, DIKEYBOARD_LEFT,0,L"Влево"},...};
C++ (Qt)// test.hstatic DIACTION action_[] =