12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include "JoyCtrl.h"
- JoyCtrl::JoyCtrl(InputAndJoy* input)
- :HardCtrl(input)
- {
- //ctor
- }
- JoyCtrl::~JoyCtrl()
- {
- //dtor
- }
- void JoyCtrl::update()
- {
- ///Deplacement
- m_mvt.setVecteur( (float)m_input->getAxeValue(0) / 32768, (float)m_input->getAxeValue(1) / -32768);
- ///Visee
- Vec move( (float)m_input->getAxeValue(3) / 14000, (float)m_input->getAxeValue(4) / -14000 );
- float norme( move.norme() );
- move.setX( move.getX() * norme * norme * norme );
- move.setY( move.getY() * norme * norme * norme );
- m_visee += move;
- if ( m_visee.getX() > m_input->getWinHalfW() )
- m_visee.setX( m_input->getWinHalfW() );
- else if ( m_visee.getX() < -m_input->getWinHalfW() )
- m_visee.setX( -m_input->getWinHalfW() );
- if ( m_visee.getY() > m_input->getWinHalfH() )
- m_visee.setY( m_input->getWinHalfH() );
- else if ( m_visee.getY() < -m_input->getWinHalfH() )
- m_visee.setY( -m_input->getWinHalfH() );
- ///Tir
- m_tir[ L_HAND ] = m_input->getBoutonPad(4); // Xbox pad = LB
- m_tir[ R_HAND ] = m_input->getBoutonPad(5); // Xbox pad = RB
- ///Recherche
- m_search[ L_HAND ] = m_input->getBoutonPad(2); // Xbox pad = A
- m_search[ R_HAND ] = m_input->getBoutonPad(1); // Xbox pad = B
- ///Craft
- m_craft = m_input->getBoutonPad(3); // Xbox pad = Y
- }
|