Hi,
First of all thanks for your hard work on this refreshing binding. I have just ported a sizeable chunk of my code that used the official PySFML 1.6 to this new binding and it does feel cleaner.
However, get_joystick_axis() (from sf.Input) seems to be broken, which kind of renders the joystick unusable.
Here is the incriminating code (where "glob.win" is an sf.RenderWindow):
jx = glob.win.get_input().get_joystick_axis(0, 0) / 100.
Which yields:
Traceback (most recent call last):
<...snip...>
File "/home/lapin/Desktop/ANTCURR/st_jeu.py", line 291, in update
jx = glob.win.get_input().get_joystick_axis(0, 0) / 100.
File "sf.pyx", line 1111, in sf.Input.get_joystick_axis (sf.cpp:11965)
AttributeError: 'sf.Input' object has no attribute 'GetJoystickAxis'
Out of curiosity I opened sf.pyx and here is the portion that seems to be wrong:
cdef class Input:
<...snip...>
def get_joystick_axis(self, unsigned int joy_id, int axis):
return self.GetJoystickAxis(joy_id, axis)
I use the latest SFML 2 snapshot from Git (as of May 9th 2011) and the latest snapshot of the new binding.
EDIT 2: I guess a "p_this" is missing in there.
So if I change line #1111 of sf.pyx to:
return self.p_this.GetJoystickAxis(joy_id, axis)
I get the following error when compiling sf.cpp after having being cythoned from sf.pyx:
sf.cpp: In function ‘PyObject* __pyx_pf_2sf_5Input_1get_joystick_axis(PyObject*, PyObject*, PyObject*)’:
sf.cpp:11962:132: error: invalid conversion from ‘int’ to ‘sf::Joy::Axis’ [-fpermissive]
/usr/include/SFML/Window/Input.hpp:120:11: error: initializing argument 2 of ‘float sf::Input::GetJoystickAxis(unsigned int, sf::Joy::Axis) const’ [-fpermissive]
My guess here is that the API has changed and now uses a "sf::Joy::Axis" instead of a simple int (as in the current .pyx file)
EDIT 3: (Sorry for the long long post) For those who want to get the job done quickly, modify line #1111 of sf.pyx as shown above, run setup.py build, which will generate the huge C++ file. gcc will fail, but don't worry about it right now. Open the huge C++ file named sf.cpp, and head down to line #11962 (I guess the exact line number is subject to change in the near future, but anyway, this is a temporary fix.)
Change it from this:
__pyx_t_1 = PyFloat_FromDouble(((struct __pyx_obj_2sf_Input *)__pyx_v_self)->p_this->GetJoystickAxis(__pyx_v_joy_id, __pyx_v_axis)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
to this:
__pyx_t_1 = PyFloat_FromDouble(((struct __pyx_obj_2sf_Input *)__pyx_v_self)->p_this->GetJoystickAxis(__pyx_v_joy_id, static_cast<sf::Joy::Axis>(__pyx_v_axis))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
We're just casting the integer as a sf::Joy::Axis. It's dirty but it does the trick for now, because I don't know how to fix the cython files yet. Then of course run setup.py build again, then setup.py install.