summaryrefslogtreecommitdiffstats
path: root/src/app/joystick.cpp
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-06-10 15:28:12 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-06-10 15:28:12 +0200
commit697fbdabf10d956e0f13bfbc9414d3db40f0c535 (patch)
treeab80ba3119d07b11da5478009b905edb702c103f /src/app/joystick.cpp
parent680af178196217bdd255d2bc851f240983144ac1 (diff)
downloadcolobot-697fbdabf10d956e0f13bfbc9414d3db40f0c535.tar.gz
colobot-697fbdabf10d956e0f13bfbc9414d3db40f0c535.tar.bz2
colobot-697fbdabf10d956e0f13bfbc9414d3db40f0c535.zip
BOOL -> bool; additional fixes in constructors/destructors
Diffstat (limited to 'src/app/joystick.cpp')
-rw-r--r--src/app/joystick.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/app/joystick.cpp b/src/app/joystick.cpp
index 91dc27f..8d617f7 100644
--- a/src/app/joystick.cpp
+++ b/src/app/joystick.cpp
@@ -41,7 +41,7 @@ DIDEVCAPS g_diDevCaps;
// Called once for each enumerated joystick. If we find one, create a
// device interface on it so we can play with it.
-BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance,
+bool CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance,
VOID* pContext )
{
HRESULT hr;
@@ -64,7 +64,7 @@ BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance,
// Callback function for enumerating the axes on a joystick.
-BOOL CALLBACK EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
+bool CALLBACK EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
VOID* pContext )
{
DIPROPRANGE diprg;
@@ -116,7 +116,7 @@ BOOL CALLBACK EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
// Initialize the DirectInput variables.
-BOOL InitDirectInput(HINSTANCE hInst, HWND hWnd)
+bool InitDirectInput(HINSTANCE hInst, HWND hWnd)
{
HRESULT hr;
@@ -124,22 +124,22 @@ BOOL InitDirectInput(HINSTANCE hInst, HWND hWnd)
// to a IDirectInput interface we can use.
#ifndef __MINGW32__ // FIXME Doesn't work under MinGW
hr = DirectInputCreateEx( hInst, DIRECTINPUT_VERSION,IID_IDirectInput7, (LPVOID*)&g_pDI, NULL );
- if( FAILED(hr) ) return FALSE;
+ if( FAILED(hr) ) return false;
#else
- return FALSE;
+ return false;
#endif
// Look for a simple joystick we can use for this sample program.
hr = g_pDI->EnumDevices( DIDEVTYPE_JOYSTICK, EnumJoysticksCallback,
NULL, DIEDFL_ATTACHEDONLY );
- if( FAILED(hr) ) return FALSE;
+ if( FAILED(hr) ) return false;
// Make sure we got a joystick
if( NULL == g_pJoystick )
{
//? MessageBox( NULL, "Joystick not found", "DInput Sample",
//? MB_ICONERROR | MB_OK );
- return FALSE;
+ return false;
}
// Set the data format to "simple joystick" - a predefined data format
@@ -148,18 +148,18 @@ BOOL InitDirectInput(HINSTANCE hInst, HWND hWnd)
// and how they should be reported. This tells DInput that we will be
// passing a DIJOYSTATE structure to IDirectInputDevice::GetDeviceState().
hr = g_pJoystick->SetDataFormat( &c_dfDIJoystick );
- if( FAILED(hr) ) return FALSE;
+ if( FAILED(hr) ) return false;
// Set the cooperative level to let DInput know how this device should
// interact with the system and with other DInput applications.
hr = g_pJoystick->SetCooperativeLevel( hWnd, DISCL_EXCLUSIVE|DISCL_FOREGROUND );
- if( FAILED(hr) ) return FALSE;
+ if( FAILED(hr) ) return false;
// Determine how many axis the joystick has (so we don't error out setting
// properties for unavailable axis)
g_diDevCaps.dwSize = sizeof(DIDEVCAPS);
hr = g_pJoystick->GetCapabilities(&g_diDevCaps);
- if( FAILED(hr) ) return FALSE;
+ if( FAILED(hr) ) return false;
// Enumerate the axes of the joyctick and set the range of each axis. Note:
@@ -167,26 +167,26 @@ BOOL InitDirectInput(HINSTANCE hInst, HWND hWnd)
// of enumerating device objects (axes, buttons, etc.).
g_pJoystick->EnumObjects( EnumAxesCallback, (VOID*)g_pJoystick, DIDFT_AXIS );
- return TRUE;
+ return true;
}
// Acquire or unacquire the keyboard, depending on if the app is active
// Input device must be acquired before the GetDeviceState is called.
-BOOL SetAcquire(BOOL bActive)
+bool SetAcquire(bool bActive)
{
if ( g_pJoystick )
{
if( bActive ) g_pJoystick->Acquire();
else g_pJoystick->Unacquire();
}
- return TRUE;
+ return true;
}
// Get the input device's state and display it.
-BOOL UpdateInputState( DIJOYSTATE &js )
+bool UpdateInputState( DIJOYSTATE &js )
{
HRESULT hr;
@@ -196,7 +196,7 @@ BOOL UpdateInputState( DIJOYSTATE &js )
{
// Poll the device to read the current state
hr = g_pJoystick->Poll();
- if ( FAILED(hr) ) return FALSE;
+ if ( FAILED(hr) ) return false;
// Get the input's device state
hr = g_pJoystick->GetDeviceState( sizeof(DIJOYSTATE), &js );
@@ -208,19 +208,19 @@ BOOL UpdateInputState( DIJOYSTATE &js )
// we don't have any special reset that needs to be done. We
// just re-acquire and try again.
hr = g_pJoystick->Acquire();
- if ( FAILED(hr) ) return FALSE;
+ if ( FAILED(hr) ) return false;
}
}
while ( DIERR_INPUTLOST == hr );
- if ( FAILED(hr) ) return FALSE;
+ if ( FAILED(hr) ) return false;
}
- return TRUE;
+ return true;
}
// Initialize the DirectInput variables.
-BOOL FreeDirectInput()
+bool FreeDirectInput()
{
// Unacquire and release any DirectInputDevice objects.
if( NULL != g_pJoystick )
@@ -240,6 +240,6 @@ BOOL FreeDirectInput()
g_pDI = NULL;
}
- return TRUE;
+ return true;
}