Fawkes API
Fawkes Development Version
|
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()
169 default:
return "UNKNOWN";
182 return data->num_axes;
216 return data->num_buttons;
250 return data->supported_ff_effects;
286 return data->pressed_buttons;
333 throw Exception(
"Index value %u out of bounds (0..7)", index);
335 return data->axis[index];
378 return data->ff_effects;
408 if ( strncmp(
"StartRumbleMessage",
type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
410 }
else if ( strncmp(
"StopRumbleMessage",
type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
412 }
else if ( strncmp(
"StopAllMessage",
type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
416 "message type for this interface type.",
type);
432 memcpy(data, oi->data,
sizeof(JoystickInterface_data_t));
438 if (strcmp(enumtype,
"Direction") == 0) {
461 data_size =
sizeof(StartRumbleMessage_data_t);
464 data = (StartRumbleMessage_data_t *)
data_ptr;
466 data->length = ini_length;
467 data->delay = ini_delay;
468 data->direction = ini_direction;
469 data->strong_magnitude = ini_strong_magnitude;
470 data->weak_magnitude = ini_weak_magnitude;
484 data_size =
sizeof(StartRumbleMessage_data_t);
487 data = (StartRumbleMessage_data_t *)
data_ptr;
514 data = (StartRumbleMessage_data_t *)
data_ptr;
620 return data->strong_magnitude;
640 change_field(data->strong_magnitude, new_strong_magnitude);
650 return data->weak_magnitude;
693 data_size =
sizeof(StopRumbleMessage_data_t);
696 data = (StopRumbleMessage_data_t *)
data_ptr;
718 data = (StopRumbleMessage_data_t *)
data_ptr;
743 data_size =
sizeof(StopAllMessage_data_t);
746 data = (StopAllMessage_data_t *)
data_ptr;
768 data = (StopAllMessage_data_t *)
data_ptr;
static const uint32_t BUTTON_25
BUTTON_25 constant.
size_t maxlenof_strong_magnitude() const
Get maximum length of strong_magnitude value.
void * data_ptr
Pointer to local memory storage.
Direction direction() const
Get direction value.
static const uint8_t JFF_INERTIA
JFF_INERTIA constant.
void set_weak_magnitude(const uint16_t new_weak_magnitude)
Set weak_magnitude value.
@ IFT_UINT8
8 bit unsigned integer field
virtual Message * clone() const
Clone this message.
StartRumbleMessage Fawkes BlackBoard Interface Message.
static const uint32_t BUTTON_28
BUTTON_28 constant.
static const uint32_t BUTTON_7
BUTTON_7 constant.
size_t maxlenof_axis() const
Get maximum length of axis value.
static const uint32_t BUTTON_24
BUTTON_24 constant.
uint16_t weak_magnitude() const
Get weak_magnitude value.
void set_direction(const Direction new_direction)
Set direction value.
~StopAllMessage()
Destructor.
static const uint32_t BUTTON_31
BUTTON_31 constant.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
StopAllMessage Fawkes BlackBoard Interface Message.
static const uint32_t BUTTON_10
BUTTON_10 constant.
static const uint32_t BUTTON_16
BUTTON_16 constant.
static const uint32_t BUTTON_26
BUTTON_26 constant.
static const uint8_t JFF_FRICTION
JFF_FRICTION constant.
void * data_ptr
Pointer to memory that contains local data.
@ IFT_ENUM
field with interface specific enum type
message_data_ts_t * data_ts
data timestamp aliasing pointer
@ IFT_UINT16
16 bit unsigned integer field
@ IFT_UINT32
32 bit unsigned integer field
uint8_t supported_ff_effects() const
Get supported_ff_effects value.
uint32_t pressed_buttons() const
Get pressed_buttons value.
void set_axis(unsigned int index, const float new_axis)
Set axis value at given index.
static const uint32_t BUTTON_19
BUTTON_19 constant.
static const uint32_t BUTTON_6
BUTTON_6 constant.
uint16_t delay() const
Get delay value.
const char * type() const
Get type of interface.
size_t maxlenof_delay() const
Get maximum length of delay value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
static const uint32_t BUTTON_1
BUTTON_1 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 field info list.
virtual void copy_values(const Interface *other)
Copy values from other interface.
uint8_t num_buttons() const
Get num_buttons value.
interface_data_ts_t * data_ts
Pointer to data casted to timestamp struct.
static const uint8_t JFF_RUMBLE
JFF_RUMBLE constant.
float * axis() const
Get axis value.
virtual Message * create_message(const char *type) const
Create message based on type name.
static const uint32_t BUTTON_30
BUTTON_30 constant.
Timestamp data, must be present and first entries for each interface data structs!...
void set_num_buttons(const uint8_t new_num_buttons)
Set num_buttons value.
static const uint32_t BUTTON_5
BUTTON_5 constant.
uint16_t length() const
Get length value.
virtual Message * clone() const
Clone this message.
static const uint32_t BUTTON_18
BUTTON_18 constant.
Direction
Effect direction.
StopAllMessage()
Constructor.
static const uint32_t BUTTON_12
BUTTON_12 constant.
StopRumbleMessage()
Constructor.
bool data_changed
Indicator if data has changed.
static const uint8_t JFF_DAMPER
JFF_DAMPER constant.
StartRumbleMessage()
Constructor.
static const uint32_t BUTTON_22
BUTTON_22 constant.
void set_length(const uint16_t new_length)
Set length value.
static const uint32_t BUTTON_4
BUTTON_4 constant.
uint8_t ff_effects() const
Get ff_effects value.
static const uint32_t BUTTON_21
BUTTON_21 constant.
static const uint32_t BUTTON_23
BUTTON_23 constant.
static const uint32_t BUTTON_8
BUTTON_8 constant.
void set_delay(const uint16_t new_delay)
Set delay value.
Fawkes library namespace.
size_t maxlenof_length() const
Get maximum length of length value.
void set_hash(unsigned char *ihash)
Set hash.
unsigned int data_size
Size of memory needed to hold all data.
StopRumbleMessage Fawkes BlackBoard Interface Message.
static const uint32_t BUTTON_9
BUTTON_9 constant.
Base class for all Fawkes BlackBoard interfaces.
size_t maxlenof_weak_magnitude() const
Get maximum length of weak_magnitude value.
size_t maxlenof_direction() const
Get maximum length of direction value.
~StartRumbleMessage()
Destructor.
~StopRumbleMessage()
Destructor.
size_t maxlenof_num_axes() const
Get maximum length of num_axes value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
static const uint32_t BUTTON_27
BUTTON_27 constant.
uint16_t strong_magnitude() const
Get strong_magnitude value.
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.
size_t maxlenof_num_buttons() const
Get maximum length of num_buttons value.
void set_supported_ff_effects(const uint8_t new_supported_ff_effects)
Set supported_ff_effects value.
unsigned int data_size
Minimal data size to hold data storage.
static const uint32_t BUTTON_11
BUTTON_11 constant.
static const uint8_t JFF_PERIODIC
JFF_PERIODIC constant.
size_t maxlenof_supported_ff_effects() const
Get maximum length of supported_ff_effects value.
static const uint32_t BUTTON_29
BUTTON_29 constant.
static const uint8_t JFF_SPRING
JFF_SPRING constant.
static const uint32_t BUTTON_2
BUTTON_2 constant.
static const uint32_t BUTTON_15
BUTTON_15 constant.
uint8_t num_axes() const
Get num_axes value.
static const uint32_t BUTTON_14
BUTTON_14 constant.
virtual Message * clone() const
Clone this message.
size_t maxlenof_pressed_buttons() const
Get maximum length of pressed_buttons value.
void set_num_axes(const uint8_t new_num_axes)
Set num_axes value.
size_t maxlenof_ff_effects() const
Get maximum length of ff_effects value.
@ IFT_BYTE
byte field, alias for uint8
void set_pressed_buttons(const uint32_t new_pressed_buttons)
Set pressed_buttons value.
static const uint32_t BUTTON_3
BUTTON_3 constant.
const char * tostring_Direction(Direction value) const
Convert Direction constant to string.
void set_strong_magnitude(const uint16_t new_strong_magnitude)
Set strong_magnitude value.
void add_messageinfo(const char *name)
Add an entry to the message info list.
void set_ff_effects(const uint8_t new_ff_effects)
Set ff_effects value.
static const uint32_t BUTTON_13
BUTTON_13 constant.
static const uint32_t BUTTON_20
BUTTON_20 constant.
static const uint8_t JFF_CONSTANT
JFF_CONSTANT constant.
static const uint32_t BUTTON_32
BUTTON_32 constant.
bool change_field(FieldT &field, const DataT &value)
Set a field and return whether it changed.
static const uint32_t BUTTON_17
BUTTON_17 constant.
static const uint8_t JFF_RAMP
JFF_RAMP constant.
JoystickInterface Fawkes BlackBoard Interface.
Base class for exceptions in Fawkes.