To drugie rozwiązanie to C#
Wstyd mi ale nie odróżniam
istotnej części kodu
nie wiem co może być jeszcze istotne. Może po prostu wkleję cały kod.
zabrałeś się za zbyt skomplikowany problem
Niestety taki mam do rozwiązania. Pogram już od jakiegoś czasu działa i poradziłem sobie bez większych trudności. Chcę go natomiast nieco rozbudować i tutaj pojawił się problem.
mieszanie języków programowania
Mieszanie języków i owszem, bo więcej piszę w C ale na mikroprocesory więc ciężko mi się przerzucić.
Jestem świadomy tego, że może się okazać, iż rozwiązanie z char jest poprawne, a to simconnect nie zrzuca poprawnie danych ale chciałem tutaj zapytać bardziej doświadczonych
Cały kod:
extern "C" {
#include "Include/DirectOutput.h"
#include "Include/SimConnect.h"
#include "Include/leds.h"
}
#include <vector>
#include <iostream>
#include <cwchar>
#include <stdio.h>
#include <windows.h>
#include <tchar.h>
#include <strsafe.h>
#include <map>
#include <thread>
#include <fstream>
#include <string>
#include "src/pugixml.hpp"
using namespace std;
//------zmienne--------------------------------------
HRESULT hr;
DWORD cbData = 0;
bool bRequestProcessed = false;
DWORD dwPage = 1;
bool blink;
SIMCONNECT_RECV* pData = NULL;
SIMCONNECT_RECV_SIMOBJECT_DATA* pObjData = NULL;
std::vector<void*> devices;
HANDLE hSimConnect = NULL;
//-----------------definicje---------------------------
enum DATA_DEFINE_ID
{
DEFINITION_ID_AP,
};
enum DATA_REQUEST_ID
{
REQUEST_AP_SETTINGS,
};
enum EVENT_ID
{
EVENT_SET_AP_ALTITUDE,
};
std::vector<std::string> mfdLine {"AP_CRS1", "AP_HDG", "AP_VS"};
std::vector<std::string> diody {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
std::map<std::string, int> dek {{"LED_FIRE", 0}, {"LED_FIRE_A", 1}, {"LED_FIRE_B", 3}, {"LED_FIRE_D", 5}, {"LED_FIRE_E", 7}, {"LED_TOGGLE_1_2", 9}, {"LED_TOGGLE_3_4", 11}, {"LED_TOGGLE_5_6", 13}, {"LED_POV_2", 15}, {"LED_CLUTCH", 17}, {"LED_THROTTLE", 19},};
struct DataRefs
{
double flaps;
double spoilers_pos;
double spoilers_armed;
double spd;
double gear;
double ap_master;
double ap_hdg_lock;
double ap_nav1_lock;
double ap_alt_lock;
double ap_app_lock;
double ap_nav_selected;
double ap_hdg;
double ap_alt;
double ap_vs;
double ap_spd;
double ap_crs1;
double ap_crs2;
double ap_crs3;
double autothrottle_lock;
double altitude;
double verticalspeed;
double hdg;
double rev;
double lightlanding;
double parkingbrake;
double enginerpm1;
double enginerpm2;
double batt_master;
double retr_gear;
double light_taxi;
double light_beacon;
double light_nav;
double light_strobe;
double light_panel;
double stall_wrn;
double overspeed_wrn;
double inner_marker;
double middle_marker;
double outer_marker;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
string tailnumber;
};
//-----------FUNKCJE------------------------------
void __stdcall DirectOutput_Device_Callback(void* hDevice, bool bAdded, void* pvContext) {
if (bAdded) {
devices.push_back(hDevice);
}
else {
}
}
void __stdcall DirectOutput_Enumerate_Callback(void* hDevice, void* pvContext) {
devices.push_back(hDevice);
}
void XMLParsing(void){
using namespace pugi;
std::cout << "Loading settings:\n";
std::ifstream xml_file("settings.xml");
if(!xml_file){
std::cerr << "ERROR: opening XML file: " << std::endl;
}
xml_document doc;
xml_parse_result res = doc.load(xml_file);
if(!res){
std::cerr << "ERROR: " << res.description() << std::endl;
}
xml_object_range<xml_named_node_iterator> sources =
doc.child("root").children("leds");
xml_named_node_iterator s;
std::string jakiPzycisk, jakiStatus, jakaLinia;
for(s = sources.begin(); s != sources.end(); ++s)
{
xml_object_range<xml_named_node_iterator> btns =
s->children("btn");
//-----LEDS-------
xml_named_node_iterator v;
for(v = btns.begin(); v != btns.end(); ++v){
jakiPzycisk = v->attribute("name").as_string();
diody[dek[jakiPzycisk]] = v->attribute("function").as_string();
std::cout << "-> " << jakiPzycisk << " / " << v->attribute("function").as_string() << "\n";
}
//----MFD-----
xml_object_range<xml_named_node_iterator> mfdLines =
s->children("mfd");
for(v = mfdLines.begin(); v != mfdLines.end(); ++v){
jakaLinia = v->attribute("name").as_string();
mfdLine[std::stoi(jakaLinia)] = v->attribute("function").as_string();
std::cout << "-> MFD: " << jakaLinia << " / " << v->attribute("function").as_string() << "\n";
}
}
}
void mfd_Print(double spd, double vs, double alt){
wchar_t txt[14];
swprintf_s(txt, L"SPD: %.0f kts", spd);
int txtsize = std::wcslen (txt);
DirectOutput_SetString(devices[0], dwPage, 0, txtsize, txt);
swprintf_s(txt, L"V/S: %.0f f/m", vs);
txtsize = std::wcslen (txt);
DirectOutput_SetString(devices[0], dwPage, 1, txtsize, txt);
swprintf_s(txt, L"ALT: %.0f ft", alt);
txtsize = std::wcslen (txt);
DirectOutput_SetString(devices[0], dwPage, 2, txtsize, txt);
}
void mfdPrintLines(void){
wchar_t txt[14];
DataRefs* pDataRefs = NULL;
pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*)pData;
pDataRefs = (DataRefs*)&pObjData->dwData;
for(uint8_t i;i<3;i++){
if(mfdLine[i] == "SPD"){
swprintf_s(txt, L"SPD: %.0f kts", pDataRefs->spd);
} else if(mfdLine[i] == "ALT"){
swprintf_s(txt, L"ALT: %.0f ft", pDataRefs->altitude);
} else if(mfdLine[i] == "V/S"){
swprintf_s(txt, L"V/S: %.0ff/m", pDataRefs->verticalspeed);
} else if(mfdLine[i] == "HDG"){
swprintf_s(txt, L"HDG: %.0f", pDataRefs->hdg);
} else if(mfdLine[i] == "AP_HDG"){
swprintf_s(txt, L"ApHDG: %.0f", pDataRefs->ap_hdg);
} else if(mfdLine[i] == "AP_ALT"){
swprintf_s(txt, L"ApALT: %.0fft", pDataRefs->ap_alt);
} else if(mfdLine[i] == "AP_V/S"){
swprintf_s(txt, L"ApV/S: %.0ff/m", pDataRefs->ap_vs);
} else if(mfdLine[i] == "AP_SPD"){
swprintf_s(txt, L"ApSPD: %.0f kts", pDataRefs->ap_spd);
} else if(mfdLine[i] == "AP_CRS1"){
swprintf_s(txt, L"ApCRS1: %.0f", pDataRefs->ap_crs1);
} else if(mfdLine[i] == "AP_CRS2"){
swprintf_s(txt, L"ApCRS2: %.0f", pDataRefs->ap_crs2);
} else {
swprintf_s(txt, L"");
}
int txtsize = std::wcslen (txt);
DirectOutput_SetString(devices[0], dwPage, i, txtsize, txt);
}
}
void mfdClearLines(void){
wchar_t txt[14];
for(uint8_t i;i<3;i++){
swprintf_s(txt, L"");
int txtsize = std::wcslen (txt);
DirectOutput_SetString(devices[0], dwPage, i, txtsize, txt);
}
}
void clear_led(void){
DirectOutput_SetLed(devices[0], dwPage, LED_TOGGLE_1_2_RED, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_TOGGLE_1_2_GREEN, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_TOGGLE_3_4_RED, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_TOGGLE_3_4_GREEN, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_TOGGLE_5_6_GREEN, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_TOGGLE_5_6_RED, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_CLUTCH_GREEN, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_CLUTCH_RED, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_FIRE, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_FIRE_A_GREEN, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_FIRE_A_RED, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_FIRE_B_GREEN, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_FIRE_B_RED, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_FIRE_D_GREEN, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_FIRE_D_RED, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_FIRE_E_GREEN, 0);
DirectOutput_SetLed(devices[0], dwPage, LED_FIRE_E_RED, 0);
}
void color_led(uint8_t nr, int8_t param){
if(nr==LED_FIRE || nr==LED_THROTTLE){
if(param==0){ //wylaczony
DirectOutput_SetLed(devices[0], dwPage, nr, 0); //green
} else {
DirectOutput_SetLed(devices[0], dwPage, nr, 1); //green
}
} else {
if(param==0){ //wylaczony
DirectOutput_SetLed(devices[0], dwPage, nr, 1); //red
DirectOutput_SetLed(devices[0], dwPage, nr+1, 0); //green
} else if (param==1){ //wlaczony
DirectOutput_SetLed(devices[0], dwPage, nr, 0); //red
DirectOutput_SetLed(devices[0], dwPage, nr+1, 1); //green
} else if (param==-1){ //diody wylaczone
DirectOutput_SetLed(devices[0], dwPage, nr, 0); //red
DirectOutput_SetLed(devices[0], dwPage, nr+1, 0); //green
}else { //stan posredni
DirectOutput_SetLed(devices[0], dwPage, nr, 1); //red
DirectOutput_SetLed(devices[0], dwPage, nr+1, 1); //green
}
}
}
void flash(uint8_t ledNR){
for(uint8_t x;x<10;x++){
color_led(ledNR,0);
Sleep(80);
color_led(ledNR,-1);
Sleep(50);
}
}
void colorFlash(uint8_t ledNR, uint8_t color){
for(uint8_t x;x<10;x++){
color_led(ledNR,color);
Sleep(80);
color_led(ledNR,-1);
Sleep(50);
}
}
void set_led(void){
DataRefs* pDataRefs = NULL;
pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*)pData;
pDataRefs = (DataRefs*)&pObjData->dwData;
if(pDataRefs->batt_master > 10){ //jesli bateria wlaczona
uint8_t i;
for(i=0;i<20;i++){
if (diody[i] == "RED"){
color_led(i,0);
} else if (diody[i] == "GREEN"){
color_led(i,1);
} else if (diody[i] == "ORANGE"){
color_led(i,2);
} else if(diody[i] == "GEAR"){
if(pDataRefs->gear >0 && pDataRefs->gear <= 99){ //GEAR
color_led(i,2);
} else if (pDataRefs->gear == 100){
color_led(i,1);
} else {
color_led(i,0);
}
} else if (diody[i] == "PARKING_BRAKE"){
color_led(i,pDataRefs->parkingbrake); //PARKING BRAKE
} else if (diody[i] == "RPM_ENGINE_1"){
if(pDataRefs->enginerpm1 >500){ //ENGINE 1 RPM
color_led(i,1);
} else {
color_led(i,0);
}
} else if (diody[i] == "RPM_ENGINE_2"){
if(pDataRefs->enginerpm2 >500){ //ENGINE 2 RPM
color_led(i,1);
} else {
color_led(i,0);
}
} else if (diody[i] == "FLAPS"){
if(pDataRefs->flaps >=10 && pDataRefs->flaps < 90){ //FLAPS
color_led(i,2);
} else if (pDataRefs->flaps >=90){
color_led(i,1);
} else {
color_led(i,0);
}
} else if (diody[i] == "LANDING_LIGHTS"){
color_led(i,pDataRefs->lightlanding);
} else if (diody[i] == "AP_MASTER"){
color_led(i,pDataRefs->ap_master);
} else if (diody[i] == "REV_THRUST"){
if(pDataRefs->rev < 0){ //REVERSE THRUST
color_led(i,0);
} else {
color_led(i,1);
}
} else if (diody[i] == "TAXI_LIGHTS"){
color_led(i,pDataRefs->light_taxi);
} else if (diody[i] == "NAV_LIGHTS"){
color_led(i,pDataRefs->light_nav);
} else if (diody[i] == "BEACON_LIGHTS"){
color_led(i,pDataRefs->light_beacon);
} else if (diody[i] == "STROBE_LIGHTS"){
color_led(i,pDataRefs->light_strobe);
} else if (diody[i] == "PANEL_LIGHTS"){
color_led(i,pDataRefs->light_panel);
} else if (diody[i] == "LIGHTS_COMBO"){
if(pDataRefs->light_taxi == 1 && pDataRefs->lightlanding == 1){
color_led(i,0);
} else if (pDataRefs->light_taxi == 1 && pDataRefs->lightlanding == 0){
color_led(i,2);
} else if (pDataRefs->light_taxi == 0 && pDataRefs->lightlanding == 1){
color_led(i,1);
} else {
color_led(i,-1);
}
} else if (diody[i] == "STALL_WARNING"){
if(pDataRefs->stall_wrn == 1){
thread f1(flash, i);
f1.join();
} else {
color_led(i,-1);
}
} else if (diody[i] == "OVERSPEED_WARNING"){
if(pDataRefs->overspeed_wrn == 1){
thread f2(flash, i);
f2.join();
} else {
color_led(i,-1);
}
} else if (diody[i] == "MARKERS"){
if(pDataRefs->inner_marker == 1){
colorFlash(i,0);
} else if(pDataRefs->middle_marker == 1){
colorFlash(i,2);
} else if(pDataRefs->outer_marker == 1){
colorFlash(i,1);
}
} else if (diody[i] == "INNER_MARKER"){
if(pDataRefs->inner_marker == 1){
thread f3(flash, i);
f3.join();
} else {
color_led(i,-1);
}
} else if (diody[i] == "MIDDLE_MARKER"){
if(pDataRefs->middle_marker == 1){
thread f4(flash, i);
f4.join();
} else {
color_led(i,-1);
}
} else if (diody[i] == "OUTER_MARKER"){
if(pDataRefs->outer_marker == 1){
thread f5(flash, i);
f5.join();
} else {
color_led(i,-1);
}
} else if (diody[i] == "SPOILERS_ARMED"){
color_led(i,pDataRefs->spoilers_armed);
} else if (diody[i] == "SPOILERS"){
if(pDataRefs->spoilers_pos < 5){
color_led(i,0);
} else if (pDataRefs->spoilers_pos > 95){
color_led(i,1);
} else {
color_led(i,2);
}
} else if (diody[i] == "AP_HDG_LOCK"){
color_led(i,pDataRefs->ap_hdg_lock);
} else if (diody[i] == "AP_NAV1_LOCK"){
color_led(i,pDataRefs->ap_nav1_lock);
} else if (diody[i] == "AP_ALT_LOCK"){
color_led(i,pDataRefs->ap_alt_lock);
} else if (diody[i] == "AP_APP_LOCK"){
color_led(i,pDataRefs->ap_app_lock);
} else if (diody[i] == "AUTOTHROTTLE_LOCK"){
color_led(i,pDataRefs->autothrottle_lock);
} else if (diody[i] == "AP_COURSE_COMBO"){
if(pDataRefs->ap_hdg_lock == 0 && pDataRefs->ap_nav1_lock == 0 && pDataRefs->ap_app_lock == 0){
color_led(i,-1);
} else if (pDataRefs->ap_app_lock == 1){
color_led(i,2); //orange
} else if (pDataRefs->ap_nav1_lock == 1){
color_led(i,1); //green
} else if (pDataRefs->ap_hdg_lock == 1){
color_led(i,0); //red
}
}
}
//mfd_Print(pDataRefs->spd, pDataRefs->verticalspeed, pDataRefs->altitude);
mfdPrintLines();
} else {
clear_led();
mfdClearLines();
}
}
void glowny(void){
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "FLAPS HANDLE PERCENT", "Percent");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "SPOILERS HANDLE POSITION", "Percent");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "SPOILERS ARMED", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AIRSPEED INDICATED", "Knots");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "GEAR POSITION", "Percent");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOPILOT MASTER", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOPILOT HEADING LOCK", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOPILOT NAV1 LOCK", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOPILOT ALTITUDE LOCK", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOPILOT APPROACH HOLD", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOPILOT NAV SELECTED", "Number");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOPILOT HEADING LOCK DIR", "Degree");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOPILOT ALTITUDE LOCK VAR", "Feet");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOPILOT VERTICAL HOLD VAR", "Feet/minute");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOPILOT AIRSPEED HOLD VAR", "Knots");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "NAV OBS:1", "Degrees");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "NAV OBS:2", "Degrees");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "NAV OBS:3", "Degrees");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "AUTOTHROTTLE ACTIVE", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "Indicated Altitude", "feet");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "VERTICAL SPEED", "feet per minute");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "HEADING INDICATOR", "degrees");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "GENERAL ENG THROTTLE LEVER POSITION:1", "Percent");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "LIGHT LANDING", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "BRAKE PARKING POSITION", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "GENERAL ENG RPM:1", "Rpm");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "GENERAL ENG RPM:2", "Rpm");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "ELECTRICAL MAIN BUS VOLTAGE", "Volts");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "IS GEAR RETRACTABLE", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "LIGHT TAXI", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "LIGHT BEACON", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "LIGHT NAV", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "LIGHT STROBE", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "LIGHT PANEL", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "STALL WARNING", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "OVERSPEED WARNING", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "INNER MARKER", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "MIDDLE MARKER", "Bool");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "OUTER MARKER", "Bool");
//
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_ID_AP, "ATC FLIGHT NUMBER", "String");
hr = SimConnect_RequestDataOnSimObject(hSimConnect, REQUEST_AP_SETTINGS, DEFINITION_ID_AP, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SECOND);
if (FAILED(hr)){
printf("RequestDataOnSimObject for AutopilotData structure - error\n");
}
bRequestProcessed = false;
while (!bRequestProcessed){
hr = SimConnect_GetNextDispatch(hSimConnect, &pData, &cbData);
if (SUCCEEDED(hr)){
set_led();
}
Sleep(100);
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int main() {
printf("X52 Dynamic LED ver 2.2\n Saitek X52 PRO plugin for Microsoft Flight Simulator\n");
printf("Created by KoSik -> [email protected]\n\n\n");
XMLParsing();
printf("Settings loaded!\n\n");
int q=0;
printf("Connecting with MSFS...");
while(1){
hr = SimConnect_Open(&hSimConnect, "Client Event", NULL, NULL, NULL, NULL);
if (SUCCEEDED(hr)) {
const wchar_t * name = L"X52_plugin";
DirectOutput_Initialize(name);
DirectOutput_RegisterDeviceCallback(*DirectOutput_Device_Callback, nullptr);
DirectOutput_Enumerate(*DirectOutput_Enumerate_Callback, nullptr);
const wchar_t * pageDebugName = L"X52_page";
DirectOutput_AddPage(devices[0], dwPage, pageDebugName, FLAG_SET_AS_ACTIVE);
const wchar_t * txt = L"Saitek X52 plugin";
int txtsize = std::wcslen (txt);
DirectOutput_SetString(devices[0], dwPage, 0, txtsize, txt);
txt = L" created by";
txtsize = std::wcslen (txt);
DirectOutput_SetString(devices[0], dwPage, 1, txtsize, txt);
txt = L" KoSik";
txtsize = std::wcslen (txt);
DirectOutput_SetString(devices[0], dwPage, 2, txtsize, txt);
printf("\nConnected to SimConnect!\n");
glowny();
break;
} else {
hr = SimConnect_Close(hSimConnect);
Sleep(5000);
q++;
printf(".");
}
if(q>60){
printf("\nFailed to Connect with SimConnect\n");
break;
}
}
// Close
hr = SimConnect_Close(hSimConnect);
return 0;
}