1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
/*
$Id: input_dx.cpp,v 1.3 2001/09/26 17:03:29 japj Exp $
------------------------------------------------------------------------
ClanLib, the platform independent game SDK.
This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
version 2. See COPYING for details.
For a total list of contributers see CREDITS.
------------------------------------------------------------------------
*/
#include "Core/precomp.h"
#include "API/Core/System/cl_assert.h"
#include "input_dx.h"
#include "input_keyboard.h"
#include "input_mouse.h"
#include "input_joystick.h"
LPDIRECTINPUT CL_Input_DX::dinput = NULL;
CL_Input_DX::CL_Input_DX()
{
HRESULT err = DirectInputCreate(CL_System_Win32::hInstance, 0x0300, &dinput, NULL);
cl_assert(err == DI_OK);
CL_Input::keyboards.push_back(new CL_Keyboard_Win32);
CL_Input::pointers.push_back(new CL_Mouse_Win32);
int num_devs = joyGetNumDevs();
for (int i=0; i<num_devs; i++)
{
JOYCAPS joycaps;
JOYINFO joyinfo;
MMRESULT err = joyGetPos(i, &joyinfo);
if (err != JOYERR_UNPLUGGED)
{
err = joyGetDevCaps(i, &joycaps, sizeof(joycaps));
if (err == JOYERR_NOERROR)
CL_Input::joysticks.push_back(new CL_Joystick_Win32(i));
}
}
}
CL_Input_DX::~CL_Input_DX()
{
dinput->Release();
for (std::vector<CL_Keyboard*>::iterator k_it=CL_Input::keyboards.begin();
k_it!=CL_Input::keyboards.end();k_it++)
{
delete *k_it;
}
for (std::vector<CL_InputDevice*>::iterator m_it=CL_Input::pointers.begin();
m_it!=CL_Input::pointers.end();m_it++)
{
delete *m_it;
}
for (std::vector<CL_InputDevice*>::iterator j_it=CL_Input::joysticks.begin();
j_it!=CL_Input::joysticks.end();j_it++)
{
delete *j_it;
}
}
|