Open tenxlenx opened 5 years ago
Hmmm I guess the best short-term solution something like this in joystick.h:
#ifdef _WIN32
#include "joystick_windows.h"
#else
#elif __linux__
#include "joystick_linux.h"
#elif __APPLE__
// Fake Joystick class to stop compiler errors
namespace BoBRobotics {
namespace HID {
struct Joystick {};
} // HID
} // BoBRobotics
#endif // _WIN32
It looks like there are third-party drivers available for macOS though: https://github.com/360Controller/360Controller
Assuming that their code isn't too bad it shouldn't take too long to port the Joystick
class and I could help you find your way around that code....
I've just realised that fake Joystick
class won't work on the code in master, but it will on my CMake branch. So you'd need more #ifdef
s around the functions etc. using Joystick
.
not a huge issue, I just modified a few classes on my local repo, I just thought I let you know since there might be some Mac users.
It might be better still to abandon the platform-specific joystick implementations an use SFML
That probably would be sensible... When we initially were writing a joystick driver just for Linux it probably did make sense to write our own joystick code, but writing a cross-platform driver is a bit of a faff
No indeed! SFML, pesky mac users and generality in general weren't really considerations at that point
On Wed, 1 May 2019, 07:37 Alex Dewar, notifications@github.com wrote:
That probably would be sensible... When we initially were writing a joystick driver just for Linux it probably did make sense to write our own joystick code, but writing a cross-platform driver is a bit of a faff
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/BrainsOnBoard/bob_robotics/issues/108#issuecomment-488214639, or mute the thread https://github.com/notifications/unsubscribe-auth/ABT2QGX2OL2E5PPNT7YJTJ3PTEUC7ANCNFSM4HJOUYBA .
It does look fairly nice and simple: https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Joystick.php
We could use the sf::Joystick
class directly, but there are a couple of features we have that SFML doesn't:
update()
Point 2 is less important (we don't need two ways of interacting with joysticks), but I do feel that monitoring changes in button state (i.e. when it's pressed or released) is something that should be handled outside of the calling code. It's a bit gross to have a bunch of wasButtonXPressedBefore
-type variables lying around. So we could either inherit from the sf::Joystick
class to add this functionality and fix up our code to use the SFML function names or we could leave the external API for our BoB robotics Joystick
as is and rework it to use SFML internally.
I THOUGHT you could also get events from SFML but maybe I'm wrong... I think Norbert's probably just using the keyboard for now so it's not urgent
On Wed, 1 May 2019, 10:39 Alex Dewar, notifications@github.com wrote:
It does look fairly nice and simple: https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Joystick.php
We could use the sf::Joystick class directly, but there are a couple of features we have that SFML doesn't:
- It looks like you can only check if a button is currently pressed rather than whether it has been pressed since the last call to update()
- We also have the event-driven aspect to our API so you can set callbacks for buttons and axes
Point 2 is less important (we don't need two ways of interacting with joysticks), but I do feel that monitoring changes in button state (i.e. when it's pressed or released) is something that should be handled outside of the calling code. It's a bit gross to have a bunch of wasButtonXPressedBefore-type variables lying around. So we could either inherit from the sf::Joystick class to add this functionality and fix up our code to use the SFML function names or we could leave the external API for our BoB robotics Joystick as is and rework it to use SFML internally.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/BrainsOnBoard/bob_robotics/issues/108#issuecomment-488236252, or mute the thread https://github.com/notifications/unsubscribe-auth/ABT2QGXRDX5VS2FPEIGCTQLPTFJN3ANCNFSM4HJOUYBA .
Joystick library is not found on macOS and it breaks all code referencing Robots::Tank.
in joystick.h :
ifdef _WIN32
include "joystick_windows.h"
else
include "joystick_linux.h"
endif
There is no option for macOS and I did not find the library for mac.