This file is indexed.

/usr/include/flatzebra/Joystick.h is in libflatzebra-dev 0.1.5-4build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*  $Id: Joystick.h,v 1.4 2010/05/16 01:50:19 sarrazip Exp $
    Joystick.h - Joystick or game pad encapsulation.

    flatzebra - Generic 2D Game Engine library
    Copyright (C) 1999-2010 Pierre Sarrazin <http://sarrazip.com/>

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    02111-1307, USA.
*/

#ifndef _H_Joystick
#define _H_Joystick

#include <SDL.h>

#include <vector>


namespace flatzebra {


// In this version of flatzebra, this class is merely experimental
// and only supports the Xbox 360 USB controller.
//
class Joystick
{
public:

    // These button numbers are specific to the Xbox 360 USB controller.
    enum
    {
        A_BTN = 0,
        B_BTN = 1,
        Y_BTN = 3,
        X_BTN = 2,
        START_BTN = 6,
        BACK_BTN = 10
    };

    // These axis numbers are specific to the Xbox 360 USB controller.
    enum
    {
        // Main joystick.
        MAIN_X = 0,
        MAIN_Y = 1,

        // D-pad.
        SECONDARY_X = 6,
        SECONDARY_Y = 7
    };

    /*  Asks SDL to open joystick number zero.
        Call isJoystickAvailable() after this constructor to check
        if the joystick was detected and successfully initialized.
        Call update() on this object at each frame.
    */
    Joystick();

    /*  Call this after construction to check if the joystick was
        detected and successfully initialized.
    */
    bool isJoystickAvailable() const;

    /*  Asks SDL to close the joystick if it was successfully opened
        by the constructor. Does nothing if no joystick was detected.
    */
    ~Joystick();

    /*  Returns true or false to indicate if the designated button
        is currently pressed.
        Can be called even if no joystick was detected: false will
        be returned.
    */
    bool getButton(int buttonNumber) const;

    /*  Returns true or false to indicate if the designated button
        is currently pressed but was not pressed before the most
        recent call to update().
    */
    bool buttonJustPressed(int buttonNumber) const;

    /*  Returns value between -32768 (left) and 32767 (right).
    */
    int getXAxisValue() const { return xAxis; }

    /*  Returns -1 if joystick is near the leftmost position,
        +1 if it is near the rightmost position, or 0 otherwise.
    */
    int getXAxisDisplacement() const;

    /*  Returns value between -32768 (up) and 32767 (down).
    */
    int getYAxisValue() const { return xAxis; }

    /*  Returns -1 if joystick is near the highest position,
        +1 if it is near the lowest position, or 0 otherwise.
    */
    int getYAxisDisplacement() const;

    /*  Asks SDL to update the joystick state.
        Also remembers the previous state of the buttons, which
        allows the buttonJustPressed() method to work.
    */
    void update();

    /*  Returns the number of buttons on the detected joystick,
        or zero if no joystick was detected.
    */
    size_t getNumButtons() const;

private:

    /*  Value (between 0 and 32767) beyond which an axis is considered
        to be far enough from the center, for use by getXAxisDisplacement()
        and getYAxisDisplacement().
    */
    enum { AXIS_THRESHOLD = 16000 };

    SDL_Joystick *joystick;
    std::vector<bool> joystickButtons;  // previous state of buttons
    Sint16 xAxis;  // -32768..32767
    Sint16 yAxis;  // -32768..32767

    // Forbidden operations:
    Joystick(const Joystick &);
    Joystick &operator = (const Joystick &);

};


}  // namespace flatzebra


#endif  /* _H_Joystick */