Commit e459d8ee authored by François Heremans's avatar François Heremans
Browse files

user inputs same function SDL/websocket

parent 2f8ee663
......@@ -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 Uint8 *keystates)
void user_keyboard(MbsData* mbs_data, Simu_realtime *realtime, int cur_t_usec, const uint8_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
......@@ -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 )
......
......@@ -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 Uint8 *keystates);
void user_keyboard(MbsData* mbs_data, Simu_realtime *realtime, int cur_t_usec, const uint8_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
......
......@@ -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
......@@ -73,6 +76,10 @@ void init_websocket(Realtime_visu *visu, MbsData *mbs_data, int nb_models, int *
exit(EXIT_FAILURE);
}
for(int i=0; i<KEYS_LEN; ++i){
key_states[i] = 0;
}
visu_in = new VisuIn;
visu_in->nb_models = nb_models;
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment