Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
robotran
mbsysc
Commits
e459d8ee
Commit
e459d8ee
authored
Mar 11, 2021
by
François Heremans
Browse files
user inputs same function SDL/websocket
parent
2f8ee663
Changes
4
Hide whitespace changes
Inline
Side-by-side
ExampleProjects/CartPendulum/userfctR/realtime/user_realtime_events.c
View file @
e459d8ee
...
...
@@ -9,10 +9,10 @@
#include "realtime.h"
#include "events_sdl.h"
#include "user_realtime.h"
#ifdef SDL
#if defined(REAL_TIME)
/*! \brief handle inputs comming from the keyboard
*
...
...
@@ -43,7 +43,7 @@
* wait_key(realtime, cur_t_usec, 0.1);
* }
*/
void
user_keyboard
(
MbsData
*
mbs_data
,
Simu_realtime
*
realtime
,
int
cur_t_usec
,
const
U
int8
*
keystates
)
void
user_keyboard
(
MbsData
*
mbs_data
,
Simu_realtime
*
realtime
,
int
cur_t_usec
,
const
u
int8
_t
*
keystates
)
{
}
...
...
@@ -94,9 +94,3 @@ void user_joystick_buttons(MbsData* mbs_data, int buttonID)
}
#endif
#ifdef WEBSOCKET
void
user_keyboard
(
MbsData
*
mbs_data
,
Simu_realtime
*
realtime
,
int
keyevent
,
int
state
){
}
#endif
\ No newline at end of file
MBsysC/cmake_aux/flags/CMakeLists.txt
View file @
e459d8ee
...
...
@@ -124,6 +124,11 @@ function(flags_check)
set
(
FLAG_OPEN_GL OFF
)
endif
(
)
# SDL only if no websocket
if
(
FLAG_WEBSOCKET
)
set
(
FLAG_PLOT OFF
)
endif
(
)
# separate build
if
(
NOT FLAG_SEPARATE_BUILD
)
set
(
FLAG_SEPARATE_SYMBOLIC OFF
)
...
...
MBsysC/mbs_common/mbs_realtime/user_realtime.h
View file @
e459d8ee
...
...
@@ -9,14 +9,20 @@
#include "user_realtime_visu.h"
#include <stdint.h>
#ifdef SDL
#include "SDL.h"
#include "SDL.h"
#include "events_sdl.h"
#endif
#if defined(SDL) || defined(WEBSOCKET)
#ifdef __cplusplus
extern
"C"
{
#endif
void
user_realtime_plot
(
MbsData
*
mbs_data
);
void
user_keyboard
(
MbsData
*
mbs_data
,
Simu_realtime
*
realtime
,
int
cur_t_usec
,
const
U
int8
*
keystates
);
void
user_keyboard
(
MbsData
*
mbs_data
,
Simu_realtime
*
realtime
,
int
cur_t_usec
,
const
u
int8
_t
*
keystates
);
void
user_joystick_axes
(
MbsData
*
mbs_data
,
Simu_realtime
*
realtime
,
int
nb_joysticks
);
void
user_joystick_buttons
(
MbsData
*
mbs_data
,
int
buttonID
);
void
wait_key
(
Simu_realtime
*
realtime
,
int
cur_t_usec
,
double
tsim
);
...
...
@@ -25,17 +31,6 @@ extern "C" {
#endif
#endif
#ifdef WEBSOCKET
#ifdef __cplusplus
extern
"C"
{
#endif
void
user_realtime_plot
(
MbsData
*
mbs_data
);
void
user_keyboard
(
MbsData
*
mbs_data
,
Simu_realtime
*
realtime
,
int
keyevent
,
int
state
);
#ifdef __cplusplus
}
#endif
#endif
#endif
...
...
MBsysC/mbs_common/mbs_realtime/websocket/visu_websocket.cc
View file @
e459d8ee
...
...
@@ -27,6 +27,9 @@ struct pollfd pfds[1]; // More if you want to monitor more
bool
pause_sim
=
false
;
struct
sockaddr_in
serv_addr
;
#define KEYS_LEN 256
uint8_t
key_states
[
KEYS_LEN
];
#define PORT 65432
#define START_VIEWPOINT 0 ///< default initial viewpoint
#define FRAMERATE 18.0
...
...
@@ -72,6 +75,10 @@ void init_websocket(Realtime_visu *visu, MbsData *mbs_data, int nb_models, int *
std
::
cout
<<
"Nb_models for anim should be positive (not "
<<
nb_models
<<
") !"
<<
std
::
endl
;
exit
(
EXIT_FAILURE
);
}
for
(
int
i
=
0
;
i
<
KEYS_LEN
;
++
i
){
key_states
[
i
]
=
0
;
}
visu_in
=
new
VisuIn
;
...
...
@@ -196,7 +203,8 @@ void process_msg(Simu_realtime *realtime){
state
=
(
int
)
subobject
->
number_
;
// Apply the key press actions
user_keyboard
(
mbs_data
,
realtime
,
key
,
state
);
key_states
[
key
]
=
state
;
user_keyboard
(
mbs_data
,
realtime
,
0
,
key_states
);
}
// Check if message is of type speedControl
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment