project64/Source/nragev20/DirectInput.h

157 lines
5.5 KiB
C
Raw Normal View History

2020-02-09 11:36:49 +00:00
/*
N-Rage`s Dinput8 Plugin
(C) 2002, 2006 Norbert Wladyka
2016-01-27 09:11:59 +00:00
Author`s Email: norbert.wladyka@chello.at
Website: http://go.to/nrage
2016-01-27 09:11:59 +00:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the free Software Foundation; either version 2 of the License, or
(at your option) any later version.
2016-01-27 09:11:59 +00:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2016-01-27 09:11:59 +00:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2016-01-27 09:11:59 +00:00
*/
#ifndef _DIRECTINPUT_H_
#define _DIRECTINPUT_H_
#include <dinput.h>
#include "NRagePluginV2.h"
2016-01-27 09:11:59 +00:00
extern LPDIRECTINPUT8 g_pDIHandle;
bool InitDirectInput( HWND hWnd );
void FreeDirectInput ();
bool PrepareInputDevices();
void InitMouse();
void GetDeviceDatas();
bool GetNControllerInput ( const int indexController, LPDWORD pdwData );
BOOL CALLBACK EnumMakeDeviceList( LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef );
bool IsBtnPressed(BUTTON btnButton);
bool GetInputDevice( HWND hWnd, LPDIRECTINPUTDEVICE8 &lpDirectInputDevice, GUID gGuid, DWORD dwDevType, DWORD dwCooperativeLevel );
void ReleaseDevice( LPDIRECTINPUTDEVICE8 &lpDirectInputDevice );
bool CreateEffectHandle( HWND hWnd, LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LPDIRECTINPUTEFFECT &pDIEffect, BYTE bRumbleTyp, long lStrength );
void ReleaseEffect( LPDIRECTINPUTEFFECT &lpDirectEffect );
BYTE GetAdaptoidStatus( LPDIRECTINPUTDEVICE8 lpDirectInputDevice );
bool IsAdaptoidCommandSupported( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, DWORD cmd );
HRESULT DirectRumbleCommand( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, DWORD cmd );
HRESULT InitializeAdaptoid( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LPBYTE status );
HRESULT ReadAdaptoidPak( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, DWORD addr, LPBYTE data );
HRESULT WriteAdaptoidPak( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, DWORD addr, LPBYTE data );
2020-02-09 11:36:49 +00:00
#define MINAXISVALUE -32767
#define MAXAXISVALUE 32767
#define ZEROVALUE 0
#define THRESHOLD 50
#define RANGERELATIVE (MAXAXISVALUE - ZEROVALUE + 1)
#define ABSTHRESHOLD (RANGERELATIVE * THRESHOLD / 100)
// Plus or minus this many 1/100 degrees counts as GetJoyPadPOV being pressed
2020-02-09 11:36:49 +00:00
#define POVANGLETHRESH 5675
#define MOUSEMOVE 5
// By default, scale the mouse input by this much
2020-02-09 11:36:49 +00:00
#define MOUSESCALEVALUE 10
// Percent to decay mouse buffer every frame
// Tweak this from 0-100 to control how much the mouse drifts; values closer to 100 drift more,
// while values closer to 0 are very stiff (deadpan) and don't turn well
2020-02-09 11:36:49 +00:00
#define MOUSEBUFFERDECAY 80
#define N64DIVIDER 258
#define DID_KEYBOARD 0
#define DID_MOUSE 1
#define DID_GAMEPAD 2
#define DIB_KEYBOARD DISCL_NONEXCLUSIVE | DISCL_FOREGROUND
#define DIB_MOUSE DISCL_EXCLUSIVE | DISCL_FOREGROUND
#define DIB_FF DISCL_EXCLUSIVE | DISCL_BACKGROUND
#define DIB_DEVICE DISCL_NONEXCLUSIVE | DISCL_BACKGROUND
#define DIB_CONFIG DISCL_NONEXCLUSIVE | DISCL_BACKGROUND
#define RUMBLE_NONE 0x00
#define RUMBLE_CONSTANT 0x01
#define RUMBLE_RAMP 0x02
#define RUMBLE_CONDITION 0x04
#define RUMBLE_PERIODIC 0x08
#define RUMBLE_CUSTOM 0x10
#define RUMBLE_DIRECT 0x80
#define RUMBLE_EFF1 RUMBLE_CONSTANT
#define RUMBLE_EFF2 RUMBLE_RAMP
#define RUMBLE_EFF3 RUMBLE_DIRECT
// Reported name of the Adaptoid
2020-02-09 11:36:49 +00:00
#define STRING_ADAPTOID "Adaptoid"
#define STRING_GUID_SYSKEYBOARD _T("Keyboard")
#define STRING_GUID_SYSMOUSE _T("SysMouse")
// Query API - pass in command #, returns 0xB0CAB0CA if supported
2020-02-09 11:36:49 +00:00
#define ADAPT_TEST 0x7834BB00
// Send command to rumble pack (DWORD 0=stop, 1=go)
2020-02-09 11:36:49 +00:00
#define ADAPT_RUMBLE 0x7834BB08
// Initialize pak (returns pak status bit flags)
2020-02-09 11:36:49 +00:00
#define ADAPT_INIT 0x7834BB0C
// Read from pak (reads 32 bytes of data)
2020-02-09 11:36:49 +00:00
#define ADAPT_READPAK 0x7834BB0D
// Write to pak (writes 32 bytes of data)
2020-02-09 11:36:49 +00:00
#define ADAPT_WRITEPAK 0x7834BB0E
// Send command directly to controller - synchronous
2020-02-09 11:36:49 +00:00
#define ADAPT_DIRECTCOMMAND 0x7834BB28
2016-01-27 09:11:59 +00:00
// The following inline functions are all overloads for existing functions
inline bool CreateEffectHandle( int iDevice, BYTE bRumbleTyp, long lStrength )
{
2020-02-09 11:36:49 +00:00
return CreateEffectHandle( g_strEmuInfo.hMainWindow, g_apFFDevice[iDevice], g_apdiEffect[iDevice], bRumbleTyp, lStrength );
2016-01-27 09:11:59 +00:00
}
// This used to exist, but it was only used once and makes things more confusing. It has been removed. (comment by rabid)
2016-01-27 09:11:59 +00:00
//inline void ReleaseEffect( int iEffect )
//{
2020-02-09 11:36:49 +00:00
// ReleaseEffect( g_apdiEffect[iEffect] );
2016-01-27 09:11:59 +00:00
//}
inline BYTE GetAdaptoidStatus( int iDevice )
{
2020-02-09 11:36:49 +00:00
return GetAdaptoidStatus( g_apFFDevice[iDevice] );
2016-01-27 09:11:59 +00:00
}
inline HRESULT WriteAdaptoidPak( int iDevice, DWORD addr, LPBYTE data )
{
2020-02-09 11:36:49 +00:00
return WriteAdaptoidPak( g_apFFDevice[iDevice], addr, data );
2016-01-27 09:11:59 +00:00
}
inline HRESULT ReadAdaptoidPak( int iDevice, DWORD addr, LPBYTE data )
{
2020-02-09 11:36:49 +00:00
return ReadAdaptoidPak( g_apFFDevice[iDevice], addr, data );
2016-01-27 09:11:59 +00:00
}
inline HRESULT InitializeAdaptoid( int iDevice, LPBYTE status )
{
2020-02-09 11:36:49 +00:00
return InitializeAdaptoid( g_apFFDevice[iDevice], status );
2016-01-27 09:11:59 +00:00
}
inline HRESULT DirectRumbleCommand( int iDevice, DWORD cmd )
{
2020-02-09 11:36:49 +00:00
return DirectRumbleCommand( g_apFFDevice[iDevice], cmd );
2016-01-27 09:11:59 +00:00
}
inline bool IsAdaptoidCommandSupported( int iDevice, DWORD cmd )
{
2020-02-09 11:36:49 +00:00
return IsAdaptoidCommandSupported( g_apFFDevice[iDevice], cmd );
2016-01-27 09:11:59 +00:00
}
#endif // #ifndef _DIRECTINPUT_H_