Input.cs 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Input.cs
  6. //
  7. // Copyright 2015 Xamarin Inc. All rights reserved.
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using System.Collections.Generic;
  11. using Urho.Urho2D;
  12. using Urho.Gui;
  13. using Urho.Resources;
  14. using Urho.IO;
  15. using Urho.Navigation;
  16. using Urho.Network;
  17. namespace Urho
  18. {
  19. /// <summary>
  20. /// %Input subsystem. Converts operating system window messages to input state and events.
  21. /// </summary>
  22. public unsafe partial class Input : UrhoObject
  23. {
  24. unsafe partial void OnInputCreated ();
  25. [Preserve]
  26. public Input (IntPtr handle) : base (handle)
  27. {
  28. OnInputCreated ();
  29. }
  30. [Preserve]
  31. protected Input (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnInputCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Input_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Input_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Input_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Input_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Input_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Input));
  54. return new StringHash (Input_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Input_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Input));
  61. return Marshal.PtrToStringAnsi (Input_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Input () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Input_Input (IntPtr context);
  69. [Preserve]
  70. public Input (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Input));
  73. handle = Input_Input ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnInputCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern void Input_Update (IntPtr handle);
  79. /// <summary>
  80. /// Poll for window messages. Called by HandleBeginFrame().
  81. /// </summary>
  82. public void Update ()
  83. {
  84. Runtime.ValidateRefCounted (this);
  85. Input_Update (handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern void Input_SetToggleFullscreen (IntPtr handle, bool enable);
  89. /// <summary>
  90. /// Set whether ALT-ENTER fullscreen toggle is enabled.
  91. /// </summary>
  92. private void SetToggleFullscreen (bool enable)
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. Input_SetToggleFullscreen (handle, enable);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern void Input_SetMouseVisible (IntPtr handle, bool enable, bool suppressEvent);
  99. /// <summary>
  100. /// Set whether the operating system mouse cursor is visible. When not visible (default), is kept centered to prevent leaving the window. Mouse visibility event can be suppressed-- this also recalls any unsuppressed SetMouseVisible which can be returned by ResetMouseVisible().
  101. /// </summary>
  102. public void SetMouseVisible (bool enable, bool suppressEvent = false)
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. Input_SetMouseVisible (handle, enable, suppressEvent);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern void Input_ResetMouseVisible (IntPtr handle);
  109. /// <summary>
  110. /// Reset last mouse visibility that was not suppressed in SetMouseVisible.
  111. /// </summary>
  112. public void ResetMouseVisible ()
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. Input_ResetMouseVisible (handle);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern void Input_SetMouseGrabbed (IntPtr handle, bool grab, bool suppressEvent);
  119. /// <summary>
  120. /// Set whether the mouse is currently being grabbed by an operation.
  121. /// </summary>
  122. public void SetMouseGrabbed (bool grab, bool suppressEvent = false)
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. Input_SetMouseGrabbed (handle, grab, suppressEvent);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern void Input_ResetMouseGrabbed (IntPtr handle);
  129. /// <summary>
  130. /// Reset the mouse grabbed to the last unsuppressed SetMouseGrabbed call
  131. /// </summary>
  132. public void ResetMouseGrabbed ()
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. Input_ResetMouseGrabbed (handle);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern void Input_SetMouseMode (IntPtr handle, MouseMode mode, bool suppressEvent);
  139. /// <summary>
  140. /// Set the mouse mode.
  141. /// Set the mouse mode behaviour.
  142. /// MM_ABSOLUTE is the default behaviour, allowing the toggling of operating system cursor visibility and allowing the cursor to escape the window when visible.
  143. /// When the operating system cursor is invisible in absolute mouse mode, the mouse is confined to the window.
  144. /// If the operating system and UI cursors are both invisible, interaction with the Urho UI will be limited (eg: drag move / drag end events will not trigger).
  145. /// SetMouseMode(MM_ABSOLUTE) will call SetMouseGrabbed(false).
  146. /// MM_RELATIVE sets the operating system cursor to invisible and confines the cursor to the window.
  147. /// The operating system cursor cannot be set to be visible in this mode via SetMouseVisible(), however changes are tracked and will be restored when another mouse mode is set.
  148. /// When the virtual cursor is also invisible, UI interaction will still function as normal (eg: drag events will trigger).
  149. /// SetMouseMode(MM_RELATIVE) will call SetMouseGrabbed(true).
  150. /// MM_WRAP grabs the mouse from the operating system and confines the operating system cursor to the window, wrapping the cursor when it is near the edges.
  151. /// SetMouseMode(MM_WRAP) will call SetMouseGrabbed(true).
  152. /// MM_FREE does not grab/confine the mouse cursor even when it is hidden. This can be used for cases where the cursor should render using the operating system
  153. /// outside the window, and perform custom rendering (with SetMouseVisible(false)) inside.
  154. /// </summary>
  155. public void SetMouseMode (MouseMode mode, bool suppressEvent = false)
  156. {
  157. Runtime.ValidateRefCounted (this);
  158. Input_SetMouseMode (handle, mode, suppressEvent);
  159. }
  160. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  161. internal static extern void Input_ResetMouseMode (IntPtr handle);
  162. /// <summary>
  163. /// Reset the last mouse mode that wasn't suppressed in SetMouseMode
  164. /// </summary>
  165. public void ResetMouseMode ()
  166. {
  167. Runtime.ValidateRefCounted (this);
  168. Input_ResetMouseMode (handle);
  169. }
  170. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  171. internal static extern int Input_AddScreenJoystick (IntPtr handle, IntPtr layoutFile, IntPtr styleFile);
  172. /// <summary>
  173. /// Add screen joystick.
  174. /// Return the joystick instance ID when successful or negative on error.
  175. /// If layout file is not given, use the default screen joystick layout.
  176. /// If style file is not given, use the default style file from root UI element.
  177. /// This method should only be called in main thread.
  178. /// </summary>
  179. public int AddScreenJoystick (Urho.Resources.XmlFile layoutFile = null, Urho.Resources.XmlFile styleFile = null)
  180. {
  181. Runtime.ValidateRefCounted (this);
  182. return Input_AddScreenJoystick (handle, (object)layoutFile == null ? IntPtr.Zero : layoutFile.Handle, (object)styleFile == null ? IntPtr.Zero : styleFile.Handle);
  183. }
  184. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  185. internal static extern bool Input_RemoveScreenJoystick (IntPtr handle, int id);
  186. /// <summary>
  187. /// Remove screen joystick by instance ID.
  188. /// Return true if successful.
  189. /// This method should only be called in main thread.
  190. /// </summary>
  191. public bool RemoveScreenJoystick (int id)
  192. {
  193. Runtime.ValidateRefCounted (this);
  194. return Input_RemoveScreenJoystick (handle, id);
  195. }
  196. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  197. internal static extern void Input_SetScreenJoystickVisible (IntPtr handle, int id, bool enable);
  198. /// <summary>
  199. /// Set whether the virtual joystick is visible.
  200. /// </summary>
  201. public void SetScreenJoystickVisible (int id, bool enable)
  202. {
  203. Runtime.ValidateRefCounted (this);
  204. Input_SetScreenJoystickVisible (handle, id, enable);
  205. }
  206. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  207. internal static extern void Input_SetScreenKeyboardVisible (IntPtr handle, bool enable);
  208. /// <summary>
  209. /// Show or hide on-screen keyboard on platforms that support it. When shown, keypresses from it are delivered as key events.
  210. /// </summary>
  211. private void SetScreenKeyboardVisible (bool enable)
  212. {
  213. Runtime.ValidateRefCounted (this);
  214. Input_SetScreenKeyboardVisible (handle, enable);
  215. }
  216. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  217. internal static extern void Input_SetTouchEmulation (IntPtr handle, bool enable);
  218. /// <summary>
  219. /// Set touch emulation by mouse. Only available on desktop platforms. When enabled, actual mouse events are no longer sent and the mouse cursor is forced visible.
  220. /// </summary>
  221. private void SetTouchEmulation (bool enable)
  222. {
  223. Runtime.ValidateRefCounted (this);
  224. Input_SetTouchEmulation (handle, enable);
  225. }
  226. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  227. internal static extern void Input_SetEnabled (IntPtr handle, bool enable);
  228. /// <summary>
  229. /// Enabled or disable Input
  230. /// </summary>
  231. private void SetEnabled (bool enable)
  232. {
  233. Runtime.ValidateRefCounted (this);
  234. Input_SetEnabled (handle, enable);
  235. }
  236. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  237. internal static extern bool Input_RecordGesture (IntPtr handle);
  238. /// <summary>
  239. /// Begin recording a touch gesture. Return true if successful. The E_GESTURERECORDED event (which contains the ID for the new gesture) will be sent when recording finishes.
  240. /// </summary>
  241. public bool RecordGesture ()
  242. {
  243. Runtime.ValidateRefCounted (this);
  244. return Input_RecordGesture (handle);
  245. }
  246. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  247. internal static extern bool Input_SaveGestures_File (IntPtr handle, IntPtr dest);
  248. /// <summary>
  249. /// Save all in-memory touch gestures. Return true if successful.
  250. /// </summary>
  251. public bool SaveGestures (File dest)
  252. {
  253. Runtime.ValidateRefCounted (this);
  254. return Input_SaveGestures_File (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  255. }
  256. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  257. internal static extern bool Input_SaveGestures_MemoryBuffer (IntPtr handle, IntPtr dest);
  258. /// <summary>
  259. /// Save all in-memory touch gestures. Return true if successful.
  260. /// </summary>
  261. public bool SaveGestures (MemoryBuffer dest)
  262. {
  263. Runtime.ValidateRefCounted (this);
  264. return Input_SaveGestures_MemoryBuffer (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  265. }
  266. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  267. internal static extern bool Input_SaveGesture_File (IntPtr handle, IntPtr dest, uint gestureID);
  268. /// <summary>
  269. /// Save a specific in-memory touch gesture to a file. Return true if successful.
  270. /// </summary>
  271. public bool SaveGesture (File dest, uint gestureID)
  272. {
  273. Runtime.ValidateRefCounted (this);
  274. return Input_SaveGesture_File (handle, (object)dest == null ? IntPtr.Zero : dest.Handle, gestureID);
  275. }
  276. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  277. internal static extern bool Input_SaveGesture_MemoryBuffer (IntPtr handle, IntPtr dest, uint gestureID);
  278. /// <summary>
  279. /// Save a specific in-memory touch gesture to a file. Return true if successful.
  280. /// </summary>
  281. public bool SaveGesture (MemoryBuffer dest, uint gestureID)
  282. {
  283. Runtime.ValidateRefCounted (this);
  284. return Input_SaveGesture_MemoryBuffer (handle, (object)dest == null ? IntPtr.Zero : dest.Handle, gestureID);
  285. }
  286. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  287. internal static extern uint Input_LoadGestures_File (IntPtr handle, IntPtr source);
  288. /// <summary>
  289. /// Load touch gestures from a file. Return number of loaded gestures, or 0 on failure.
  290. /// </summary>
  291. public uint LoadGestures (File source)
  292. {
  293. Runtime.ValidateRefCounted (this);
  294. return Input_LoadGestures_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  295. }
  296. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  297. internal static extern uint Input_LoadGestures_MemoryBuffer (IntPtr handle, IntPtr source);
  298. /// <summary>
  299. /// Load touch gestures from a file. Return number of loaded gestures, or 0 on failure.
  300. /// </summary>
  301. public uint LoadGestures (MemoryBuffer source)
  302. {
  303. Runtime.ValidateRefCounted (this);
  304. return Input_LoadGestures_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  305. }
  306. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  307. internal static extern bool Input_RemoveGesture (IntPtr handle, uint gestureID);
  308. /// <summary>
  309. /// Remove an in-memory gesture by ID. Return true if was found.
  310. /// </summary>
  311. public bool RemoveGesture (uint gestureID)
  312. {
  313. Runtime.ValidateRefCounted (this);
  314. return Input_RemoveGesture (handle, gestureID);
  315. }
  316. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  317. internal static extern void Input_RemoveAllGestures (IntPtr handle);
  318. /// <summary>
  319. /// Remove all in-memory gestures.
  320. /// </summary>
  321. public void RemoveAllGestures ()
  322. {
  323. Runtime.ValidateRefCounted (this);
  324. Input_RemoveAllGestures (handle);
  325. }
  326. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  327. internal static extern void Input_SetMousePosition (IntPtr handle, ref Urho.IntVector2 position);
  328. /// <summary>
  329. /// Set the mouse cursor position. Uses the backbuffer (Graphics width/height) coordinates.
  330. /// </summary>
  331. public void SetMousePosition (Urho.IntVector2 position)
  332. {
  333. Runtime.ValidateRefCounted (this);
  334. Input_SetMousePosition (handle, ref position);
  335. }
  336. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  337. internal static extern void Input_CenterMousePosition (IntPtr handle);
  338. /// <summary>
  339. /// Center the mouse position.
  340. /// </summary>
  341. public void CenterMousePosition ()
  342. {
  343. Runtime.ValidateRefCounted (this);
  344. Input_CenterMousePosition (handle);
  345. }
  346. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  347. internal static extern int Input_GetKeyFromName (IntPtr handle, string name);
  348. /// <summary>
  349. /// Return keycode from key name.
  350. /// </summary>
  351. public int GetKeyFromName (string name)
  352. {
  353. Runtime.ValidateRefCounted (this);
  354. return Input_GetKeyFromName (handle, name);
  355. }
  356. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  357. internal static extern int Input_GetKeyFromScancode (IntPtr handle, int scancode);
  358. /// <summary>
  359. /// Return keycode from scancode.
  360. /// </summary>
  361. public int GetKeyFromScancode (int scancode)
  362. {
  363. Runtime.ValidateRefCounted (this);
  364. return Input_GetKeyFromScancode (handle, scancode);
  365. }
  366. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  367. internal static extern IntPtr Input_GetKeyName (IntPtr handle, int key);
  368. /// <summary>
  369. /// Return name of key from keycode.
  370. /// </summary>
  371. public string GetKeyName (Key key)
  372. {
  373. Runtime.ValidateRefCounted (this);
  374. return Marshal.PtrToStringAnsi (Input_GetKeyName (handle, (int)key));
  375. }
  376. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  377. internal static extern int Input_GetScancodeFromKey (IntPtr handle, int key);
  378. /// <summary>
  379. /// Return scancode from keycode.
  380. /// </summary>
  381. public int GetScancodeFromKey (Key key)
  382. {
  383. Runtime.ValidateRefCounted (this);
  384. return Input_GetScancodeFromKey (handle, (int)key);
  385. }
  386. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  387. internal static extern int Input_GetScancodeFromName (IntPtr handle, string name);
  388. /// <summary>
  389. /// Return scancode from key name.
  390. /// </summary>
  391. public int GetScancodeFromName (string name)
  392. {
  393. Runtime.ValidateRefCounted (this);
  394. return Input_GetScancodeFromName (handle, name);
  395. }
  396. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  397. internal static extern IntPtr Input_GetScancodeName (IntPtr handle, int scancode);
  398. /// <summary>
  399. /// Return name of key from scancode.
  400. /// </summary>
  401. public string GetScancodeName (int scancode)
  402. {
  403. Runtime.ValidateRefCounted (this);
  404. return Marshal.PtrToStringAnsi (Input_GetScancodeName (handle, scancode));
  405. }
  406. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  407. internal static extern bool Input_GetKeyDown (IntPtr handle, int key);
  408. /// <summary>
  409. /// Check if a key is held down.
  410. /// </summary>
  411. public bool GetKeyDown (Key key)
  412. {
  413. Runtime.ValidateRefCounted (this);
  414. return Input_GetKeyDown (handle, (int)key);
  415. }
  416. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  417. internal static extern bool Input_GetKeyPress (IntPtr handle, int key);
  418. /// <summary>
  419. /// Check if a key has been pressed on this frame.
  420. /// </summary>
  421. public bool GetKeyPress (Key key)
  422. {
  423. Runtime.ValidateRefCounted (this);
  424. return Input_GetKeyPress (handle, (int)key);
  425. }
  426. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  427. internal static extern bool Input_GetScancodeDown (IntPtr handle, int scancode);
  428. /// <summary>
  429. /// Check if a key is held down by scancode.
  430. /// </summary>
  431. public bool GetScancodeDown (int scancode)
  432. {
  433. Runtime.ValidateRefCounted (this);
  434. return Input_GetScancodeDown (handle, scancode);
  435. }
  436. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  437. internal static extern bool Input_GetScancodePress (IntPtr handle, int scancode);
  438. /// <summary>
  439. /// Check if a key has been pressed on this frame by scancode.
  440. /// </summary>
  441. public bool GetScancodePress (int scancode)
  442. {
  443. Runtime.ValidateRefCounted (this);
  444. return Input_GetScancodePress (handle, scancode);
  445. }
  446. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  447. internal static extern bool Input_GetMouseButtonDown (IntPtr handle, int button);
  448. /// <summary>
  449. /// Check if a mouse button is held down.
  450. /// </summary>
  451. public bool GetMouseButtonDown (MouseButton button)
  452. {
  453. Runtime.ValidateRefCounted (this);
  454. return Input_GetMouseButtonDown (handle, (int)button);
  455. }
  456. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  457. internal static extern bool Input_GetMouseButtonPress (IntPtr handle, int button);
  458. /// <summary>
  459. /// Check if a mouse button has been pressed on this frame.
  460. /// </summary>
  461. public bool GetMouseButtonPress (MouseButton button)
  462. {
  463. Runtime.ValidateRefCounted (this);
  464. return Input_GetMouseButtonPress (handle, (int)button);
  465. }
  466. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  467. internal static extern bool Input_GetQualifierDown (IntPtr handle, int qualifier);
  468. /// <summary>
  469. /// Check if a qualifier key is held down.
  470. /// </summary>
  471. public bool GetQualifierDown (int qualifier)
  472. {
  473. Runtime.ValidateRefCounted (this);
  474. return Input_GetQualifierDown (handle, qualifier);
  475. }
  476. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  477. internal static extern bool Input_GetQualifierPress (IntPtr handle, int qualifier);
  478. /// <summary>
  479. /// Check if a qualifier key has been pressed on this frame.
  480. /// </summary>
  481. public bool GetQualifierPress (int qualifier)
  482. {
  483. Runtime.ValidateRefCounted (this);
  484. return Input_GetQualifierPress (handle, qualifier);
  485. }
  486. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  487. internal static extern int Input_GetQualifiers (IntPtr handle);
  488. /// <summary>
  489. /// Return the currently held down qualifiers.
  490. /// </summary>
  491. private int GetQualifiers ()
  492. {
  493. Runtime.ValidateRefCounted (this);
  494. return Input_GetQualifiers (handle);
  495. }
  496. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  497. internal static extern Urho.IntVector2 Input_GetMousePosition (IntPtr handle);
  498. /// <summary>
  499. /// Return mouse position within window. Should only be used with a visible mouse cursor. Uses the backbuffer (Graphics width/height) coordinates.
  500. /// </summary>
  501. private Urho.IntVector2 GetMousePosition ()
  502. {
  503. Runtime.ValidateRefCounted (this);
  504. return Input_GetMousePosition (handle);
  505. }
  506. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  507. internal static extern Urho.IntVector2 Input_GetMouseMove (IntPtr handle);
  508. /// <summary>
  509. /// Return mouse movement since last frame.
  510. /// </summary>
  511. private Urho.IntVector2 GetMouseMove ()
  512. {
  513. Runtime.ValidateRefCounted (this);
  514. return Input_GetMouseMove (handle);
  515. }
  516. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  517. internal static extern int Input_GetMouseMoveX (IntPtr handle);
  518. /// <summary>
  519. /// Return horizontal mouse movement since last frame.
  520. /// </summary>
  521. private int GetMouseMoveX ()
  522. {
  523. Runtime.ValidateRefCounted (this);
  524. return Input_GetMouseMoveX (handle);
  525. }
  526. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  527. internal static extern int Input_GetMouseMoveY (IntPtr handle);
  528. /// <summary>
  529. /// Return vertical mouse movement since last frame.
  530. /// </summary>
  531. private int GetMouseMoveY ()
  532. {
  533. Runtime.ValidateRefCounted (this);
  534. return Input_GetMouseMoveY (handle);
  535. }
  536. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  537. internal static extern int Input_GetMouseMoveWheel (IntPtr handle);
  538. /// <summary>
  539. /// Return mouse wheel movement since last frame.
  540. /// </summary>
  541. private int GetMouseMoveWheel ()
  542. {
  543. Runtime.ValidateRefCounted (this);
  544. return Input_GetMouseMoveWheel (handle);
  545. }
  546. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  547. internal static extern Vector2 Input_GetInputScale (IntPtr handle);
  548. /// <summary>
  549. /// Return input coordinate scaling. Should return non-unity on High DPI display.
  550. /// </summary>
  551. private Vector2 GetInputScale ()
  552. {
  553. Runtime.ValidateRefCounted (this);
  554. return Input_GetInputScale (handle);
  555. }
  556. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  557. internal static extern uint Input_GetNumTouches (IntPtr handle);
  558. /// <summary>
  559. /// Return number of active finger touches.
  560. /// </summary>
  561. private uint GetNumTouches ()
  562. {
  563. Runtime.ValidateRefCounted (this);
  564. return Input_GetNumTouches (handle);
  565. }
  566. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  567. internal static extern IntPtr Input_GetTouch (IntPtr handle, uint index);
  568. /// <summary>
  569. /// Return active finger touch by index.
  570. /// </summary>
  571. public TouchState GetTouch (uint index)
  572. {
  573. Runtime.ValidateRefCounted (this);
  574. return (TouchState)Marshal.PtrToStructure (Input_GetTouch (handle, index), typeof(TouchState));
  575. }
  576. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  577. internal static extern uint Input_GetNumJoysticks (IntPtr handle);
  578. /// <summary>
  579. /// Return number of connected joysticks.
  580. /// </summary>
  581. private uint GetNumJoysticks ()
  582. {
  583. Runtime.ValidateRefCounted (this);
  584. return Input_GetNumJoysticks (handle);
  585. }
  586. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  587. internal static extern JoystickState* Input_GetJoystick (IntPtr handle, int id);
  588. /// <summary>
  589. /// Return joystick state by ID, or null if does not exist.
  590. /// </summary>
  591. public JoystickState* GetJoystick (int id)
  592. {
  593. Runtime.ValidateRefCounted (this);
  594. return Input_GetJoystick (handle, id);
  595. }
  596. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  597. internal static extern JoystickState* Input_GetJoystickByIndex (IntPtr handle, uint index);
  598. /// <summary>
  599. /// Return joystick state by index, or null if does not exist. 0 = first connected joystick.
  600. /// </summary>
  601. public JoystickState* GetJoystickByIndex (uint index)
  602. {
  603. Runtime.ValidateRefCounted (this);
  604. return Input_GetJoystickByIndex (handle, index);
  605. }
  606. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  607. internal static extern JoystickState* Input_GetJoystickByName (IntPtr handle, string name);
  608. /// <summary>
  609. /// Return joystick state by name, or null if does not exist.
  610. /// </summary>
  611. public JoystickState* GetJoystickByName (string name)
  612. {
  613. Runtime.ValidateRefCounted (this);
  614. return Input_GetJoystickByName (handle, name);
  615. }
  616. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  617. internal static extern bool Input_GetToggleFullscreen (IntPtr handle);
  618. /// <summary>
  619. /// Return whether fullscreen toggle is enabled.
  620. /// </summary>
  621. private bool GetToggleFullscreen ()
  622. {
  623. Runtime.ValidateRefCounted (this);
  624. return Input_GetToggleFullscreen (handle);
  625. }
  626. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  627. internal static extern bool Input_IsScreenJoystickVisible (IntPtr handle, int id);
  628. /// <summary>
  629. /// Return whether a virtual joystick is visible.
  630. /// </summary>
  631. public bool IsScreenJoystickVisible (int id)
  632. {
  633. Runtime.ValidateRefCounted (this);
  634. return Input_IsScreenJoystickVisible (handle, id);
  635. }
  636. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  637. internal static extern bool Input_GetScreenKeyboardSupport (IntPtr handle);
  638. /// <summary>
  639. /// Return whether on-screen keyboard is supported.
  640. /// </summary>
  641. private bool GetScreenKeyboardSupport ()
  642. {
  643. Runtime.ValidateRefCounted (this);
  644. return Input_GetScreenKeyboardSupport (handle);
  645. }
  646. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  647. internal static extern bool Input_IsScreenKeyboardVisible (IntPtr handle);
  648. /// <summary>
  649. /// Return whether on-screen keyboard is being shown.
  650. /// </summary>
  651. private bool IsScreenKeyboardVisible ()
  652. {
  653. Runtime.ValidateRefCounted (this);
  654. return Input_IsScreenKeyboardVisible (handle);
  655. }
  656. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  657. internal static extern bool Input_GetTouchEmulation (IntPtr handle);
  658. /// <summary>
  659. /// Return whether touch emulation is enabled.
  660. /// </summary>
  661. private bool GetTouchEmulation ()
  662. {
  663. Runtime.ValidateRefCounted (this);
  664. return Input_GetTouchEmulation (handle);
  665. }
  666. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  667. internal static extern bool Input_IsMouseVisible (IntPtr handle);
  668. /// <summary>
  669. /// Return whether the operating system mouse cursor is visible.
  670. /// </summary>
  671. private bool IsMouseVisible ()
  672. {
  673. Runtime.ValidateRefCounted (this);
  674. return Input_IsMouseVisible (handle);
  675. }
  676. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  677. internal static extern bool Input_IsMouseGrabbed (IntPtr handle);
  678. /// <summary>
  679. /// Return whether the mouse is currently being grabbed by an operation.
  680. /// </summary>
  681. private bool IsMouseGrabbed ()
  682. {
  683. Runtime.ValidateRefCounted (this);
  684. return Input_IsMouseGrabbed (handle);
  685. }
  686. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  687. internal static extern bool Input_IsMouseLocked (IntPtr handle);
  688. /// <summary>
  689. /// Return whether the mouse is locked to the window
  690. /// </summary>
  691. private bool IsMouseLocked ()
  692. {
  693. Runtime.ValidateRefCounted (this);
  694. return Input_IsMouseLocked (handle);
  695. }
  696. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  697. internal static extern MouseMode Input_GetMouseMode (IntPtr handle);
  698. /// <summary>
  699. /// Return the mouse mode.
  700. /// </summary>
  701. private MouseMode GetMouseMode ()
  702. {
  703. Runtime.ValidateRefCounted (this);
  704. return Input_GetMouseMode (handle);
  705. }
  706. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  707. internal static extern bool Input_HasFocus (IntPtr handle);
  708. /// <summary>
  709. /// Return whether application window has input focus.
  710. /// </summary>
  711. public bool HasFocus ()
  712. {
  713. Runtime.ValidateRefCounted (this);
  714. return Input_HasFocus (handle);
  715. }
  716. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  717. internal static extern bool Input_IsEnabled (IntPtr handle);
  718. /// <summary>
  719. /// Return whether Input is enabled.
  720. /// </summary>
  721. private bool IsEnabled ()
  722. {
  723. Runtime.ValidateRefCounted (this);
  724. return Input_IsEnabled (handle);
  725. }
  726. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  727. internal static extern bool Input_IsMinimized (IntPtr handle);
  728. /// <summary>
  729. /// Return whether application window is minimized.
  730. /// </summary>
  731. private bool IsMinimized ()
  732. {
  733. Runtime.ValidateRefCounted (this);
  734. return Input_IsMinimized (handle);
  735. }
  736. public override StringHash Type {
  737. get {
  738. return UrhoGetType ();
  739. }
  740. }
  741. public override string TypeName {
  742. get {
  743. return GetTypeName ();
  744. }
  745. }
  746. [Preserve]
  747. public static StringHash TypeStatic {
  748. get {
  749. return GetTypeStatic ();
  750. }
  751. }
  752. public static string TypeNameStatic {
  753. get {
  754. return GetTypeNameStatic ();
  755. }
  756. }
  757. /// <summary>
  758. /// Return whether fullscreen toggle is enabled.
  759. /// Or
  760. /// Set whether ALT-ENTER fullscreen toggle is enabled.
  761. /// </summary>
  762. public bool ToggleFullscreen {
  763. get {
  764. return GetToggleFullscreen ();
  765. }
  766. set {
  767. SetToggleFullscreen (value);
  768. }
  769. }
  770. /// <summary>
  771. /// Return whether on-screen keyboard is being shown.
  772. /// Or
  773. /// Show or hide on-screen keyboard on platforms that support it. When shown, keypresses from it are delivered as key events.
  774. /// </summary>
  775. public bool ScreenKeyboardVisible {
  776. get {
  777. return IsScreenKeyboardVisible ();
  778. }
  779. set {
  780. SetScreenKeyboardVisible (value);
  781. }
  782. }
  783. /// <summary>
  784. /// Return whether touch emulation is enabled.
  785. /// Or
  786. /// Set touch emulation by mouse. Only available on desktop platforms. When enabled, actual mouse events are no longer sent and the mouse cursor is forced visible.
  787. /// </summary>
  788. public bool TouchEmulation {
  789. get {
  790. return GetTouchEmulation ();
  791. }
  792. set {
  793. SetTouchEmulation (value);
  794. }
  795. }
  796. /// <summary>
  797. /// Return whether Input is enabled.
  798. /// Or
  799. /// Enabled or disable Input
  800. /// </summary>
  801. public bool Enabled {
  802. get {
  803. return IsEnabled ();
  804. }
  805. set {
  806. SetEnabled (value);
  807. }
  808. }
  809. /// <summary>
  810. /// Return mouse position within window. Should only be used with a visible mouse cursor. Uses the backbuffer (Graphics width/height) coordinates.
  811. /// </summary>
  812. public Urho.IntVector2 MousePosition {
  813. get {
  814. return GetMousePosition ();
  815. }
  816. }
  817. /// <summary>
  818. /// Return the currently held down qualifiers.
  819. /// </summary>
  820. public int Qualifiers {
  821. get {
  822. return GetQualifiers ();
  823. }
  824. }
  825. /// <summary>
  826. /// Return mouse movement since last frame.
  827. /// </summary>
  828. public Urho.IntVector2 MouseMove {
  829. get {
  830. return GetMouseMove ();
  831. }
  832. }
  833. /// <summary>
  834. /// Return horizontal mouse movement since last frame.
  835. /// </summary>
  836. public int MouseMoveX {
  837. get {
  838. return GetMouseMoveX ();
  839. }
  840. }
  841. /// <summary>
  842. /// Return vertical mouse movement since last frame.
  843. /// </summary>
  844. public int MouseMoveY {
  845. get {
  846. return GetMouseMoveY ();
  847. }
  848. }
  849. /// <summary>
  850. /// Return mouse wheel movement since last frame.
  851. /// </summary>
  852. public int MouseMoveWheel {
  853. get {
  854. return GetMouseMoveWheel ();
  855. }
  856. }
  857. /// <summary>
  858. /// Return input coordinate scaling. Should return non-unity on High DPI display.
  859. /// </summary>
  860. public Vector2 InputScale {
  861. get {
  862. return GetInputScale ();
  863. }
  864. }
  865. /// <summary>
  866. /// Return number of active finger touches.
  867. /// </summary>
  868. public uint NumTouches {
  869. get {
  870. return GetNumTouches ();
  871. }
  872. }
  873. /// <summary>
  874. /// Return number of connected joysticks.
  875. /// </summary>
  876. public uint NumJoysticks {
  877. get {
  878. return GetNumJoysticks ();
  879. }
  880. }
  881. /// <summary>
  882. /// Return whether on-screen keyboard is supported.
  883. /// </summary>
  884. public bool ScreenKeyboardSupport {
  885. get {
  886. return GetScreenKeyboardSupport ();
  887. }
  888. }
  889. /// <summary>
  890. /// Return whether the operating system mouse cursor is visible.
  891. /// </summary>
  892. public bool MouseVisible {
  893. get {
  894. return IsMouseVisible ();
  895. }
  896. }
  897. /// <summary>
  898. /// Return whether the mouse is currently being grabbed by an operation.
  899. /// </summary>
  900. public bool MouseGrabbed {
  901. get {
  902. return IsMouseGrabbed ();
  903. }
  904. }
  905. /// <summary>
  906. /// Return whether the mouse is locked to the window
  907. /// </summary>
  908. public bool MouseLocked {
  909. get {
  910. return IsMouseLocked ();
  911. }
  912. }
  913. /// <summary>
  914. /// Return the mouse mode.
  915. /// </summary>
  916. public MouseMode MouseMode {
  917. get {
  918. return GetMouseMode ();
  919. }
  920. }
  921. /// <summary>
  922. /// Return whether application window is minimized.
  923. /// </summary>
  924. public bool Minimized {
  925. get {
  926. return IsMinimized ();
  927. }
  928. }
  929. }
  930. }