|
@@ -713,173 +713,19 @@ int OpenRaider::bind(const char *action, const char *key) {
|
713
|
713
|
assert(key != NULL);
|
714
|
714
|
assert(key[0] != '\0');
|
715
|
715
|
|
716
|
|
- const char *tmp = action;
|
717
|
|
- if (action[0] == '+')
|
718
|
|
- tmp++;
|
719
|
|
-
|
720
|
|
- if (strcmp(tmp, "menu") == 0) {
|
721
|
|
- return bind(menuAction, key);
|
722
|
|
- } else if (strcmp(tmp, "console") == 0) {
|
723
|
|
- return bind(consoleAction, key);
|
724
|
|
- } else if (strcmp(tmp, "forward") == 0) {
|
725
|
|
- return bind(forwardAction, key);
|
726
|
|
- } else if (strcmp(tmp, "backward") == 0) {
|
727
|
|
- return bind(backwardAction, key);
|
728
|
|
- } else if (strcmp(tmp, "left") == 0) {
|
729
|
|
- return bind(leftAction, key);
|
730
|
|
- } else if (strcmp(tmp, "right") == 0) {
|
731
|
|
- return bind(rightAction, key);
|
732
|
|
- } else if (strcmp(tmp, "jump") == 0) {
|
733
|
|
- return bind(jumpAction, key);
|
734
|
|
- } else if (strcmp(tmp, "crouch") == 0) {
|
735
|
|
- return bind(crouchAction, key);
|
736
|
|
- } else if (strcmp(tmp, "use") == 0) {
|
737
|
|
- return bind(useAction, key);
|
738
|
|
- } else if (strcmp(tmp, "holster") == 0) {
|
739
|
|
- return bind(holsterAction, key);
|
740
|
|
- } else if (strcmp(tmp, "walk") == 0) {
|
741
|
|
- return bind(walkAction, key);
|
742
|
|
- } else {
|
|
716
|
+ ActionEvents e = stringToActionEvent(action);
|
|
717
|
+ if (e == ActionEventCount) {
|
743
|
718
|
getConsole().print("bind-Error: Unknown action (%s --> %s)", key, action);
|
744
|
719
|
return -1;
|
745
|
720
|
}
|
746
|
|
-}
|
747
|
|
-
|
748
|
|
-int OpenRaider::bind(ActionEvents action, const char *key) {
|
749
|
|
- assert(action < ActionEventCount);
|
750
|
|
- assert(key != NULL);
|
751
|
|
- assert(key[0] != '\0');
|
752
|
721
|
|
753
|
|
- size_t length = strlen(key);
|
754
|
|
- if ((key[0] == '\'') && (key[length - 1] == '\'') && (length == 3)) {
|
755
|
|
- // Literal character like w, a, s, d, 0, 1...
|
756
|
|
- char c = key[1];
|
757
|
|
- if (((c >= '0') && (c <= '9'))
|
758
|
|
- || ((c >= 'a') && (c <= 'z'))) {
|
759
|
|
- keyBindings[action] = (KeyboardButton)c;
|
760
|
|
- } else {
|
761
|
|
- getConsole().print("bind-\'\'-Error: Unknown key (%s)", key);
|
762
|
|
- return -1;
|
763
|
|
- }
|
764
|
|
- } else if ((key[0] == '\"') && (key[length - 1] == '\"')) {
|
765
|
|
- // Special characters like tilde, esc, quote...
|
766
|
|
- char *tmp = stringRemoveQuotes(key);
|
767
|
|
- if (strcmp(tmp, "quote") == 0) {
|
768
|
|
- keyBindings[action] = quoteKey;
|
769
|
|
- } else if (strcmp(tmp, "backslash") == 0) {
|
770
|
|
- keyBindings[action] = backslashKey;
|
771
|
|
- } else if (strcmp(tmp, "backspace") == 0) {
|
772
|
|
- keyBindings[action] = backspaceKey;
|
773
|
|
- } else if (strcmp(tmp, "capslock") == 0) {
|
774
|
|
- keyBindings[action] = capslockKey;
|
775
|
|
- } else if (strcmp(tmp, "comma") == 0) {
|
776
|
|
- keyBindings[action] = commaKey;
|
777
|
|
- } else if (strcmp(tmp, "del") == 0) {
|
778
|
|
- keyBindings[action] = delKey;
|
779
|
|
- } else if (strcmp(tmp, "up") == 0) {
|
780
|
|
- keyBindings[action] = upKey;
|
781
|
|
- } else if (strcmp(tmp, "down") == 0) {
|
782
|
|
- keyBindings[action] = downKey;
|
783
|
|
- } else if (strcmp(tmp, "left") == 0) {
|
784
|
|
- keyBindings[action] = leftKey;
|
785
|
|
- } else if (strcmp(tmp, "right") == 0) {
|
786
|
|
- keyBindings[action] = rightKey;
|
787
|
|
- } else if (strcmp(tmp, "end") == 0) {
|
788
|
|
- keyBindings[action] = endKey;
|
789
|
|
- } else if (strcmp(tmp, "equals") == 0) {
|
790
|
|
- keyBindings[action] = equalsKey;
|
791
|
|
- } else if (strcmp(tmp, "escape") == 0) {
|
792
|
|
- keyBindings[action] = escapeKey;
|
793
|
|
- } else if (strcmp(tmp, "f1") == 0) {
|
794
|
|
- keyBindings[action] = f1Key;
|
795
|
|
- } else if (strcmp(tmp, "f2") == 0) {
|
796
|
|
- keyBindings[action] = f2Key;
|
797
|
|
- } else if (strcmp(tmp, "f3") == 0) {
|
798
|
|
- keyBindings[action] = f3Key;
|
799
|
|
- } else if (strcmp(tmp, "f4") == 0) {
|
800
|
|
- keyBindings[action] = f4Key;
|
801
|
|
- } else if (strcmp(tmp, "f5") == 0) {
|
802
|
|
- keyBindings[action] = f5Key;
|
803
|
|
- } else if (strcmp(tmp, "f6") == 0) {
|
804
|
|
- keyBindings[action] = f6Key;
|
805
|
|
- } else if (strcmp(tmp, "f7") == 0) {
|
806
|
|
- keyBindings[action] = f7Key;
|
807
|
|
- } else if (strcmp(tmp, "f8") == 0) {
|
808
|
|
- keyBindings[action] = f8Key;
|
809
|
|
- } else if (strcmp(tmp, "f9") == 0) {
|
810
|
|
- keyBindings[action] = f9Key;
|
811
|
|
- } else if (strcmp(tmp, "f10") == 0) {
|
812
|
|
- keyBindings[action] = f10Key;
|
813
|
|
- } else if (strcmp(tmp, "f11") == 0) {
|
814
|
|
- keyBindings[action] = f11Key;
|
815
|
|
- } else if (strcmp(tmp, "f12") == 0) {
|
816
|
|
- keyBindings[action] = f12Key;
|
817
|
|
- } else if (strcmp(tmp, "backquote") == 0) {
|
818
|
|
- keyBindings[action] = backquoteKey;
|
819
|
|
- } else if (strcmp(tmp, "home") == 0) {
|
820
|
|
- keyBindings[action] = homeKey;
|
821
|
|
- } else if (strcmp(tmp, "insert") == 0) {
|
822
|
|
- keyBindings[action] = insertKey;
|
823
|
|
- } else if (strcmp(tmp, "leftalt") == 0) {
|
824
|
|
- keyBindings[action] = leftaltKey;
|
825
|
|
- } else if (strcmp(tmp, "leftctrl") == 0) {
|
826
|
|
- keyBindings[action] = leftctrlKey;
|
827
|
|
- } else if (strcmp(tmp, "leftbracket") == 0) {
|
828
|
|
- keyBindings[action] = leftbracketKey;
|
829
|
|
- } else if (strcmp(tmp, "leftgui") == 0) {
|
830
|
|
- keyBindings[action] = leftguiKey;
|
831
|
|
- } else if (strcmp(tmp, "leftshift") == 0) {
|
832
|
|
- keyBindings[action] = leftshiftKey;
|
833
|
|
- } else if (strcmp(tmp, "minus") == 0) {
|
834
|
|
- keyBindings[action] = minusKey;
|
835
|
|
- } else if (strcmp(tmp, "numlock") == 0) {
|
836
|
|
- keyBindings[action] = numlockKey;
|
837
|
|
- } else if (strcmp(tmp, "pagedown") == 0) {
|
838
|
|
- keyBindings[action] = pagedownKey;
|
839
|
|
- } else if (strcmp(tmp, "pageup") == 0) {
|
840
|
|
- keyBindings[action] = pageupKey;
|
841
|
|
- } else if (strcmp(tmp, "pause") == 0) {
|
842
|
|
- keyBindings[action] = pauseKey;
|
843
|
|
- } else if (strcmp(tmp, "dot") == 0) {
|
844
|
|
- keyBindings[action] = dotKey;
|
845
|
|
- } else if (strcmp(tmp, "rightalt") == 0) {
|
846
|
|
- keyBindings[action] = rightaltKey;
|
847
|
|
- } else if (strcmp(tmp, "rightctrl") == 0) {
|
848
|
|
- keyBindings[action] = rightctrlKey;
|
849
|
|
- } else if (strcmp(tmp, "enter") == 0) {
|
850
|
|
- keyBindings[action] = enterKey;
|
851
|
|
- } else if (strcmp(tmp, "rightgui") == 0) {
|
852
|
|
- keyBindings[action] = rightguiKey;
|
853
|
|
- } else if (strcmp(tmp, "rightbracket") == 0) {
|
854
|
|
- keyBindings[action] = rightbracketKey;
|
855
|
|
- } else if (strcmp(tmp, "rightshift") == 0) {
|
856
|
|
- keyBindings[action] = rightshiftKey;
|
857
|
|
- } else if (strcmp(tmp, "scrolllock") == 0) {
|
858
|
|
- keyBindings[action] = scrolllockKey;
|
859
|
|
- } else if (strcmp(tmp, "semicolon") == 0) {
|
860
|
|
- keyBindings[action] = semicolonKey;
|
861
|
|
- } else if (strcmp(tmp, "slash") == 0) {
|
862
|
|
- keyBindings[action] = slashKey;
|
863
|
|
- } else if (strcmp(tmp, "space") == 0) {
|
864
|
|
- keyBindings[action] = spaceKey;
|
865
|
|
- } else if (strcmp(tmp, "tab") == 0) {
|
866
|
|
- keyBindings[action] = tabKey;
|
867
|
|
- } else if (strcmp(tmp, "leftmouse") == 0) {
|
868
|
|
- keyBindings[action] = leftmouseKey;
|
869
|
|
- } else if (strcmp(tmp, "middlemouse") == 0) {
|
870
|
|
- keyBindings[action] = middlemouseKey;
|
871
|
|
- } else if (strcmp(tmp, "rightmouse") == 0) {
|
872
|
|
- keyBindings[action] = rightmouseKey;
|
873
|
|
- } else {
|
874
|
|
- getConsole().print("bind-\"\"-Error: Unknown key (%s)", key);
|
875
|
|
- delete [] tmp;
|
876
|
|
- return -2;
|
877
|
|
- }
|
878
|
|
- delete [] tmp;
|
879
|
|
- } else {
|
|
722
|
+ KeyboardButton c = stringToKeyboardButton(key);
|
|
723
|
+ if (c == unknownKey) {
|
880
|
724
|
getConsole().print("bind-Error: Unknown key (%s)", key);
|
881
|
|
- return -3;
|
|
725
|
+ return -2;
|
882
|
726
|
}
|
|
727
|
+
|
|
728
|
+ keyBindings[e] = c;
|
883
|
729
|
return 0;
|
884
|
730
|
}
|
885
|
731
|
|