24 #include <interfaces/JoystickInterface.h> 26 #include <core/exceptions/software.h> 128 JoystickInterface::JoystickInterface() : Interface()
130 data_size =
sizeof(JoystickInterface_data_t);
132 data = (JoystickInterface_data_t *)
data_ptr;
135 enum_map_Direction[(int)DIRECTION_DOWN] =
"DIRECTION_DOWN";
136 enum_map_Direction[(int)DIRECTION_LEFT] =
"DIRECTION_LEFT";
137 enum_map_Direction[(int)DIRECTION_UP] =
"DIRECTION_UP";
138 enum_map_Direction[(int)DIRECTION_RIGHT] =
"DIRECTION_RIGHT";
148 unsigned char tmp_hash[] = {0xeb, 0x7c, 0xd1, 0x1c, 0xae, 0xa, 0x37, 0x45, 0x5c, 0xa, 0x5e, 0xda, 0x5e, 0x17, 0xdd, 0x42};
153 JoystickInterface::~JoystickInterface()
165 case DIRECTION_DOWN:
return "DIRECTION_DOWN";
166 case DIRECTION_LEFT:
return "DIRECTION_LEFT";
167 case DIRECTION_UP:
return "DIRECTION_UP";
168 case DIRECTION_RIGHT:
return "DIRECTION_RIGHT";
169 default:
return "UNKNOWN";
182 return data->num_axes;
204 data->num_axes = new_num_axes;
217 return data->num_buttons;
239 data->num_buttons = new_num_buttons;
252 return data->supported_ff_effects;
274 data->supported_ff_effects = new_supported_ff_effects;
289 return data->pressed_buttons;
313 data->pressed_buttons = new_pressed_buttons;
337 throw Exception(
"Index value %u out of bounds (0..8)", index);
339 return data->axis[index];
359 memcpy(data->axis, new_axis,
sizeof(
float) * 8);
372 throw Exception(
"Index value %u out of bounds (0..8)", index);
374 data->axis[index] = new_axis;
387 return data->ff_effects;
410 data->ff_effects = new_ff_effects;
418 if ( strncmp(
"StartRumbleMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
420 }
else if ( strncmp(
"StopRumbleMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
422 }
else if ( strncmp(
"StopAllMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
426 "message type for this interface type.", type);
442 memcpy(data, oi->data,
sizeof(JoystickInterface_data_t));
448 if (strcmp(enumtype,
"Direction") == 0) {
449 return tostring_Direction((
Direction)val);
471 data_size =
sizeof(StartRumbleMessage_data_t);
474 data = (StartRumbleMessage_data_t *)
data_ptr;
476 data->length = ini_length;
477 data->delay = ini_delay;
478 data->direction = ini_direction;
479 data->strong_magnitude = ini_strong_magnitude;
480 data->weak_magnitude = ini_weak_magnitude;
494 data_size =
sizeof(StartRumbleMessage_data_t);
497 data = (StartRumbleMessage_data_t *)
data_ptr;
524 data = (StartRumbleMessage_data_t *)
data_ptr;
560 data->length = new_length;
590 data->delay = new_delay;
620 data->direction = new_direction;
630 return data->strong_magnitude;
650 data->strong_magnitude = new_strong_magnitude;
660 return data->weak_magnitude;
680 data->weak_magnitude = new_weak_magnitude;
703 data_size =
sizeof(StopRumbleMessage_data_t);
706 data = (StopRumbleMessage_data_t *)
data_ptr;
728 data = (StopRumbleMessage_data_t *)
data_ptr;
753 data_size =
sizeof(StopAllMessage_data_t);
756 data = (StopAllMessage_data_t *)
data_ptr;
778 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.
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.
size_t maxlenof_ff_effects() const
Get maximum length of ff_effects value.
uint16_t weak_magnitude() const
Get weak_magnitude value.
static const uint32_t BUTTON_28
BUTTON_28 constant.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
size_t maxlenof_length() const
Get maximum length of length 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_direction() const
Get maximum length of direction value.
StopAllMessage Fawkes BlackBoard Interface Message.
uint16_t delay() const
Get delay value.
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.
static const uint8_t JFF_RAMP
JFF_RAMP constant.
Fawkes library namespace.
8 bit unsigned integer field
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
~StopAllMessage()
Destructor.
Direction
Effect direction.
unsigned int data_size
Minimal data size to hold data storage.
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 length() const
Get length value.
StopRumbleMessage()
Constructor.
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.
Base class for all Fawkes BlackBoard interfaces.
static const uint32_t BUTTON_20
BUTTON_20 constant.
void set_weak_magnitude(const uint16_t new_weak_magnitude)
Set weak_magnitude value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
float * axis() const
Get axis value.
StopRumbleMessage Fawkes BlackBoard Interface Message.
void set_num_axes(const uint8_t new_num_axes)
Set num_axes value.
size_t maxlenof_num_buttons() const
Get maximum length of num_buttons value.
message_data_ts_t * data_ts
data timestamp aliasing pointer
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the field info list.
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.
virtual Message * clone() const
Clone this message.
const char * type() const
Get type of interface.
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.
uint8_t supported_ff_effects() const
Get supported_ff_effects value.
uint32_t pressed_buttons() const
Get pressed_buttons value.
Base class for exceptions in Fawkes.
static const uint32_t BUTTON_6
BUTTON_6 constant.
static const uint32_t BUTTON_17
BUTTON_17 constant.
size_t maxlenof_weak_magnitude() const
Get maximum length of weak_magnitude value.
static const uint32_t BUTTON_16
BUTTON_16 constant.
uint16_t strong_magnitude() const
Get strong_magnitude value.
static const uint32_t BUTTON_24
BUTTON_24 constant.
static const uint8_t JFF_DAMPER
JFF_DAMPER constant.
StartRumbleMessage()
Constructor.
static const uint32_t BUTTON_13
BUTTON_13 constant.
uint8_t ff_effects() const
Get ff_effects value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
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.
size_t maxlenof_delay() const
Get maximum length of delay value.
Direction direction() const
Get direction value.
virtual Message * clone() const
Clone this message.
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.
uint8_t num_axes() const
Get num_axes value.
static const uint8_t JFF_INERTIA
JFF_INERTIA constant.
size_t maxlenof_pressed_buttons() const
Get maximum length of pressed_buttons value.
const char * tostring_Direction(Direction value) const
Convert Direction constant to string.
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.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the info list.
uint8_t num_buttons() const
Get num_buttons value.
static const uint32_t BUTTON_5
BUTTON_5 constant.
size_t maxlenof_axis() const
Get maximum length of axis value.
void set_strong_magnitude(const uint16_t new_strong_magnitude)
Set strong_magnitude value.
size_t maxlenof_strong_magnitude() const
Get maximum length of strong_magnitude value.
size_t maxlenof_num_axes() const
Get maximum length of num_axes value.
virtual Message * create_message(const char *type) const
Create message based on type name.
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.
size_t maxlenof_supported_ff_effects() const
Get maximum length of supported_ff_effects value.