You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

142 lines
4.5 KiB

#ifndef __JOYSTICK_OBJECT_HEADER__
#define __JOYSTICK_OBJECT_HEADER__
#include <WinSock2.h>
#include <math.h>
#ifndef STRICT
#define STRICT 1
#endif
#define DIRECTINPUT_VERSION 0x0800
#define _CRT_SECURE_NO_DEPRECATE
#ifndef _WIN32_DCOM
#define _WIN32_DCOM
#endif
#include <windows.h>
#include <commctrl.h>
#include <basetsd.h>
#include <dinput.h>
#include <dinputd.h>
#include <assert.h>
#include <oleauto.h>
#include <shellapi.h>
//#pragma warning( disable : 4996 ) // disable deprecated warning
//#include <strsafe.h>
//#pragma warning( default : 4996 )
//#include <Windows.h>
//#include <tchar.h>
#define _USE_MATH_DEFINES
#ifndef M_E
#include <math.h>
#endif
//#include <hidsdi.h>
#include "../../components/base/basicLogCollection.h"
#include "../../components/base/basicSettingsProvider.h"
#include "../../components/base/basicThread.h"
#include "../../gui/guiClass.h"
#define IDI_MAIN 102
#define IDD_JOYST_IMM 103
#define IDR_ACCELERATOR1 103
#define IDC_CLOSE 1001
#define IDC_X_AXIS 1010
#define IDC_Y_AXIS 1011
#define IDC_Z_AXIS 1012
#define IDC_X_AXIS_TEXT 1013
#define IDC_Y_AXIS_TEXT 1014
#define IDC_Z_AXIS_TEXT 1015
#define IDC_X_ROT_TEXT 1016
#define IDC_Y_ROT_TEXT 1017
#define IDC_Z_ROT_TEXT 1018
#define IDC_SLIDER0_TEXT 1019
#define IDC_X_ROT 1020
#define IDC_Y_ROT 1021
#define IDC_Z_ROT 1022
#define IDC_SLIDER1_TEXT 1023
#define IDC_POV0_TEXT 1024
#define IDC_POV1_TEXT 1025
#define IDC_POV2_TEXT 1026
#define IDC_POV3_TEXT 1027
#define IDC_SLIDER0 1030
#define IDC_SLIDER1 1031
#define IDC_POV 1040
#define IDC_POV0 1040
#define IDC_BUTTONS 1041
#define IDC_POV1 1042
#define IDC_POV2 1043
#define IDC_POV3 1044
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1025
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
#define MAX_BUTTONS 128
class joysticObject : public basicThread{
private:
basicLogCollection *m_pLog;
config_setting_t *m_pSettings;
DIJOYSTATE2 m_sJoystickState; // DInput joystick state
bool m_bPresented;
bool m_bActive;
bool bButtonStates[MAX_BUTTONS];
long lAxisX;
long lAxisY;
long lAxisZ;
long lAxisRz;
long lHat;
int m_nNumberOfButtons;
static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext );
public:
// Method to fetch singleton instance.
static joysticObject* getInstance();
// Destructor
~joysticObject();
bool isActive( void ) { return m_bActive; };
bool isPresent( void ){ return m_bPresented; };
int getBtnCnt( void ){ return m_nNumberOfButtons; };
bool getButton( uint8_t id ){return(!m_bPresented)?false:bButtonStates[id];};
long getAxisX( void ){return(!m_bPresented)?0:lAxisX;};
long getAxisY( void ){return(!m_bPresented)?0:lAxisY;};
long getAxisZ( void ){return(!m_bPresented)?0:lAxisZ;};
long getAxisRz( void ){return(!m_bPresented)?0:lAxisRz;};
long getHat( void ){return(!m_bPresented)?0:lHat;};
protected:
// Constructor - protected so users cannot call it.
joysticObject();
void m_fThreadProc(void);
private:
// private static member referencing the single instance of the object
// TODO: Replace mediaVideoSourceManager with the type of object you want to
// return the single instance of
static joysticObject* _instance;
// Copy constructor
// Declared but not defined to prevent auto-generated
// copy constructor. Refer to "Effective C++" by Meyers
joysticObject(const joysticObject& src);
// Assignment operator
// Declared but not defined to prevent auto-generated
// assignment operator. Refer to "Effective C++" by Meyers
joysticObject& operator=(const joysticObject& src);
};
#endif