YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
JoypadControlNetUtils.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7
10
12{
13 Buttons.resize(connection.expectInt32());
14 Sticks.resize(connection.expectInt32());
15 Axes.resize(connection.expectInt32());
16 Balls.resize(connection.expectInt32());
17 Touch.resize(connection.expectInt32());
18 Hats.resize(connection.expectInt32());
19 connection.expectBlock((char*)Buttons.data(), Buttons.length() * sizeof(double));
20 connection.expectBlock((char*)Sticks.data(), Sticks.length() * sizeof(double));
21 connection.expectBlock((char*)Axes.data(), Axes.length() * sizeof(double));
22 connection.expectBlock((char*)Balls.data(), Balls.length() * sizeof(double));
23 connection.expectBlock((char*)Touch.data(), Touch.length() * sizeof(double));
24 connection.expectBlock((char*)&Hats[0], Hats.size() * sizeof(char));
25 return !connection.isError();
26}
27
29{
30 connection.appendInt32(Buttons.length());
31 connection.appendInt32(Sticks.length());
32 connection.appendInt32(Axes.length() );
33 connection.appendInt32(Balls.length() );
34 connection.appendInt32(Touch.length() );
35 connection.appendInt32(Hats.size() );
36 connection.appendBlock((char*)Buttons.data(), Buttons.length() * sizeof(double));
37 connection.appendBlock((char*)Sticks.data(), Sticks.length() * sizeof(double));
38 connection.appendBlock((char*)Axes.data(), Axes.length() * sizeof(double));
39 connection.appendBlock((char*)Balls.data(), Balls.length() * sizeof(double));
40 connection.appendBlock((char*)Touch.data(), Touch.length() * sizeof(double));
41 connection.appendBlock((char*)&Hats[0], Hats.size() * sizeof(char));
42 connection.convertTextMode();
43 return !connection.isError();
44}
An interface for reading from a network connection.
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual bool isError() const =0
An interface for writing to a network connection.
virtual bool isError() const =0
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
void resize(size_t size) override
Resize the vector.
Definition Vector.h:221
size_t size() const
Definition Vector.h:341
T * data()
Return a pointer to the first element of the vector.
Definition Vector.h:206
size_t length() const
Get the length of the vector.
Definition Vector.h:349
yarp::sig::VectorOf< unsigned char > Hats
yarp::sig::Vector Buttons
yarp::sig::Vector Sticks
yarp::sig::Vector Balls
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
yarp::sig::Vector Axes
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarp::sig::Vector Touch