uainput.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /** @file */
  2. // constants for device (binding device) type determine:
  3. //
  4. // EUAINPUT_DEVICE_KEYBOARD
  5. // EUAINPUT_DEVICE_MOUSE
  6. // EUAINPUT_DEVICE_KEYBOARDMOUSE
  7. // EUAINPUT_DEVICE_CONTROLLER
  8. // EUAINPUT_DEVICE_IR
  9. // -------------------------------------------------------------------------
  10. class UAIDWrapper
  11. {
  12. private void UAIDWrapper() {}
  13. private void ~UAIDWrapper() {}
  14. proto native UAInput InputP(); // get input pointer
  15. };
  16. // -------------------------------------------------------------------------
  17. class UAInput
  18. {
  19. proto native int ID(); // return input index
  20. proto native int NameHash(); // return input hash
  21. proto native int BindingCount(); // return binding count
  22. proto native int Binding( int iIndex ); // return binding at index
  23. proto native void ClearBinding(); // remove all bindings
  24. proto native void BindCombo( string sButtonName ); // bind combo to this input by name (single/ or append to existing button)
  25. proto native void BindComboByHash( int iHash ); // bind combo to this input by hash (single/ or append to existing button)
  26. proto native void AddAlternative(); // add new alternative keybind
  27. proto native void ClearAlternative( int iIndex ); // clear binding alternative by index
  28. proto native void SelectAlternative( int iIndex ); // select binding alternative by index
  29. proto native int AlternativeCount(); // get currently assigned alternative count
  30. proto native int AlternativeIndex(); // get currently selected alternative index
  31. proto native void ClearDeviceBind( int iDeviceFlags ); // clear binding for specific device(s)
  32. proto native int BindKeyCount(); // binded key count (for selected alternative)
  33. proto native int GetBindKey( int iIndex ); // binded "control" at index (for selected alternative)
  34. proto native int GetBindDevice( int iIndex ); // binded "control" device type at index (for selected alternative)
  35. proto native bool CheckBindDevice( int iIndex, int iDeviceFlags ); // compare binded device "control" type :: EUAINPUT_DEVICE_KEYBOARD for example
  36. proto native float LocalValue();
  37. proto native bool LocalPress();
  38. proto native bool LocalRelease();
  39. proto native bool LocalHold();
  40. proto native bool LocalHoldBegin();
  41. proto native bool LocalDoubleClick();
  42. proto native bool LocalClick();
  43. proto native bool IsCombo(); // return true if there is currently combo bind - use Binding() result !!!
  44. // normal state is there are no limits, input generates all the events
  45. // but if there is an limiter,
  46. proto native bool IsLimited(); // return true if there is an event limit
  47. proto native bool IsLimitConditionActive(); // return true if event limits matches current control item activity
  48. proto native bool IsPressLimit(); // if limited to PRESS
  49. proto native bool IsReleaseLimit(); // if limited to RELEASE
  50. proto native bool IsHoldLimit(); // if limited to HOLD
  51. proto native bool IsHoldBeginLimit(); // if limited to HOLDBEGIN
  52. proto native bool IsClickLimit(); // if limited to SINGLE CLICK
  53. proto native bool IsDoubleClickLimit(); // if limited to DOUBLE CLICK
  54. proto native bool HasSorting( int iIndex ); // has sorting group index?
  55. proto native void Supress(); // supress press event for next frame (while not pressed ATM - otherwise until release)
  56. proto native bool IsLocked(); // determine if locked (not active ATM)
  57. proto native void Lock(); // lock (until unlock called or exclusion is selected)
  58. proto native void Unlock(); // unlock exclusively
  59. proto native int ConflictCount(); // get number of conflicts with other inputs
  60. proto native void ForceEnable( bool bEnable ); // force enable on/ off
  61. proto native void ForceDisable( bool bEnable ); // force disable on/ off
  62. proto native void Backlit_Override( int eType, int iColor ); // enable/ disable backlit of associated controls (EUABACKLIT_*)
  63. proto native bool Backlit_Enabled(); // check whether associated controls are backlit
  64. proto native UAIDWrapper GetPersistentWrapper(); // create persistent object for input access
  65. private void UAInput();
  66. private void ~UAInput();
  67. };
  68. // -------------------------------------------------------------------------
  69. class UAInterface
  70. {
  71. private void UAInterface() {}
  72. private void ~UAInterface() {}
  73. // getting action state
  74. /**
  75. \brief Get action state
  76. @param action id of action, defined in \ref 4_World/Classes/UserActionsComponent/_constants.c
  77. @param check_focus if true and game is unfocused, returns 0; otherwise returns actual value
  78. @return actual action state as float, for regular two state buttons returns 0 or 1, for analog buttons/axes returns value in interval <0, 1> with consideration of defined deadzones
  79. @see SyncedValue()
  80. */
  81. proto native float SyncedValue_ID(int action, bool check_focus = true);
  82. proto native float SyncedValue(string action, bool check_focus = true);
  83. /**
  84. \brief Returns true just in frame, when action was invoked (button was pressed)
  85. @param action id of action, defined in \ref 4_World/Classes/UserActionsComponent/_constants.c
  86. @param check_focus if true and game is unfocused, returns 0; otherwise returns actual value
  87. @return true if action was invoked in that frame, false otherwise
  88. @see SyncedPress()
  89. */
  90. proto native bool SyncedPress_ID(int action, bool check_focus = true);
  91. proto native bool SyncedPress(string action, bool check_focus = true);
  92. /**
  93. \brief Returns true just in frame, when release action happened (button was released)
  94. @param action id of action, defined in \ref 4_World/Classes/UserActionsComponent/_constants.c
  95. @param check_focus if true and game is unfocused, returns 0; otherwise returns actual value
  96. @return true if action was released in that frame, false otherwise
  97. @see SyncedRelease()
  98. */
  99. proto native bool SyncedRelease_ID(int action, bool check_focus = true);
  100. proto native bool SyncedRelease(string action, bool check_focus = true);
  101. /**
  102. \brief Returns true just in frame, when hold action invoked (button is hold)
  103. @param action id of action, defined in \ref 4_World/Classes/UserActionsComponent/_constants.c
  104. @param check_focus if true and game is unfocused, returns 0; otherwise returns actual value
  105. @return true if action was released in that frame, false otherwise
  106. @see SyncedHold()
  107. */
  108. proto native bool SyncedHold_ID(int action, bool check_focus = true);
  109. proto native bool SyncedHold(string action, bool check_focus = true);
  110. /**
  111. \brief Returns true just in frame, when double click action invoked (button double clicked)
  112. @param action id of action, defined in \ref 4_World/Classes/UserActionsComponent/_constants.c
  113. @param check_focus if true and game is unfocused, returns 0; otherwise returns actual value
  114. @return true if action was released in that frame, false otherwise
  115. @see SyncedDbl()
  116. */
  117. proto native bool SyncedDbl_ID(int action, bool check_focus = true);
  118. proto native bool SyncedDbl(string action, bool check_focus = true);
  119. /**
  120. \brief Returns true just in frame, when single click action invoked (button pressed and released before hold timer)
  121. @param action id of action, defined in \ref 4_World/Classes/UserActionsComponent/_constants.c
  122. @param check_focus if true and game is unfocused, returns 0; otherwise returns actual value
  123. @return true if action was released in that frame, false otherwise
  124. @see SyncedClick()
  125. */
  126. proto native bool SyncedClick_ID(int action, bool check_focus = true);
  127. proto native bool SyncedClick(string action, bool check_focus = true);
  128. };
  129. // -------------------------------------------------------------------------
  130. class UAInputAPI
  131. {
  132. private void UAInputAPI() {}
  133. private void ~UAInputAPI() {}
  134. proto native void ListCurrentProfile();
  135. proto native void ListCurrentPreset();
  136. proto native void ListAvailableButtons();
  137. proto native void ListActiveGroup();
  138. proto native void GetActiveInputs( out TIntArray items ); //! returns list of all bindable (i.e. visible) inputs from the active group ('core' by default)
  139. proto native UAInput GetInputByID( int iID );
  140. proto native UAInput GetInputByName( string sInputName );
  141. proto native owned string GetButtonName( int iHash ); // get localized name for any button hash
  142. proto native owned string GetButtonIcon( int iHash ); // get associated icon path for any button hash
  143. proto native int ModificatorCount(); // modificator count
  144. proto native owned string GetModificatorName( int index ); // modificator name
  145. // for options only mapping, do not call normally as it is not performance wise!
  146. proto native int DeterminePressedButton(); // recently pressed key, mouse button or pad button (returns zero if nothing pressed)
  147. proto native int DeterminedCount(); // all buttons (keys, etc.) pressed during determination test (call only when DeterminePressedButton() returned something !)
  148. proto native int GetDetermined( int iIndex ); // total count of pressed buttons (call only when DeterminePressedButton() returned something !)
  149. proto native UAInput RegisterInput( string sInputName, string sLoc, string sGroupName );
  150. proto native void DeRegisterInput( string sInputName );
  151. proto native void RegisterGroup( string sGroupName, string sLoc );
  152. proto native void DeRegisterGroup( string sGroupName );
  153. proto native void UpdateControls(); // call this on each change of exclusion
  154. proto native void ActivateGroup( string sGroupName );
  155. proto native void ActivateExclude( string sExcludeName );
  156. proto native void ActivateContext( string sContextName );
  157. proto native void ActivateModificator( string sModName );
  158. proto native void DeactivateModificator( string sModName );
  159. proto native void DeactivateContext();
  160. proto native bool PresetCreateNew(); // create new dynamic preset from the selected one. False == cannot create new == too many presets (current max == 6)
  161. proto native bool PresetDelete( int index ); // delete specific preset - (false == not deletable!)
  162. proto native int PresetCurrent(); // determine index of current preset - (-1 == not selected)
  163. proto native void PresetSelect( int index ); // select specific preset
  164. /**
  165. \brief Resets current 'main' preset without reverting anything else ('softer' Revert)
  166. \note Does not reset dynamic presets, since they don't have any real defaults in the core PBOs.
  167. */
  168. proto native void PresetReset();
  169. proto native int PresetCount(); // count of presets
  170. proto native owned string PresetName( int index ); // name of selected preset
  171. proto native int SortingCount(); // sorting group count
  172. proto native owned string SortingName( int index ); // sorting group name (different from localization!)
  173. proto native owned string SortingLocalization( int index ); // sorting group localized name
  174. proto native void Export(); // export XML (user) configuration
  175. proto native void Revert(); // revert XML (user) configuration - all of it and use default PBO content! Auto-exports afterward.
  176. proto native void SaveInputPresetMiscData(); // saves preset index on consoles, where the regular XMLs are unavailable
  177. proto native void SupressNextFrame( bool bForce); // supress inputs for nextframe (until key release - call this when leaving main menu and alike - to avoid button collision after character control returned)
  178. proto native void Backlit_None(); // turn off backlit
  179. proto native void Backlit_Background( int eType, int iColor1, int iColor2 ); // start backlit
  180. proto native void Backlit_Animation( string strName, float fLifeTime, int iColor1, int iColor2 ); // start backlit animation and after time limit -> continue with another one
  181. proto native bool Backlit_Enabled(); // check whether backlit active
  182. proto native void Backlit_KeyByHash( int uHash, int eLayer, int eType, int iColor ); // key directly (during keybinding process) (EUABACKLIT_*)
  183. proto native void Backlit_KeyByName( string strName, int eLayer, int eType, int iColor ); // key directly (by name) (EUABACKLIT_*)
  184. proto native void Backlit_Remove( int eLayer ); // turn off layer of backlit
  185. proto native void Backlit_ForceUpdate(); // this forces update immediately - USE ONLY IN LOADING SEQUENCE !!!
  186. proto native void Backlit_EmptyQueue(); // empty queue of animations - use if you want to play something immediately
  187. };
  188. proto native UAInputAPI GetUApi();