logicinput.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //Logic Input
  2. //by Redo
  3. //Uses a move map to capture keystrokes and send them to the server, for use with a keyboard or something
  4. $LogicInput_Version = "1.1";
  5. function LogicInput_Start(%mouse){
  6. if(!$LogicInput_Active){
  7. $LogicInput_Active = true;
  8. LogicInput_UpdateStopKey();
  9. LogicInput_MoveMap_Keys.push();
  10. if(%mouse) LogicInput_MoveMap_Axis.push();
  11. commandToServer('LInputStart');
  12. clientCmdBottomPrint("Logic Input is active. Press " @ $LogicInput_StopKey @ " to exit.", 3);
  13. }
  14. }
  15. function LogicInput_Stop(){
  16. if($LogicInput_Active){
  17. $LogicInput_Active = false;
  18. LogicInput_MoveMap_Keys.pop();
  19. LogicInput_MoveMap_Axis.pop();
  20. commandToServer('LInputStop');
  21. clientCmdBottomPrint("", 0.01);
  22. }
  23. }
  24. ///////////////////////////////////////////////////////////
  25. // Functions called on input from the movemaps
  26. function LogicInput_SendKey(%key, %state){
  27. if(%state && (%key $= $LogicInput_StopKey)) {
  28. LogicInput_Stop();
  29. } else {
  30. commandToServer('LInputKey', %key, %state);
  31. }
  32. }
  33. function LogicInput_SendAxis(%axis, %amt) {
  34. commandToServer('LInputAxis', %axis, %amt);
  35. }
  36. ///////////////////////////////////////////////////////////
  37. // Client cmds
  38. function clientCmdLStartInput(%mouse){
  39. LogicInput_Start(%mouse);
  40. }
  41. function clientCmdLStopInput(){
  42. LogicInput_Stop();
  43. }
  44. function clientCmdLInputHandshake() {
  45. commandToServer('LInputVersion', $LogicInput_Version);
  46. }
  47. ///////////////////////////////////////////////////////////
  48. // Remappable keybind for exiting input mode
  49. if(!$LogicInput_MadeKeys) {
  50. $LogicInput_MadeKeys = 1;
  51. $remapDivision[$remapCount] = "Logic Input";
  52. $remapName [$remapCount] = "Exit (Defaults to Esc)";
  53. $remapCmd [$remapCount] = "LogicInput_Stop";
  54. $remapCount++;
  55. }
  56. function LogicInput_UpdateStopKey() {
  57. %key = getField(moveMap.getBinding("LogicInput_Stop"), 1);
  58. if(%key $= "") %key = "escape";
  59. $LogicInput_StopKey = %key;
  60. }
  61. LogicInput_UpdateStopKey();
  62. ///////////////////////////////////////////////////////////
  63. LogicInput_Stop();
  64. exec("./logicinputmovemap.cs");