You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

173 lines
4.6 KiB

// SDL_HAD.cpp : Defines the entry point for the application.
//
#include "framework.h"
#include "SDL_HAD.h"
#include "../../lib/sdl/gui_sdl.h"
#include "../../lib/sdl/widgets/logWidget.h"
#include "../../lib/sdl/widgets/OSDWidget.h"
#include "../../lib/sdl/widgets/buttonWidget.h"
#include "../../lib/components/base/basicLogCollection.h"
#include "../../lib/components/object/objectFlyHunter.h"
#include "../../lib/components/object/objectFileLoggingService.h"
#include "../../lib/sdl/elements/animatedSprite.h"
#include "../../lib/sdl/joystickWrapper.h"
#include "../../lib/sdl/widgets/flyHunterWidget.h"
#define LOG( X ) mLGP->Log( "Main", NULL, X )
#define LOG_ERROR( X ) mLGP->Log( "Main", NULL, _LOG_ERROR, X )
sdlOsdVideoWidget * mVID;
sdlFlyHunterWidget * mFHW;
objectFlyHunter * mHNT;
void test(void) {
exit(1212);
};
void setVizor1(int16_t a) {
mVID->setJoystickRoll(a);
//mHNT->setJoystickRoll(a);
};
void setVizor2(int16_t a) {
mVID->setJoystickPitch(a);
};
void setVizor3(int16_t a) {
mVID->setJoystickYaw(a);
};
void setVizor4(int16_t a) {
mVID->setJoistickThrottle(a);
};
void updateOrien(float a, float b, float c) {
mVID->setRoll(a * 57.295779513082320876798154814105f);
//void setPitch(float Angle);
//void setYaw(float Angle);
//void setAlt(float Angle);
};
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
classGUI_SDL * SDL;
sdlLog * mLOG;
sdlButtonWidget * mBTN;
basicSettingsProvider * mMSP;
config_setting_t * mSET = NULL;
basicLogCollection * mLGP;
objectFileLoggingService * mFLO;
sdlJoystickWrapper * mJOY;
bool mVIW = false;
char mVSRC[256];
mLGP = basicLogCollection::getInstance();
mFLO = new objectFileLoggingService("SDL_HAD.log");
mLGP->addHandler(mFLO);
mMSP = basicSettingsProvider::getInstance((CSTR)"SDL_HAD.conf");
SDL = classGUI_SDL::getInstance();
SLEEP(1000);
mLOG = new sdlLog(10, 520, 400, 190);
mLGP->addHandler(mLOG);
LOG("Start Application");
if (mMSP != NULL) {
mSET = mMSP->getSubNode(NULL, (CSTR)"APPLICATION");
if (mSET == NULL) {
LOG_ERROR("Cannot get Settings!");
} else {
config_setting_t * pSetting;
LOG("Reading Settings");
pSetting = config_setting_get_member(mSET, "VIDEO_SOURCE");
if (pSetting == NULL) {
pSetting = config_setting_add(mSET, "VIDEO_SOURCE", CONFIG_TYPE_STRING);
sprintf(mVSRC, "video=USB2.0 PC CAMERA");
if (pSetting != NULL) {
config_setting_set_string(pSetting, mVSRC );
mMSP->compromise();
};
} else {
sprintf(mVSRC, "%s", config_setting_get_string(pSetting));
};
pSetting = config_setting_get_member(mSET, "VIDEO_WIDE");
if (pSetting == NULL) {
pSetting = config_setting_add(mSET, "VIDEO_WIDE", CONFIG_TYPE_BOOL);
if (pSetting != NULL) {
config_setting_set_bool(pSetting, mVIW);
mMSP->compromise();
};
} else {
mVIW = (bool)config_setting_get_bool(pSetting);
};
};
mMSP->validate();
} else {
LOG_ERROR("Error create Settings File!");
};
mHNT = new objectFlyHunter(mSET);
if (mHNT == NULL) {
LOG_ERROR("Error create FlyHunter Object!");
} else {
if( mHNT->cerate()){
LOG("FlyHunter Created Sucessfully");
} else {
LOG_ERROR("Error Init of FlyHunter!");
};
};
if (mVIW) {
mFHW = new sdlFlyHunterWidget(550, 10, 405, 400);
if (mFHW) {
mFHW->attachFlyHunter(mHNT);
};
mJOY = new sdlJoystickWrapper(10, 320);
if (mJOY) {
SDL->registerJoystickWraper(mJOY);
};
mVID = new sdlOsdVideoWidget((CSTR)mVSRC, 10, 10, 528, 300);
mJOY->Roll = setVizor1;
mJOY->Pitch = setVizor2;
mJOY->Yaw = setVizor3;
mJOY->Throttle = setVizor4;
if (mFHW) {
mFHW->attachOSD(mVID);
};
mHNT->updateOrientation = updateOrien;
mBTN = new sdlButtonWidget((CSTR)"EXIT", 10, 720, 200, 40);
mBTN->Pushed = &test;
} else {
mFHW = new sdlFlyHunterWidget(420, 10, 594, 400);
if (mFHW) {
mFHW->attachFlyHunter(mHNT);
};
mJOY = new sdlJoystickWrapper(10, 320);
if (mJOY) {
SDL->registerJoystickWraper(mJOY);
};
mVID = new sdlOsdVideoWidget((CSTR)mVSRC, 10, 10, 400, 300);
mJOY->Roll = setVizor1;
mJOY->Pitch = setVizor2;
mJOY->Yaw = setVizor3;
mJOY->Throttle = setVizor4;
if (mFHW) {
mFHW->attachOSD(mVID);
};
mBTN = new sdlButtonWidget((CSTR)"EXIT", 10, 720, 200, 40);
mBTN->Pushed = &test;
};
SDL->waitThreadEnd();
LOG("End Application");
return (int) 1234;
}
#undef LOG
#undef LOG_ERROR