main.h

来自「<B>很多DirectX 9.0游戏编程源码例子</B>」· C头文件 代码 · 共 69 行

H
69
字号
//-----------------------------------------------------------------------------
// Name: DInput_Simple
//
// Description: Example code showing how to use DirectInput
//
// File Function: Header file for the program (main.h)
//
// Code: 
//		Copyright (c) 2002-2003 LostLogic Corporation. All rights reserved.
//
// Libraries Required:
//		dxguid.lib dinput8.lib
//
// Local Files Required:
//		main.cpp
//		main.h
//
// DX Files: 
//		Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#ifndef MAIN_H
#define MAIN_H

// Set the direct input version
#define DIRECTINPUT_VERSION 0x0800

#define STRICT
#include <windows.h>
#include <stdio.h>
#include <D3DX9.h>
#include <dinput.h>

// Keyboard buffer size
const int  KEYBOARD_BUFFERSIZE			= 10;

// Error codes
const int  INPUTERROR_SUCCESS			= 0;
const int  INPUTERROR_NODI				= 1;
const int  INPUTERROR_NOKEYBOARD		= 2;
const int  INPUTERROR_KEYBOARDEXISTS	= 3;
const int  INPUTERROR_DI_EXISTS			= 4;

// Device pointers
LPDIRECTINPUT8					pDI			= NULL;         
LPDIRECTINPUTDEVICE8			pKeyboard	= NULL; 

// Keyboard buffers
BYTE							diks[ 256 ][ KEYBOARD_BUFFERSIZE ];
BYTE							ascKeys[ 256 ][ KEYBOARD_BUFFERSIZE ];

// Keyboard layout
HKL								g_Layout;

// Program instance pointer
HINSTANCE						g_hInstance;

//-----------------------------------------------------------------------------
// Function headers
//-----------------------------------------------------------------------------
LRESULT WINAPI fnMessageProcessor( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
void vCleanup( void );
int	iInitDirectInput(void);
int iInitKeyboard(HWND hWnd);
BYTE Scan2Ascii(DWORD scancode);
int iReadKeyboard( void );

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?