`
黑色杰克史密斯
  • 浏览: 16251 次
社区版块
存档分类
最新评论

Dinput8 杂

    博客分类:
  • n/a
 
阅读更多
10 12 00 00             _c_rgodfDIKeyboard dd offset _GUID_Key  ; DATA XREF: .rdata:00000200o
.data:00000208 00                                      db    0
.data:00000209 00                                      db    0
.data:0000020A 00                                      db    0
.data:0000020B 00                                      db    0
.data:0000020C 0C                                      db  0Ch
.data:0000020D 00                                      db    0
.data:0000020E 00                                      db    0
.data:0000020F 80                                      db  80h ; €
.data:00000210 00                                      db    0
.data:00000211 00                                      db    0
.data:00000212 00                                      db    0
.data:00000213 00                                      db    0

.rdata:000001EC 18                      _c_dfDIKeyboard db  18h
.rdata:000001ED 00                                      db    0
.rdata:000001EE 00                                      db    0
.rdata:000001EF 00                                      db    0
.rdata:000001F0 10                                      db  10h
.rdata:000001F1 00                                      db    0
.rdata:000001F2 00                                      db    0
.rdata:000001F3 00                                      db    0
.rdata:000001F4 02                                      db    2
.rdata:000001F5 00                                      db    0
.rdata:000001F6 00                                      db    0
.rdata:000001F7 00                                      db    0
.rdata:000001F8 00                                      db    0
.rdata:000001F9 01                                      db    1
.rdata:000001FA 00                                      db    0
.rdata:000001FB 00                                      db    0
.rdata:000001FC 00                                      db    0
.rdata:000001FD 01                                      db    1
.rdata:000001FE 00                                      db    0
.rdata:000001FF 00                                      db    0
.rdata:00000200 04 02 00 00                             dd offset _c_rgodfDIKeyboard

const GUID GUID_Key =         {0x55728220, 0xD33C, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};

#include <windows.h>
#include <dinput.h>

#define INPUT  __declspec(dllimport)
#define OUTPUT __declspec(dllexport)

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

UCHAR HitFlag[256] = {0};
UCHAR KeyArry[256] = {0};

HWND main_window_handle = nullptr;

HINSTANCE main_instance_handle = nullptr;

LPDIRECTINPUT8        lpdi      = nullptr;
LPDIRECTINPUTDEVICE8  lpdikey   = nullptr;
LPDIRECTINPUTDEVICE8  lpdimouse = nullptr;
LPDIRECTINPUTDEVICE8  lpdijoy   = nullptr;

EXTERN_C OUTPUT BOOL CDECL InitInput(HWND hWnd, HINSTANCE hInst)
{
main_window_handle   = hWnd;
main_instance_handle = hInst;

return SUCCEEDED(DirectInput8Create (hInst,
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(void **)&lpdi,
nullptr));
}

EXTERN_C OUTPUT BOOL CDECL InitKeyBoard(DWORD dwFlags)
{
BOOL val = 0;

val |= lpdi->CreateDevice (GUID_SysKeyboard, &lpdikey, nullptr);
val |= lpdikey->SetCooperativeLevel (main_window_handle, dwFlags);
val |= lpdikey->SetDataFormat(&c_dfDIKeyboard);
val |= lpdikey->Acquire();

return !val;
}

EXTERN_C OUTPUT BOOL CDECL GetKeyUp(DWORD KeyIndex)
{
// if(lpdikey->GetDeviceState(256, (LPVOID)KeyArry) != DIERR_INPUTLOST) {
lpdikey->GetDeviceState(256, (LPVOID)KeyArry);
__asm cmp eax, 8007001Eh // DIERR_INPUTLOST
__asm jnz most_hit_branch

if (lpdikey->Acquire() != S_OK) {
__asm int 3
} return lpdikey->GetDeviceState(256, (LPVOID)KeyArry);
__asm align 16
most_hit_branch:
UCHAR u8Temp;
  u8Temp= HitFlag[KeyIndex];

HitFlag[KeyIndex] = KeyArry[KeyIndex] | ((0x80^HitFlag[KeyIndex]) & HitFlag[KeyIndex]);

return ((0x80 ^ KeyArry[KeyIndex]) & u8Temp);
// }
// else {
// if (lpdikey->Acquire() != S_OK) {
// __asm int 3
// } lpdikey->GetDeviceState(256, (LPVOID)KeyArry);
// }
// return 233;
/*
if(lpdikey->GetDeviceState(256, (LPVOID)KeyArry)==DIERR_INPUTLOST)
{
lpdikey->Acquire();
}
if (KeyArry[KeyIndex]  )
{
HitFlag[KeyIndex]=0x80;
return FALSE;
}
else if (HitFlag[KeyIndex] == 0x80)
{
HitFlag[KeyIndex] = 0;
return TRUE;
}
else
return FALSE;*/
}

EXTERN_C OUTPUT BOOL CDECL GetKeyDown(DWORD KeyIndex)
{
// if(lpdikey->GetDeviceState(256, (LPVOID)KeyArry) != DIERR_INPUTLOST) {
lpdikey->GetDeviceState(256, (LPVOID)KeyArry);
__asm cmp eax, 8007001Eh
__asm jnz most_hit_branch

if (lpdikey->Acquire() != S_OK) {
__asm int 3
} return lpdikey->GetDeviceState(256, (LPVOID)KeyArry);
__asm align 16
most_hit_branch:
HitFlag[KeyIndex] |= KeyArry[KeyIndex];
  return KeyArry[KeyIndex];
//} else {
// if (lpdikey->Acquire() != S_OK) {
//__asm int 3
// } lpdikey->GetDeviceState(256, (LPVOID)KeyArry);
//} return 233;
}

EXTERN_C OUTPUT BOOL CDECL ShutDownInput ()
{
BOOL val = 0;

if(lpdikey != nullptr)
val |= lpdikey->Unacquire()   | lpdikey->Release();

if(lpdimouse != nullptr)
val |= lpdimouse->Unacquire() | lpdimouse->Release();

if(lpdijoy != nullptr)
val |= lpdijoy->Unacquire()   | lpdijoy->Release();

if(lpdikey != nullptr)
val |= lpdi->Release();

return !val;
}

EXTERN_C OUTPUT BOOL CDECL InitMouse(DWORD KeyIndex)
{
return 0;
}

EXTERN_C OUTPUT BOOL CDECL InitJoy(HWND hWnd, HINSTANCE hInst)
{
return 0;
}
分享到:
评论

相关推荐

    DINPUT8.DLL修复

    **DINPUT8.DLL**是DirectInput 8的一个动态链接库文件,它是Microsoft DirectX的一部分,主要用于游戏和其他应用程序的输入设备管理。DirectInput是Windows平台上一个重要的API(应用程序接口),它允许开发者直接...

    dinput8.dll

    **DirectX与dinput8.dll** DirectX是由微软开发的一套用于Windows操作系统的应用程序接口(API),主要用于多媒体、游戏开发和图形渲染。它包含了多个子组件,如Direct3D、DirectDraw、DirectSound、DirectInput等...

    dinput.h头文件

    头文件 头文件dinput.h

    dinput8.lib

    directx 库,必不可少,给缺少该资源的朋友一些帮助吧

    dinput8.dll.mui

    dinput8.dll

    dinput.lib

    解决报错 unresolved external symbol _DirectDrawCreateEx@16 的一个依赖库

    dinput.dll

    dinput

    dinput.dll.mui

    dinput.dll

    Windows平台下使用DirectX(DirectInput8)进行Joystick编程

    在Windows平台下使用DirectInput8接口,对joystick进行编程。 共2个文件:《DirectInput8开发手册》和Joystick.cpp(代码) 编译器:Visual Studio 2017 主要包含头文件: #include &lt;dinput.h&gt; #include &lt;dinputd.h&gt;

    dx ACE:dinput 和 xinput 包装器,用于调节游戏设备的输入-开源

    1. **dinput8.dll**:这是DirectInput的动态链接库文件,是dx ACE实现其功能的核心部分。它允许dx ACE与游戏中的DirectInput接口进行交互,读取和修改控制器输入数据。 2. **xinput1_3.dll**:这是XInput的动态链接...

    DirectInput8

    DirectInput8是一个重要的API接口,它是Microsoft DirectX的一部分,主要用于游戏和其他需要高性能输入设备交互的应用程序。这个API允许开发者直接从硬件设备,如鼠标和键盘,获取输入数据,从而实现更高效、更精确...

    SPSS input SPSS input

    SPSS input SPSS inputSPSS input SPSS inputSPSS input SPSS input

Global site tag (gtag.js) - Google Analytics