23 #include "act_thread.h" 24 #include "sensor_thread.h" 25 #include "acquisition_thread.h" 27 #include <interfaces/JoystickInterface.h> 29 #include "force_feedback.h" 47 :
Thread(
"JoystickActThread",
Thread::OPMODE_WAITFORWAKEUP),
91 __joystick_if = joystick_if;
92 __joystick_connected =
false;
105 if (dynamic_cast<JoystickInterface::StartRumbleMessage *>(msg) != NULL) {
113 uint8_t e = __joystick_if->
ff_effects() | JoystickInterface::JFF_RUMBLE;
115 __joystick_if->
write();
118 else if (dynamic_cast<JoystickInterface::StopRumbleMessage *>(msg) != NULL)
123 __joystick_if->
write();
126 else if (dynamic_cast<JoystickInterface::StopAllMessage *>(msg) != NULL)
130 __joystick_if->
write();
143 if (__joystick_connected) {
145 __joystick_if->
write();
146 __joystick_connected =
false;
148 }
else if (! __joystick_connected) {
151 effects |= JoystickInterface::JFF_RUMBLE;
154 effects |= JoystickInterface::JFF_PERIODIC;
157 effects |= JoystickInterface::JFF_RAMP;
160 effects |= JoystickInterface::JFF_SPRING;
163 effects |= JoystickInterface::JFF_FRICTION;
166 effects |= JoystickInterface::JFF_DAMPER;
169 effects |= JoystickInterface::JFF_INERTIA;
172 effects |= JoystickInterface::JFF_CONSTANT;
175 __joystick_if->
write();
176 __joystick_connected =
true;
181 if (! __joystick_connected) {
virtual void init()
Initialize the thread.
uint16_t weak_magnitude() const
Get weak_magnitude value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
bool msgq_empty()
Check if queue is empty.
fawkes::JoystickInterface * joystick_interface() const
Get joystick interface.
uint16_t delay() const
Get delay value.
JoystickInterface Fawkes BlackBoard Interface.
bool can_ramp()
Check if ramp effect is supported.
Process incoming messages.
Fawkes library namespace.
bool can_friction()
Check if friction effect is supported.
virtual void finalize()
Finalize the thread.
MessageProcessor(JoystickAcquisitionThread *aqt, fawkes::JoystickInterface *joystick_if)
Constructor.
uint16_t length() const
Get length value.
Thread class encapsulation of pthreads.
void write()
Write from local copy into BlackBoard memory.
Joystick acqusition thread for Linux joystick API.
void stop_rumble()
Stop rumbling.
void stop_all()
Stop all current effects.
void rumble(uint16_t strong_magnitude, uint16_t weak_magnitude, Direction direction=DIRECTION_DOWN, uint16_t length=0, uint16_t delay=0)
Rumble the joystick.
bool can_constant()
Check if constant effect is supported.
bool can_periodic()
Check if periodic effect is supported.
JoystickForceFeedback * ff() const
Access force feedback of joystick.
Thread aspect to use blocked timing.
void msgq_pop()
Erase first message from queue.
Cause force feedback on a joystick.
Message * msgq_first()
Get the first message from the message queue.
Direction
Direction of the effect.
virtual void loop()
Code to execute in the thread.
bool can_damper()
Check if damper effect is supported.
uint16_t strong_magnitude() const
Get strong_magnitude value.
uint8_t ff_effects() const
Get ff_effects value.
bool can_spring()
Check if spring effect is supported.
StartRumbleMessage Fawkes BlackBoard Interface Message.
void set_supported_ff_effects(const uint8_t new_supported_ff_effects)
Set supported_ff_effects value.
Direction direction() const
Get direction value.
bool can_rumble()
Check if rumbling effect is supported.
void msgq_flush()
Flush all messages.
void set_ff_effects(const uint8_t new_ff_effects)
Set ff_effects value.
void process_message(fawkes::Message *msg)
Process a single message.
bool can_inertia()
Check if inertia effect is supported.
JoystickActThread(JoystickAcquisitionThread *aqt, JoystickSensorThread *senst)
Constructor.
void process()
Process message currently in the queue.