1 /********************************************************************
2 * COPYRIGHT PARROT 2010
3 ********************************************************************
4 * PARROT - A.R.Drone SDK Windows Client Example
5 *-----------------------------------------------------------------*/
8 * @brief User added code
10 * @author sylvain.gaeremynck@parrot.com
13 * @author Stephane Piskorski <stephane.piskorski.ext@parrot.fr>
16 *******************************************************************/
20 #include <custom_code.h>
23 #include <ardrone_tool/ardrone_time.h>
24 #include <ardrone_tool/Navdata/ardrone_navdata_client.h>
25 #include <ardrone_tool/Control/ardrone_control.h>
26 #include <ardrone_tool/UI/ardrone_input.h>
30 #include <ardrone_api.h>
33 #include <ATcodec/ATcodec_api.h>
34 #include <VP_Os/vp_os_print.h>
35 #include <VP_Api/vp_api_thread_helper.h>
36 #include <VP_Os/vp_os_signal.h>
39 #include <UI/gamepad.h>
40 #include <Video/video_stage.h>
41 #include <UI/directx_rendering.h>
44 int32_t exit_ihm_program = 1;
45 vp_os_mutex_t consoleMutex;
48 /* Implementing Custom methods for the main function of an ARDrone application */
52 /*--------------------------------------------------------------------
53 The delegate object calls this method during initialization of an
55 --------------------------------------------------------------------*/
56 C_RESULT ardrone_tool_init_custom(int argc, char **argv)
58 /* Change the console title */
59 vp_os_mutex_init(&consoleMutex);
61 SetConsoleTitle(TEXT("Parrot A.R. Drone SDK Demo for Windows"));
62 //CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&HmiStart,NULL,0,0);
63 //CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&HmiStart2,NULL,0,0);
66 /* Registering for a new device of game controller */
67 ardrone_tool_input_add( &dx_keyboard );
68 ardrone_tool_input_add( &dx_gamepad );
70 /* Start all threads of your application */
71 START_THREAD( directx_renderer_thread , NULL);
72 START_THREAD( video_stage, NULL );
81 /*--------------------------------------------------------------------
82 The delegate object calls this method when the event loop exit
83 --------------------------------------------------------------------*/
84 C_RESULT ardrone_tool_shutdown_custom()
86 /* Relinquish all threads of your application */
87 JOIN_THREAD( video_stage );
89 /* Unregistering for the current device */
90 ardrone_tool_input_remove( &dx_gamepad );
91 ardrone_tool_input_remove( &dx_keyboard );
93 /* Mutex needs to be destroyed but may still be used by navdata thread */
94 /* todo : synchronize threads shutdown */
95 //vp_os_mutex_destroy(&consoleMutex);
100 /*--------------------------------------------------------------------
101 The event loop calls this method for the exit condition
102 --------------------------------------------------------------------*/
103 bool_t ardrone_tool_exit()
105 return exit_ihm_program == 0;
108 C_RESULT signal_exit()
110 exit_ihm_program = 0;
115 int custom_main(int argc,char**argv) { return 0;};
118 /* Implementing thread table in which you add routines of your application and those provided by the SDK */
120 THREAD_TABLE_ENTRY( ardrone_control, 20 )
121 THREAD_TABLE_ENTRY( navdata_update, 20 )
122 THREAD_TABLE_ENTRY( video_stage, 20 )
123 THREAD_TABLE_ENTRY( directx_renderer_thread, 20 )
128 /* Function to change the cursor place in the console window */
130 HANDLE hStdout = NULL; /* Handle to the output console */
\r
131 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; /* Information about the output console */
135 void ARWin32Demo_SetConsoleCursor(int x,int y)
137 if (hStdout==NULL) hStdout=GetStdHandle(STD_OUTPUT_HANDLE);
139 if (hStdout != INVALID_HANDLE_VALUE){
\r
140 GetConsoleScreenBufferInfo(hStdout, &csbiInfo);
\r
141 csbiInfo.dwCursorPosition.X=x;
\r
142 csbiInfo.dwCursorPosition.Y=y;
\r
143 SetConsoleCursorPosition(hStdout,csbiInfo.dwCursorPosition);
\r
147 void ARWin32Demo_AcquireConsole(int x,int y)
\r
149 vp_os_mutex_lock(&consoleMutex);
\r
151 void ARWin32Demo_ReleaseConsole(int x,int y)
\r
153 vp_os_mutex_unlock(&consoleMutex);
\r