00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef MOBILEINTERFACE_H
00024 #define MOBILEINTERFACE_H
00025
00026 #include "UIObject.h"
00027 #include "Command.h"
00028 #include "JString.h"
00029 #include "NameList.h"
00030 #include "WKFUtils.h"
00031
00032 class MobileClientList {
00033 public:
00034 MobileClientList() {}
00035 MobileClientList(const JString n, const JString i, const bool a) :
00036 nick(n), ip(i), active(a) {}
00037 private:
00038 JString nick;
00039 JString ip;
00040 bool active;
00041 };
00042
00044 class Mobile : public UIObject {
00045 public:
00047 enum MoveMode { OFF, MOVE, ANIMATE, TRACKER, USER };
00048
00049 enum TouchMode { ROTATE, TRANSLATE, SCALEROTZ };
00050
00052 static const char *get_mode_str(MoveMode mode);
00053
00054 private:
00055 void *mobile;
00056 int port;
00057
00058 MoveMode moveMode;
00059 int maxstride;
00060 float transInc;
00061 float rotInc;
00062 float scaleInc;
00063 float animInc;
00064 int buttonDown;
00065
00066 int touchinprogress;
00067 int touchcount;
00068 int touchmode;
00069 wkf_timerhandle packtimer;
00070 float touchstartX;
00071 float touchstartY;
00072 float touchdeltaX;
00073 float touchdeltaY;
00074 float touchscale;
00075 float touchscalestartdist;
00076 float touchrotstartangle;
00077
00078 float tranScaling;
00079 float rotScaling;
00080 float zoomScaling;
00081
00082
00084 float trtx;
00085 float trty;
00086 float trtz;
00087 float trrx;
00088 float trry;
00089 float trrz;
00090 int trbuttons;
00091
00092 ResizeArray <JString *> clientNick;
00093 ResizeArray <JString *> clientIP;
00094 ResizeArray <bool> clientActive;
00095 ResizeArray <int> clientListenerPort;
00096 ResizeArray <wkf_timerhandle> clientLastContact;
00097
00098 bool isInControl(JString* nick, JString* ip, const int port,
00099 const int packtype);
00100
00101 void sendStatus(const int event);
00102 void checkAndSendStatus();
00103 wkf_timerhandle statustimer;
00104
00105 float statusSendSeconds;
00106
00107
00108
00109 char statusSendBuffer[1536];
00110 int statusSendBufferLength;
00111
00112
00113 void prepareSendBuffer(const int event);
00114
00115 public:
00116 Mobile(VMDApp *);
00117 virtual ~Mobile(void);
00118
00119
00120
00121
00122
00124 virtual void reset(void);
00125
00130 virtual int act_on_command(int, Command *);
00131
00133 virtual int check_event(void);
00134
00135
00136 int get_port ();
00137
00138
00139 int get_APIsupported ();
00140
00141
00142 int get_move_mode ();
00143
00144
00145 void get_client_list (ResizeArray <JString*>* &nick,
00146 ResizeArray <JString*>* &ip, ResizeArray <bool>* &active);
00147
00148 int move_mode(MoveMode mm);
00149
00151 int set_activeClient(const char *nick, const char *ip);
00152
00154 int sendMsgToClient(const char *nick, const char *ip, const char *msgType, const char *msg);
00155
00157 int network_port(int newport);
00158
00160 void set_max_stride(int ms) {
00161 maxstride = ms;
00162 }
00163
00166 void get_tracker_status(float &tx, float &ty, float &tz,
00167 float &rx, float &ry, float &rz, int &buttons);
00168
00169
00170 int addNewClient(JString* nick, JString* ip, const int port,
00171 const bool active);
00172 int removeClient(const int num);
00173 void removeAllClients();
00174
00175 };
00176
00177
00181 class CmdMobileMode : public Command {
00182 public:
00184 CmdMobileMode(int mm)
00185 : Command(MOBILE_MODE), mobileMode(mm) {}
00186
00188 int mobileMode;
00189 };
00190
00191 #endif
00192