inputManager.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. function SetInput(%client, %device, %key, %command, %bindMap, %behav)
  23. {
  24. commandToClient(%client, 'SetInput', %device, %key, %command, %bindMap, %behav);
  25. }
  26. function RemoveInput(%client, %device, %key, %command, %bindMap)
  27. {
  28. commandToClient(%client, 'removeInput', %device, %key, %command, %bindMap);
  29. }
  30. function clientCmdSetInput(%device, %key, %command, %bindMap, %behav)
  31. {
  32. //if we're requesting a custom bind map, set that up
  33. if(%bindMap $= "")
  34. %bindMap = moveMap;
  35. if (!isObject(%bindMap)){
  36. new ActionMap(moveMap);
  37. moveMap.push();
  38. }
  39. //get our local
  40. //%localID = ServerConnection.resolveGhostID(%behav);
  41. //%tmpl = %localID.getTemplate();
  42. //%tmpl.insantiateNamespace(%tmpl.getName());
  43. //first, check if we have an existing command
  44. %oldBind = %bindMap.getBinding(%command);
  45. if(%oldBind !$= "")
  46. %bindMap.unbind(getField(%oldBind, 0), getField(%oldBind, 1));
  47. //now, set the requested bind
  48. %bindMap.bind(%device, %key, %command);
  49. }
  50. function clientCmdRemoveSpecCtrlInput(%device, %key, %bindMap)
  51. {
  52. //if we're requesting a custom bind map, set that up
  53. if(%bindMap $= "")
  54. %bindMap = moveMap;
  55. if (!isObject(%bindMap))
  56. return;
  57. %bindMap.unbind(%device, %key);
  58. }
  59. function clientCmdSetupClientBehavior(%bhvrGstID)
  60. {
  61. %localID = ServerConnection.resolveGhostID(%bhvrGstID);
  62. %tmpl = %localID.getTemplate();
  63. %tmpl.insantiateNamespace(%tmpl.getName());
  64. }
  65. function getMouseAdjustAmount(%val)
  66. {
  67. // based on a default camera FOV of 90'
  68. return(%val * ($cameraFov / 90) * 0.01) * $pref::Input::LinkMouseSensitivity;
  69. }