23 #include "act_thread.h" 25 #include "acquisition_thread.h" 26 #include "force_feedback.h" 27 #include "sensor_thread.h" 29 #include <interfaces/JoystickInterface.h> 45 :
Thread(
"JoystickActThread",
Thread::OPMODE_WAITFORWAKEUP),
85 joystick_if_ = joystick_if;
86 joystick_connected_ =
false;
100 if (dynamic_cast<JoystickInterface::StartRumbleMessage *>(msg) != NULL) {
102 dynamic_cast<JoystickInterface::StartRumbleMessage *>(msg);
110 uint8_t e = joystick_if_->
ff_effects() | JoystickInterface::JFF_RUMBLE;
112 joystick_if_->
write();
114 }
else if (dynamic_cast<JoystickInterface::StopRumbleMessage *>(msg) != NULL) {
118 joystick_if_->
write();
120 }
else if (dynamic_cast<JoystickInterface::StopAllMessage *>(msg) != NULL) {
123 joystick_if_->
write();
135 if (joystick_connected_) {
137 joystick_if_->
write();
138 joystick_connected_ =
false;
140 }
else if (!joystick_connected_) {
143 effects |= JoystickInterface::JFF_RUMBLE;
146 effects |= JoystickInterface::JFF_PERIODIC;
149 effects |= JoystickInterface::JFF_RAMP;
152 effects |= JoystickInterface::JFF_SPRING;
155 effects |= JoystickInterface::JFF_FRICTION;
158 effects |= JoystickInterface::JFF_DAMPER;
161 effects |= JoystickInterface::JFF_INERTIA;
164 effects |= JoystickInterface::JFF_CONSTANT;
167 joystick_if_->
write();
168 joystick_connected_ =
true;
172 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.