Kaynağa Gözat

Remove CR

Microsoft Windows legacy.
DricomDragon 4 yıl önce
ebeveyn
işleme
9de95c0eea
4 değiştirilmiş dosya ile 278 ekleme ve 278 silme
  1. 145 145
      src/Control/Input.cpp
  2. 66 66
      src/Control/Input.h
  3. 44 44
      src/Control/InputAndJoy.cpp
  4. 23 23
      src/Control/InputAndJoy.h

+ 145 - 145
src/Control/Input.cpp

@@ -1,66 +1,66 @@
-#include "Input.h"
-
-
-// Constructeur et Destructeur
+#include "Input.h"
+
+
+// Constructeur et Destructeur
 Input::Input()
 : m_x(0), m_y(0), m_xRel(0), m_yRel(0),
 m_terminer(false), m_relativeMouse(false), m_windowHalfHeight(0), m_windowHalfWidth(0)
-{
-    // Initialisation du tableau m_touchesHeld[]
-    for(int i(0); i < SDLK_LAST; i++)
+{
+    // Initialisation du tableau m_touchesHeld[]
+    for(int i(0); i < SDLK_LAST; i++)
         m_touchesHeld[i] = false;
-    std::cout << "Il y a "<<SDLK_LAST<<" touches sur le clavier."<<std::endl;
-
-    // Initialisation du tableau m_boutonsSourisHeld[]
-    for(int i(0); i < 8; i++)
-        m_boutonsSourisHeld[i] = false;
-}
-
-
-Input::~Input()
-{}
-
-
-// Méthodes
-void Input::updateEvenements()
-{
-    // Pour éviter des mouvements fictifs de la souris, on réinitialise les coordonnées relatives
-    m_xRel = 0;
+    std::cout << "Il y a "<<SDLK_LAST<<" touches sur le clavier."<<std::endl;
+
+    // Initialisation du tableau m_boutonsSourisHeld[]
+    for(int i(0); i < 8; i++)
+        m_boutonsSourisHeld[i] = false;
+}
+
+
+Input::~Input()
+{}
+
+
+// Méthodes
+void Input::updateEvenements()
+{
+    // Pour éviter des mouvements fictifs de la souris, on réinitialise les coordonnées relatives
+    m_xRel = 0;
     m_yRel = 0;
 
     // Les touches qui viennent d'être appuyées ne le sont plus
     m_touchesInstant.clear();
-    m_boutonsSourisInstant.clear();
-
-    // Boucle d'évènements
-    while(SDL_PollEvent(&m_evenements))
-    {
-        // Switch sur le type d'évènement
-        switch(m_evenements.type)
-        {
-            // Cas d'une touche enfoncée
-            case SDL_KEYDOWN:
+    m_boutonsSourisInstant.clear();
+
+    // Boucle d'évènements
+    while(SDL_PollEvent(&m_evenements))
+    {
+        // Switch sur le type d'évènement
+        switch(m_evenements.type)
+        {
+            // Cas d'une touche enfoncée
+            case SDL_KEYDOWN:
                 m_touchesHeld[m_evenements.key.keysym.sym] = true;
-                m_touchesInstant.push_back( m_evenements.key.keysym.sym );
-            break;
-
-            // Cas d'une touche relâchée
-            case SDL_KEYUP:
-                m_touchesHeld[m_evenements.key.keysym.sym] = false;
-            break;
-
-            // Cas de pression sur un bouton de la souris
-            case SDL_MOUSEBUTTONDOWN:
+                m_touchesInstant.push_back( m_evenements.key.keysym.sym );
+            break;
+
+            // Cas d'une touche relâchée
+            case SDL_KEYUP:
+                m_touchesHeld[m_evenements.key.keysym.sym] = false;
+            break;
+
+            // Cas de pression sur un bouton de la souris
+            case SDL_MOUSEBUTTONDOWN:
                 m_boutonsSourisHeld[m_evenements.button.button] = true;
-                m_boutonsSourisInstant.push_back( m_evenements.button.button );
-            break;
-
-            // Cas du relâchement d'un bouton de la souris
-            case SDL_MOUSEBUTTONUP:
-                m_boutonsSourisHeld[m_evenements.button.button] = false;
-            break;
-
-            // Cas d'un mouvement de souris
+                m_boutonsSourisInstant.push_back( m_evenements.button.button );
+            break;
+
+            // Cas du relâchement d'un bouton de la souris
+            case SDL_MOUSEBUTTONUP:
+                m_boutonsSourisHeld[m_evenements.button.button] = false;
+            break;
+
+            // Cas d'un mouvement de souris
             case SDL_MOUSEMOTION:
                 if (m_relativeMouse)
                 {
@@ -73,115 +73,115 @@ void Input::updateEvenements()
                     m_y = m_evenements.motion.y;
                     m_xRel = m_evenements.motion.xrel;
                     m_yRel = m_evenements.motion.yrel;
-                }
-
-            break;
-
+                }
+
+            break;
+
             // Cas de la fermeture de la fenêtre
             case SDL_QUIT:
                 m_terminer = true;
-            break;
-
-            // Les autres ne nous interessent pas : on évite de faire râler g++
-            default:
-            break;
-        }
+            break;
+
+            // Les autres ne nous interessent pas : on évite de faire râler g++
+            default:
+            break;
+        }
     }
 
     // Pour éviter que la souris se barre en mode relative, on la "warp"
     if (m_relativeMouse)
-         SDL_WarpMouse(m_windowHalfWidth, m_windowHalfHeight);
-}
-
-
-bool Input::terminer() const
-{
-    return m_terminer;
-}
-
-
-void Input::afficherPointeur(bool reponse) const
-{
-    if(reponse)
-        SDL_ShowCursor(SDL_ENABLE);
-
-    else
-        SDL_ShowCursor(SDL_DISABLE);
-}
-
-
-void Input::capturerPointeur(bool reponse)
-{
-    m_relativeMouse = reponse;
-}
-
-
-
-// Getters
-
-bool Input::getToucheHeld(const int touche) const
-{
-    return m_touchesHeld[touche];
-}
-
-
-bool Input::getBoutonSourisHeld(const Uint8 bouton) const
-{
-    return m_boutonsSourisHeld[bouton];
-}
-
-bool Input::getToucheInstant(const int touche) const
-{
+         SDL_WarpMouse(m_windowHalfWidth, m_windowHalfHeight);
+}
+
+
+bool Input::terminer() const
+{
+    return m_terminer;
+}
+
+
+void Input::afficherPointeur(bool reponse) const
+{
+    if(reponse)
+        SDL_ShowCursor(SDL_ENABLE);
+
+    else
+        SDL_ShowCursor(SDL_DISABLE);
+}
+
+
+void Input::capturerPointeur(bool reponse)
+{
+    m_relativeMouse = reponse;
+}
+
+
+
+// Getters
+
+bool Input::getToucheHeld(const int touche) const
+{
+    return m_touchesHeld[touche];
+}
+
+
+bool Input::getBoutonSourisHeld(const Uint8 bouton) const
+{
+    return m_boutonsSourisHeld[bouton];
+}
+
+bool Input::getToucheInstant(const int touche) const
+{
     for ( unsigned int i(0); i < m_touchesInstant.size(); i++ ){
         if ( m_touchesInstant[i] == touche )
             return true;
     }
 
-    return false;
-}
-
-
-bool Input::getBoutonSourisInstant(const Uint8 bouton) const
-{
+    return false;
+}
+
+
+bool Input::getBoutonSourisInstant(const Uint8 bouton) const
+{
     for ( unsigned int i(0); i < m_boutonsSourisInstant.size(); i++ ){
         if ( m_boutonsSourisInstant[i] == bouton )
             return true;
     }
 
-    return false;
-}
-
-
-bool Input::mouvementSouris() const
-{
-    if(m_xRel == 0 && m_yRel == 0)
-        return false;
-
-    else
-        return true;
-}
-
-
-// Getters concernant la position du curseur
-
-int Input::getX() const
-{
-    return m_x;
-}
-
-int Input::getY() const
-{
-    return m_y;
-}
-
-int Input::getXRel() const
-{
-    return m_xRel;
-}
-
-int Input::getYRel() const
-{
-    return m_yRel;
+    return false;
+}
+
+
+bool Input::mouvementSouris() const
+{
+    if(m_xRel == 0 && m_yRel == 0)
+        return false;
+
+    else
+        return true;
+}
+
+
+// Getters concernant la position du curseur
+
+int Input::getX() const
+{
+    return m_x;
+}
+
+int Input::getY() const
+{
+    return m_y;
+}
+
+int Input::getXRel() const
+{
+    return m_xRel;
+}
+
+int Input::getYRel() const
+{
+    return m_yRel;
 }
 
 void Input::placerPtr(SDL_Surface* activWindow)

+ 66 - 66
src/Control/Input.h

@@ -1,66 +1,66 @@
-#ifndef DEF_INPUT
-#define DEF_INPUT
-
-///Jovian
-///Adaptation pour InputAndJoy
-
-// Include
-#include <iostream>
-#include <SDL/SDL.h>
-#include <vector>
-
-
-// Classe
-class Input
-{
-    public:
-
-    Input();
-    virtual ~Input();
-
-    virtual void updateEvenements();
-
-    bool terminer() const;
-    void afficherPointeur(bool reponse) const;
-    void capturerPointeur(bool reponse);
-
-    bool getToucheHeld(const int touche) const;
-    bool getBoutonSourisHeld(const Uint8 bouton) const;
-    bool getToucheInstant(const int touche) const;
-    bool getBoutonSourisInstant(const Uint8 bouton) const;
-    bool mouvementSouris() const;
-
-    int getX() const;
-    int getY() const;
-
-    int getXRel() const;
-    int getYRel() const;
-
-    void placerPtr(SDL_Surface* activWindow);
-
-    int getWinHalfH();
-    int getWinHalfW();
-
-
-    protected:
-
-    SDL_Event m_evenements;
-    bool m_touchesHeld[SDLK_LAST];
-    std::vector<int> m_touchesInstant;
-    bool m_boutonsSourisHeld[8];
-    std::vector<int> m_boutonsSourisInstant;
-
-    int m_x;
-    int m_y;
-    int m_xRel;
-    int m_yRel;
-
-    bool m_terminer;
-    bool m_relativeMouse;
-
-    int m_windowHalfHeight;
-    int m_windowHalfWidth;
-};
-
-#endif
-
+#ifndef DEF_INPUT
+#define DEF_INPUT
+
+///Jovian
+///Adaptation pour InputAndJoy
+
+// Include
+#include <iostream>
+#include <SDL/SDL.h>
+#include <vector>
+
+
+// Classe
+class Input
+{
+    public:
+
+    Input();
+    virtual ~Input();
+
+    virtual void updateEvenements();
+
+    bool terminer() const;
+    void afficherPointeur(bool reponse) const;
+    void capturerPointeur(bool reponse);
+
+    bool getToucheHeld(const int touche) const;
+    bool getBoutonSourisHeld(const Uint8 bouton) const;
+    bool getToucheInstant(const int touche) const;
+    bool getBoutonSourisInstant(const Uint8 bouton) const;
+    bool mouvementSouris() const;
+
+    int getX() const;
+    int getY() const;
+
+    int getXRel() const;
+    int getYRel() const;
+
+    void placerPtr(SDL_Surface* activWindow);
+
+    int getWinHalfH();
+    int getWinHalfW();
+
+
+    protected:
+
+    SDL_Event m_evenements;
+    bool m_touchesHeld[SDLK_LAST];
+    std::vector<int> m_touchesInstant;
+    bool m_boutonsSourisHeld[8];
+    std::vector<int> m_boutonsSourisInstant;
+
+    int m_x;
+    int m_y;
+    int m_xRel;
+    int m_yRel;
+
+    bool m_terminer;
+    bool m_relativeMouse;
+
+    int m_windowHalfHeight;
+    int m_windowHalfWidth;
+};
+
+#endif
+

+ 44 - 44
src/Control/InputAndJoy.cpp

@@ -31,7 +31,7 @@ InputAndJoy::InputAndJoy()
         }
     }
 }
-
+
 InputAndJoy::~InputAndJoy()
 {
     if (m_manette != 0x0) SDL_JoystickClose(m_manette);
@@ -39,44 +39,44 @@ InputAndJoy::~InputAndJoy()
 
 void InputAndJoy::updateEvenements()
 {
-    // Pour éviter des mouvements fictifs de la souris, on réinitialise les coordonnées relatives
-    m_xRel = 0;
+    // Pour éviter des mouvements fictifs de la souris, on réinitialise les coordonnées relatives
+    m_xRel = 0;
     m_yRel = 0;
 
     // Les touches qui viennent d'être appuyées ne le sont plus
     m_touchesInstant.clear();
-    m_boutonsSourisInstant.clear();
-
-    // Boucle d'évènements
-    while(SDL_PollEvent(&m_evenements))
-    {
-        // Switch sur le type d'évènement
-        switch(m_evenements.type)
+    m_boutonsSourisInstant.clear();
+
+    // Boucle d'évènements
+    while(SDL_PollEvent(&m_evenements))
+    {
+        // Switch sur le type d'évènement
+        switch(m_evenements.type)
         {
-        /// Evenements clavier et souris
-            // Cas d'une touche enfoncée
-            case SDL_KEYDOWN:
+        /// Evenements clavier et souris
+            // Cas d'une touche enfoncée
+            case SDL_KEYDOWN:
                 m_touchesInstant[m_evenements.key.keysym.sym] = true;
-                m_touchesInstant.push_back( m_evenements.key.keysym.sym );
-            break;
-
-            // Cas d'une touche relâchée
-            case SDL_KEYUP:
-                m_touchesInstant[m_evenements.key.keysym.sym] = false;
-            break;
-
-            // Cas de pression sur un bouton de la souris
-            case SDL_MOUSEBUTTONDOWN:
+                m_touchesInstant.push_back( m_evenements.key.keysym.sym );
+            break;
+
+            // Cas d'une touche relâchée
+            case SDL_KEYUP:
+                m_touchesInstant[m_evenements.key.keysym.sym] = false;
+            break;
+
+            // Cas de pression sur un bouton de la souris
+            case SDL_MOUSEBUTTONDOWN:
                 m_boutonsSourisHeld[m_evenements.button.button] = true;
-                m_boutonsSourisInstant.push_back( m_evenements.button.button );
-            break;
-
-            // Cas du relâchement d'un bouton de la souris
-            case SDL_MOUSEBUTTONUP:
-                m_boutonsSourisHeld[m_evenements.button.button] = false;
-            break;
-
-            // Cas d'un mouvement de souris
+                m_boutonsSourisInstant.push_back( m_evenements.button.button );
+            break;
+
+            // Cas du relâchement d'un bouton de la souris
+            case SDL_MOUSEBUTTONUP:
+                m_boutonsSourisHeld[m_evenements.button.button] = false;
+            break;
+
+            // Cas d'un mouvement de souris
             case SDL_MOUSEMOTION:
                 if (m_relativeMouse)
                 {
@@ -89,11 +89,11 @@ void InputAndJoy::updateEvenements()
                     m_y = m_evenements.motion.y;
                     m_xRel = m_evenements.motion.xrel;
                     m_yRel = m_evenements.motion.yrel;
-                }
-
-            break;
-
-            // Cas de la fermeture de la fenêtre
+                }
+
+            break;
+
+            // Cas de la fermeture de la fenêtre
             case SDL_QUIT:
                 m_terminer = true;
             break;
@@ -110,18 +110,18 @@ void InputAndJoy::updateEvenements()
                 break;
             case SDL_JOYBUTTONUP:
                     m_boutonValue[m_evenements.jbutton.button] = false;
-                break;
-
-            default:
-            break;
+                break;
+
+            default:
+            break;
         }
     }
 
     // Pour éviter que la souris se barre en mode relative, on la "warp"
     if (m_relativeMouse)
          SDL_WarpMouse(m_windowHalfWidth, m_windowHalfHeight);
-}
-
+}
+
 int InputAndJoy::getAxeValue(const Uint8 axeID) const
 {
     if (axeID < m_nbAxes)
@@ -130,7 +130,7 @@ int InputAndJoy::getAxeValue(const Uint8 axeID) const
         std::cout << "Axe numéro " << axeID << " non-éxistant." << std::endl;
     return -1;
 }
-
+
 bool InputAndJoy::getBoutonPad(const Uint8 bouton) const
 {
     if (bouton<m_nbBoutons)

+ 23 - 23
src/Control/InputAndJoy.h

@@ -1,37 +1,37 @@
-#ifndef INPUTANDJOY_H_INCLUDED
+#ifndef INPUTANDJOY_H_INCLUDED
 #define INPUTANDJOY_H_INCLUDED
 
 
 ///Jovian
-///Adaptation pour InputAndJoy
-
+///Adaptation pour InputAndJoy
+
 // Include
 #include <vector>
 #include "Input.h"
 
 //Enum
 #define CLAVIER_SOURIS 1
-#define MANETTE 2
-
-// Classe
-class InputAndJoy : public Input
-{
-    public:
-
-    InputAndJoy();
+#define MANETTE 2
+
+// Classe
+class InputAndJoy : public Input
+{
+    public:
+
+    InputAndJoy();
     virtual ~InputAndJoy();
 
-    virtual void updateEvenements();
-
-    int getAxeValue(const Uint8 axeID) const;
+    virtual void updateEvenements();
+
+    int getAxeValue(const Uint8 axeID) const;
     bool getBoutonPad(const Uint8 bouton) const;
 
     void setMainControleur(int type);
-    int getMainCtrl() const;
-
-
-    private:
-
+    int getMainCtrl() const;
+
+
+    private:
+
     SDL_Joystick* m_manette;
     int m_nbAxes;
     int m_nbBoutons;
@@ -39,7 +39,7 @@ class InputAndJoy : public Input
     int const m_seuil;
 
     std::vector<int> m_axeValue;
-    std::vector<bool> m_boutonValue;
-};
-
-#endif // INPUTANDJOY_H_INCLUDED
+    std::vector<bool> m_boutonValue;
+};
+
+#endif // INPUTANDJOY_H_INCLUDED