1 /*
2
3 Helper functions for touch devices
4
5 */
6
7 #ifdef WIN32
8 #define WINDOWS_VERSION
9 #define WIN32_LEAN_AND_MEAN
10 #include <windows.h>
11 #pragma warning(disable : 4244)
12 #endif
13
14 #if !defined(BUILTIN_PLUGINS)
15 #define THIS_IS_THE_PLUGIN
16 #endif
17
18 #include "plugin/agsplugin.h"
19
20 #if defined(BUILTIN_PLUGINS)
21 namespace agstouch {
22 #endif
23
24 IAGSEngine* engine;
25
26
27 #if defined(IOS_VERSION)
28
29 extern "C"
30 {
31 void ios_show_keyboard();
32 void ios_hide_keyboard();
33 int ios_is_keyboard_visible();
34 }
35
36 #endif
37
38
39
40 // ********************************************
41 // ************ AGS Interface ***************
42 // ********************************************
43
44
TouchShowKeyboard()45 void TouchShowKeyboard()
46 {
47 #if defined(IOS_VERSION)
48 ios_show_keyboard();
49 #endif
50 }
51
52
TouchHideKeyboard()53 void TouchHideKeyboard()
54 {
55 #if defined(IOS_VERSION)
56 ios_hide_keyboard();
57 #endif
58 }
59
60
TouchIsKeyboardVisible()61 bool TouchIsKeyboardVisible()
62 {
63 #if defined(IOS_VERSION)
64 return (ios_is_keyboard_visible() != 0);
65 #else
66 return false;
67 #endif
68 }
69
70
AGS_EngineStartup(IAGSEngine * lpEngine)71 void AGS_EngineStartup(IAGSEngine *lpEngine)
72 {
73 engine = lpEngine;
74
75 engine->RegisterScriptFunction("TouchShowKeyboard", (void*)&TouchShowKeyboard);
76 engine->RegisterScriptFunction("TouchHideKeyboard", (void*)&TouchHideKeyboard);
77 engine->RegisterScriptFunction("TouchIsKeyboardVisible", (void*)&TouchIsKeyboardVisible);
78 }
79
AGS_EngineShutdown()80 void AGS_EngineShutdown()
81 {
82
83 }
84
AGS_EngineOnEvent(int event,int data)85 int AGS_EngineOnEvent(int event, int data)
86 {
87 return 0;
88 }
89
AGS_EngineDebugHook(const char * scriptName,int lineNum,int reserved)90 int AGS_EngineDebugHook(const char *scriptName, int lineNum, int reserved)
91 {
92 return 0;
93 }
94
AGS_EngineInitGfx(const char * driverID,void * data)95 void AGS_EngineInitGfx(const char *driverID, void *data)
96 {
97 }
98
99
100
101 #if defined(WINDOWS_VERSION) && !defined(BUILTIN_PLUGINS)
102
103 // ********************************************
104 // *********** Editor Interface *************
105 // ********************************************
106
107 const char* scriptHeader =
108 "import void TouchShowKeyboard();\r\n"
109 "import void TouchHideKeyboard();\r\n"
110 "import bool TouchIsKeyboardVisible();\r\n"
111 ;
112
113
114 IAGSEditor* editor;
115
116
AGS_GetPluginName(void)117 LPCSTR AGS_GetPluginName(void)
118 {
119 // Return the plugin description
120 return "Touch device control";
121 }
122
AGS_EditorStartup(IAGSEditor * lpEditor)123 int AGS_EditorStartup(IAGSEditor* lpEditor)
124 {
125 // User has checked the plugin to use it in their game
126
127 // If it's an earlier version than what we need, abort.
128 if (lpEditor->version < 1)
129 return -1;
130
131 editor = lpEditor;
132 editor->RegisterScriptHeader(scriptHeader);
133
134 // Return 0 to indicate success
135 return 0;
136 }
137
AGS_EditorShutdown()138 void AGS_EditorShutdown()
139 {
140 // User has un-checked the plugin from their game
141 editor->UnregisterScriptHeader(scriptHeader);
142 }
143
AGS_EditorProperties(HWND parent)144 void AGS_EditorProperties(HWND parent)
145 {
146 // User has chosen to view the Properties of the plugin
147 // We could load up an options dialog or something here instead
148 MessageBoxA(parent, "Touch device control plugin by JJS", "About", MB_OK | MB_ICONINFORMATION);
149 }
150
AGS_EditorSaveGame(char * buffer,int bufsize)151 int AGS_EditorSaveGame(char* buffer, int bufsize)
152 {
153 // We don't want to save any persistent data
154 return 0;
155 }
156
AGS_EditorLoadGame(char * buffer,int bufsize)157 void AGS_EditorLoadGame(char* buffer, int bufsize)
158 {
159 // Nothing to load for this plugin
160 }
161
162 #endif
163
164
165 #if defined(BUILTIN_PLUGINS)
166 }
167 #endif
168