blender/source/gameengine/GameLogic/Joystick/SCA_Joystick.h

389 lines
4.1 KiB
C
Raw Normal View History

2005-01-23 01:36:29 +00:00
/**
2005-01-23 01:36:29 +00:00
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
2005-01-23 01:36:29 +00:00
*
2005-01-23 01:36:29 +00:00
* This program is free software; you can redistribute it and/or
2005-01-23 01:36:29 +00:00
* modify it under the terms of the GNU General Public License
2005-01-23 01:36:29 +00:00
* as published by the Free Software Foundation; either version 2
2005-01-23 01:36:29 +00:00
* of the License, or (at your option) any later version. The Blender
2005-01-23 01:36:29 +00:00
* Foundation also sells licenses for use in proprietary software under
2005-01-23 01:36:29 +00:00
* the Blender License. See http://www.blender.org/BL/ for information
2005-01-23 01:36:29 +00:00
* about this.
2005-01-23 01:36:29 +00:00
*
2005-01-23 01:36:29 +00:00
* This program is distributed in the hope that it will be useful,
2005-01-23 01:36:29 +00:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2005-01-23 01:36:29 +00:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2005-01-23 01:36:29 +00:00
* GNU General Public License for more details.
2005-01-23 01:36:29 +00:00
*
2005-01-23 01:36:29 +00:00
* You should have received a copy of the GNU General Public License
2005-01-23 01:36:29 +00:00
* along with this program; if not, write to the Free Software Foundation,
2005-01-23 01:36:29 +00:00
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2005-01-23 01:36:29 +00:00
*
2005-01-23 01:36:29 +00:00
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
2005-01-23 01:36:29 +00:00
* All rights reserved.
2005-01-23 01:36:29 +00:00
*
2005-01-23 01:36:29 +00:00
* The Original Code is: all of this file.
2005-01-23 01:36:29 +00:00
*
2005-01-23 01:36:29 +00:00
* Contributor(s): snailrose.
2005-01-23 01:36:29 +00:00
*
2005-01-23 01:36:29 +00:00
* ***** END GPL/BL DUAL LICENSE BLOCK *****
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
#ifndef _SCA_JOYSTICK_H_
2005-01-23 01:36:29 +00:00
#define _SCA_JOYSTICK_H_
2005-01-23 01:36:29 +00:00
#include "SCA_JoystickDefines.h"
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* Basic Joystick class
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
class SCA_Joystick
2005-01-23 01:36:29 +00:00
{
2005-01-23 01:36:29 +00:00
class PrivateData;
2005-01-23 01:36:29 +00:00
PrivateData *m_private;
2005-01-23 01:36:29 +00:00
int m_joyindex;
2005-01-23 01:36:29 +00:00
/*!
2005-01-23 01:36:29 +00:00
* the number of avail joysticks
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int m_numjoys;
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
*support for 2 axes
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int m_axis10,m_axis11;
2005-01-23 01:36:29 +00:00
int m_axis20,m_axis21;
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* Precision or range of the axes
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int m_prec;
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* multiple axis values stored here
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int m_axisnum;
2005-01-23 01:36:29 +00:00
int m_axisvalue;
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* max # of axes avail
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
/*disabled
2005-01-23 01:36:29 +00:00
int m_axismax;
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* button values stored here
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int m_buttonnum;
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* max # of buttons avail
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int m_buttonmax;
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* hat values stored here
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int m_hatnum;
2005-01-23 01:36:29 +00:00
int m_hatdir;
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* max # of hats avail
2005-01-23 01:36:29 +00:00
disabled
2005-01-23 01:36:29 +00:00
int m_hatmax;
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
/* is the joystick initialized ?*/
2005-01-23 01:36:29 +00:00
bool m_isinit;
2005-01-23 01:36:29 +00:00
2005-01-23 01:36:29 +00:00
/* is triggered */
2005-01-23 01:36:29 +00:00
bool m_istrig;
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* Open the joystick
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
bool pCreateJoystickDevice(void);
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* Close the joystick
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
void pDestroyJoystickDevice(void);
2005-01-23 01:36:29 +00:00
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* event callbacks
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
void OnAxisMotion(void);
2005-01-23 01:36:29 +00:00
void OnHatMotion(void);
2005-01-23 01:36:29 +00:00
void OnButtonUp(void);
2005-01-23 01:36:29 +00:00
void OnButtonDown(void);
2005-01-23 01:36:29 +00:00
void OnNothing(void);
2005-01-23 01:36:29 +00:00
void OnBallMotion(void){}
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* fills the axis mnember values
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
void pFillAxes(void);
2005-01-23 01:36:29 +00:00
void pFillButtons(void);
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* returns m_axis10,m_axis11...
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int pGetAxis(int axisnum, int udlr);
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* gets the current button
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int pGetButtonPress(int button);
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* returns if no button is pressed
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int pGetButtonRelease(int button);
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* gets the current hat direction
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int pGetHat(int direction);
2005-01-23 01:36:29 +00:00
2005-01-23 01:36:29 +00:00
public:
2005-01-23 01:36:29 +00:00
SCA_Joystick();
2005-01-23 01:36:29 +00:00
~SCA_Joystick();
2005-01-23 01:36:29 +00:00
2005-01-23 01:36:29 +00:00
bool CreateJoystickDevice(void);
2005-01-23 01:36:29 +00:00
void DestroyJoystickDevice(void);
2005-01-23 01:36:29 +00:00
void HandleEvents();
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
bool aUpAxisIsPositive(int axis);
2005-01-23 01:36:29 +00:00
bool aDownAxisIsPositive(int axis);
2005-01-23 01:36:29 +00:00
bool aLeftAxisIsPositive(int axis);
2005-01-23 01:36:29 +00:00
bool aRightAxisIsPositive(int axis);
2005-01-23 01:36:29 +00:00
bool aButtonPressIsPositive(int button);
2005-01-23 01:36:29 +00:00
bool aButtonReleaseIsPositive(int button);
2005-01-23 01:36:29 +00:00
bool aHatIsPositive(int dir);
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* precision is default '3200' which is overridden by input
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
void cSetPrecision(int val);
2005-01-23 01:36:29 +00:00
int GetAxis10(void){
2005-01-23 01:36:29 +00:00
return m_axis10;
2005-01-23 01:36:29 +00:00
}
2005-01-23 01:36:29 +00:00
int GetAxis11(void){
2005-01-23 01:36:29 +00:00
return m_axis11;
2005-01-23 01:36:29 +00:00
}
2005-01-23 01:36:29 +00:00
int GetAxis20(void){
2005-01-23 01:36:29 +00:00
return m_axis20;
2005-01-23 01:36:29 +00:00
}
2005-01-23 01:36:29 +00:00
int GetAxis21(void){
2005-01-23 01:36:29 +00:00
return m_axis21;
2005-01-23 01:36:29 +00:00
}
2005-01-23 01:36:29 +00:00
int GetButton(void){
2005-01-23 01:36:29 +00:00
return m_buttonnum;
2005-01-23 01:36:29 +00:00
}
2005-01-23 01:36:29 +00:00
int GetHat(void){
2005-01-23 01:36:29 +00:00
return m_hatdir;
2005-01-23 01:36:29 +00:00
}
2005-01-23 01:36:29 +00:00
int GetThreshold(void){
2005-01-23 01:36:29 +00:00
return m_prec;
2005-01-23 01:36:29 +00:00
}
2005-01-23 01:36:29 +00:00
bool IsTrig(void){
2005-01-23 01:36:29 +00:00
return m_istrig;
2005-01-23 01:36:29 +00:00
}
2005-01-23 01:36:29 +00:00
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* returns true if an event is being processed
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
bool GetJoyAxisMotion(void);
2005-01-23 01:36:29 +00:00
bool GetJoyButtonPress(void);
2005-01-23 01:36:29 +00:00
bool GetJoyButtonRelease(void);
2005-01-23 01:36:29 +00:00
bool GetJoyHatMotion(void);
2005-01-23 01:36:29 +00:00
/*
2005-01-23 01:36:29 +00:00
* returns the # of...
2005-01-23 01:36:29 +00:00
*/
2005-01-23 01:36:29 +00:00
int GetNumberOfAxes(void);
2005-01-23 01:36:29 +00:00
int GetNumberOfButtons(void);
2005-01-23 01:36:29 +00:00
int GetNumberOfHats(void);
2005-01-23 01:36:29 +00:00
2005-01-23 01:36:29 +00:00
};
2005-01-23 01:36:29 +00:00
#endif