24 #include <interfaces/JoystickInterface.h>
26 #include <core/exceptions/software.h>
126 JoystickInterface::JoystickInterface() : Interface()
128 data_size =
sizeof(JoystickInterface_data_t);
130 data = (JoystickInterface_data_t *)
data_ptr;
142 unsigned char tmp_hash[] = {0xeb, 0x7c, 0xd1, 0x1c, 0xae, 0xa, 0x37, 0x45, 0x5c, 0xa, 0x5e, 0xda, 0x5e, 0x17, 0xdd, 0x42};
147 JoystickInterface::~JoystickInterface()
163 default:
return "UNKNOWN";
176 return data->num_axes;
198 data->num_axes = new_num_axes;
211 return data->num_buttons;
233 data->num_buttons = new_num_buttons;
246 return data->supported_ff_effects;
268 data->supported_ff_effects = new_supported_ff_effects;
283 return data->pressed_buttons;
307 data->pressed_buttons = new_pressed_buttons;
331 throw Exception(
"Index value %u out of bounds (0..8)", index);
333 return data->axis[index];
353 memcpy(data->axis, new_axis,
sizeof(
float) * 8);
366 throw Exception(
"Index value %u out of bounds (0..8)", index);
368 data->axis[index] = new_axis;
381 return data->ff_effects;
404 data->ff_effects = new_ff_effects;
412 if ( strncmp(
"StartRumbleMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
414 }
else if ( strncmp(
"StopRumbleMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
416 }
else if ( strncmp(
"StopAllMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
420 "message type for this interface type.", type);
436 memcpy(data, oi->data,
sizeof(JoystickInterface_data_t));
442 if (strcmp(enumtype,
"Direction") == 0) {
465 data_size =
sizeof(StartRumbleMessage_data_t);
468 data = (StartRumbleMessage_data_t *)
data_ptr;
470 data->length = ini_length;
471 data->delay = ini_delay;
472 data->direction = ini_direction;
473 data->strong_magnitude = ini_strong_magnitude;
474 data->weak_magnitude = ini_weak_magnitude;
484 data_size =
sizeof(StartRumbleMessage_data_t);
487 data = (StartRumbleMessage_data_t *)
data_ptr;
510 data = (StartRumbleMessage_data_t *)
data_ptr;
546 data->length = new_length;
576 data->delay = new_delay;
606 data->direction = new_direction;
616 return data->strong_magnitude;
636 data->strong_magnitude = new_strong_magnitude;
646 return data->weak_magnitude;
666 data->weak_magnitude = new_weak_magnitude;
689 data_size =
sizeof(StopRumbleMessage_data_t);
692 data = (StopRumbleMessage_data_t *)
data_ptr;
710 data = (StopRumbleMessage_data_t *)
data_ptr;
735 data_size =
sizeof(StopAllMessage_data_t);
738 data = (StopAllMessage_data_t *)
data_ptr;
756 data = (StopAllMessage_data_t *)
data_ptr;
void set_direction(const Direction new_direction)
Set direction value.
static const uint32_t BUTTON_14
BUTTON_14 constant.
static const uint32_t BUTTON_4
BUTTON_4 constant.
float * axis() const
Get axis value.
static const uint32_t BUTTON_15
BUTTON_15 constant.
void * data_ptr
Pointer to memory that contains local data.
static const uint32_t BUTTON_23
BUTTON_23 constant.
static const uint32_t BUTTON_28
BUTTON_28 constant.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
size_t maxlenof_supported_ff_effects() const
Get maximum length of supported_ff_effects value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
static const uint32_t BUTTON_1
BUTTON_1 constant.
size_t maxlenof_num_axes() const
Get maximum length of num_axes value.
StopAllMessage Fawkes BlackBoard Interface Message.
JoystickInterface Fawkes BlackBoard Interface.
static const uint8_t JFF_SPRING
JFF_SPRING constant.
static const uint32_t BUTTON_7
BUTTON_7 constant.
void set_hash(unsigned char *ihash)
Set hash.
static const uint32_t BUTTON_32
BUTTON_32 constant.
size_t maxlenof_axis() const
Get maximum length of axis value.
static const uint8_t JFF_RAMP
JFF_RAMP constant.
Fawkes library namespace.
size_t maxlenof_num_buttons() const
Get maximum length of num_buttons value.
8 bit unsigned integer field
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
uint32_t pressed_buttons() const
Get pressed_buttons value.
~StopAllMessage()
Destructor.
Direction
Effect direction.
uint16_t length() const
Get length value.
unsigned int data_size
Minimal data size to hold data storage.
size_t maxlenof_delay() const
Get maximum length of delay value.
void set_pressed_buttons(const uint32_t new_pressed_buttons)
Set pressed_buttons value.
16 bit unsigned integer field
static const uint32_t BUTTON_22
BUTTON_22 constant.
uint16_t weak_magnitude() const
Get weak_magnitude value.
StopRumbleMessage()
Constructor.
uint8_t ff_effects() const
Get ff_effects value.
static const uint32_t BUTTON_27
BUTTON_27 constant.
byte field, alias for uint8
virtual Message * clone() const
Clone this message.
static const uint32_t BUTTON_8
BUTTON_8 constant.
uint16_t strong_magnitude() const
Get strong_magnitude value.
Base class for all Fawkes BlackBoard interfaces.
static const uint32_t BUTTON_20
BUTTON_20 constant.
uint8_t supported_ff_effects() const
Get supported_ff_effects value.
void set_weak_magnitude(const uint16_t new_weak_magnitude)
Set weak_magnitude value.
uint8_t num_axes() const
Get num_axes value.
uint8_t num_buttons() const
Get num_buttons value.
StopRumbleMessage Fawkes BlackBoard Interface Message.
void set_num_axes(const uint8_t new_num_axes)
Set num_axes value.
message_data_ts_t * data_ts
data timestamp aliasing pointer
unsigned int data_size
Size of memory needed to hold all data.
static const uint32_t BUTTON_11
BUTTON_11 constant.
static const uint8_t JFF_FRICTION
JFF_FRICTION constant.
StopAllMessage()
Constructor.
static const uint8_t JFF_PERIODIC
JFF_PERIODIC constant.
static const uint32_t BUTTON_18
BUTTON_18 constant.
void add_messageinfo(const char *name)
Add an entry to the message info list.
bool data_changed
Indicator if data has changed.
void set_delay(const uint16_t new_delay)
Set delay value.
~StartRumbleMessage()
Destructor.
static const uint32_t BUTTON_12
BUTTON_12 constant.
void * data_ptr
Pointer to local memory storage.
static const uint32_t BUTTON_21
BUTTON_21 constant.
static const uint32_t BUTTON_19
BUTTON_19 constant.
~StopRumbleMessage()
Destructor.
Base class for exceptions in Fawkes.
static const uint32_t BUTTON_6
BUTTON_6 constant.
static const uint32_t BUTTON_17
BUTTON_17 constant.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
size_t maxlenof_weak_magnitude() const
Get maximum length of weak_magnitude value.
size_t maxlenof_pressed_buttons() const
Get maximum length of pressed_buttons value.
size_t maxlenof_strong_magnitude() const
Get maximum length of strong_magnitude value.
static const uint32_t BUTTON_16
BUTTON_16 constant.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0)
Add an entry to the field info list.
uint16_t delay() const
Get delay value.
size_t maxlenof_direction() const
Get maximum length of direction value.
static const uint32_t BUTTON_24
BUTTON_24 constant.
static const uint8_t JFF_DAMPER
JFF_DAMPER constant.
size_t maxlenof_length() const
Get maximum length of length value.
StartRumbleMessage()
Constructor.
static const uint32_t BUTTON_13
BUTTON_13 constant.
const char * tostring_Direction(Direction value) const
Convert Direction constant to string.
StartRumbleMessage Fawkes BlackBoard Interface Message.
static const uint8_t JFF_RUMBLE
JFF_RUMBLE constant.
static const uint32_t BUTTON_10
BUTTON_10 constant.
void set_supported_ff_effects(const uint8_t new_supported_ff_effects)
Set supported_ff_effects value.
static const uint32_t BUTTON_30
BUTTON_30 constant.
void set_axis(unsigned int index, const float new_axis)
Set axis value at given index.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
virtual Message * clone() const
Clone this message.
virtual Message * create_message(const char *type) const
Create message based on type name.
static const uint32_t BUTTON_2
BUTTON_2 constant.
static const uint32_t BUTTON_29
BUTTON_29 constant.
static const uint32_t BUTTON_9
BUTTON_9 constant.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0)
Add an entry to the info list.
static const uint8_t JFF_INERTIA
JFF_INERTIA constant.
size_t maxlenof_ff_effects() const
Get maximum length of ff_effects value.
void set_length(const uint16_t new_length)
Set length value.
interface_data_ts_t * data_ts
Pointer to data casted to timestamp struct.
void set_ff_effects(const uint8_t new_ff_effects)
Set ff_effects value.
static const uint32_t BUTTON_3
BUTTON_3 constant.
static const uint32_t BUTTON_5
BUTTON_5 constant.
void set_strong_magnitude(const uint16_t new_strong_magnitude)
Set strong_magnitude value.
Direction direction() const
Get direction value.
virtual Message * clone() const
Clone this message.
const char * type() const
Get type of interface.
static const uint8_t JFF_CONSTANT
JFF_CONSTANT constant.
void set_num_buttons(const uint8_t new_num_buttons)
Set num_buttons value.
32 bit unsigned integer field
field with interface specific enum type
static const uint32_t BUTTON_26
BUTTON_26 constant.
static const uint32_t BUTTON_31
BUTTON_31 constant.
static const uint32_t BUTTON_25
BUTTON_25 constant.