aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerkeyboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llviewerkeyboard.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/linden/indra/newview/llviewerkeyboard.cpp b/linden/indra/newview/llviewerkeyboard.cpp
index c732ae5..3c2fb88 100644
--- a/linden/indra/newview/llviewerkeyboard.cpp
+++ b/linden/indra/newview/llviewerkeyboard.cpp
@@ -564,7 +564,8 @@ void bind_keyboard_functions()
564 gViewerKeyboard.bindNamedFunction("start_gesture", start_gesture); 564 gViewerKeyboard.bindNamedFunction("start_gesture", start_gesture);
565} 565}
566 566
567LLViewerKeyboard::LLViewerKeyboard() 567LLViewerKeyboard::LLViewerKeyboard() :
568 mNamedFunctionCount(0)
568{ 569{
569 for (S32 i = 0; i < MODE_COUNT; i++) 570 for (S32 i = 0; i < MODE_COUNT; i++)
570 { 571 {
@@ -583,7 +584,7 @@ LLViewerKeyboard::LLViewerKeyboard()
583} 584}
584 585
585 586
586void LLViewerKeyboard::bindNamedFunction(const char *name, LLKeyFunc func) 587void LLViewerKeyboard::bindNamedFunction(const std::string& name, LLKeyFunc func)
587{ 588{
588 S32 i = mNamedFunctionCount; 589 S32 i = mNamedFunctionCount;
589 mNamedFunctions[i].mName = name; 590 mNamedFunctions[i].mName = name;
@@ -592,29 +593,29 @@ void LLViewerKeyboard::bindNamedFunction(const char *name, LLKeyFunc func)
592} 593}
593 594
594 595
595BOOL LLViewerKeyboard::modeFromString(const char *string, S32 *mode) 596BOOL LLViewerKeyboard::modeFromString(const std::string& string, S32 *mode)
596{ 597{
597 if (!strcmp(string, "FIRST_PERSON")) 598 if (string == "FIRST_PERSON")
598 { 599 {
599 *mode = MODE_FIRST_PERSON; 600 *mode = MODE_FIRST_PERSON;
600 return TRUE; 601 return TRUE;
601 } 602 }
602 else if (!strcmp(string, "THIRD_PERSON")) 603 else if (string == "THIRD_PERSON")
603 { 604 {
604 *mode = MODE_THIRD_PERSON; 605 *mode = MODE_THIRD_PERSON;
605 return TRUE; 606 return TRUE;
606 } 607 }
607 else if (!strcmp(string, "EDIT")) 608 else if (string == "EDIT")
608 { 609 {
609 *mode = MODE_EDIT; 610 *mode = MODE_EDIT;
610 return TRUE; 611 return TRUE;
611 } 612 }
612 else if (!strcmp(string, "EDIT_AVATAR")) 613 else if (string == "EDIT_AVATAR")
613 { 614 {
614 *mode = MODE_EDIT_AVATAR; 615 *mode = MODE_EDIT_AVATAR;
615 return TRUE; 616 return TRUE;
616 } 617 }
617 else if (!strcmp(string, "SITTING")) 618 else if (string == "SITTING")
618 { 619 {
619 *mode = MODE_SITTING; 620 *mode = MODE_SITTING;
620 return TRUE; 621 return TRUE;
@@ -662,11 +663,11 @@ BOOL LLViewerKeyboard::handleKey(KEY translated_key, MASK translated_mask, BOOL
662 663
663 664
664 665
665BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, const char *function_name) 666BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, const std::string& function_name)
666{ 667{
667 S32 i,index; 668 S32 i,index;
668 void (*function)(EKeystate keystate) = NULL; 669 void (*function)(EKeystate keystate) = NULL;
669 const char *name = NULL; 670 std::string name;
670 671
671 // Allow remapping of F2-F12 672 // Allow remapping of F2-F12
672 if (function_name[0] == 'F') 673 if (function_name[0] == 'F')
@@ -690,7 +691,7 @@ BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, c
690 // Not remapped, look for a function 691 // Not remapped, look for a function
691 for (i = 0; i < mNamedFunctionCount; i++) 692 for (i = 0; i < mNamedFunctionCount; i++)
692 { 693 {
693 if (!strcmp(function_name, mNamedFunctions[i].mName)) 694 if (function_name == mNamedFunctions[i].mName)
694 { 695 {
695 function = mNamedFunctions[i].mFunction; 696 function = mNamedFunctions[i].mFunction;
696 name = mNamedFunctions[i].mName; 697 name = mNamedFunctions[i].mName;
@@ -730,22 +731,20 @@ BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, c
730 if (index == mBindingCount[mode]) 731 if (index == mBindingCount[mode])
731 mBindingCount[mode]++; 732 mBindingCount[mode]++;
732 733
733 // printf("Bound key %c to %s\n", key, name);
734
735 return TRUE; 734 return TRUE;
736} 735}
737 736
738 737
739S32 LLViewerKeyboard::loadBindings(const char *filename) 738S32 LLViewerKeyboard::loadBindings(const std::string& filename)
740{ 739{
741 LLFILE *fp; 740 LLFILE *fp;
742 const S32 BUFFER_SIZE = 2048; 741 const S32 BUFFER_SIZE = 2048;
743 char buffer[BUFFER_SIZE]; /* Flawfinder: ignore */ 742 char buffer[BUFFER_SIZE]; /* Flawfinder: ignore */
744 // *NOTE: This buffer size is hard coded into scanf() below. 743 // *NOTE: This buffer size is hard coded into scanf() below.
745 char mode_string[MAX_STRING]; /* Flawfinder: ignore */ 744 char mode_string[MAX_STRING] = ""; /* Flawfinder: ignore */
746 char key_string[MAX_STRING]; /* Flawfinder: ignore */ 745 char key_string[MAX_STRING] = ""; /* Flawfinder: ignore */
747 char mask_string[MAX_STRING]; /* Flawfinder: ignore */ 746 char mask_string[MAX_STRING] = ""; /* Flawfinder: ignore */
748 char function_string[MAX_STRING]; /* Flawfinder: ignore */ 747 char function_string[MAX_STRING] = ""; /* Flawfinder: ignore */
749 S32 mode = MODE_THIRD_PERSON; 748 S32 mode = MODE_THIRD_PERSON;
750 KEY key = 0; 749 KEY key = 0;
751 MASK mask = 0; 750 MASK mask = 0;
@@ -753,7 +752,7 @@ S32 LLViewerKeyboard::loadBindings(const char *filename)
753 S32 binding_count = 0; 752 S32 binding_count = 0;
754 S32 line_count = 0; 753 S32 line_count = 0;
755 754
756 if(!filename) 755 if(filename.empty())
757 { 756 {
758 llerrs << " No filename specified" << llendl; 757 llerrs << " No filename specified" << llendl;
759 return 0; 758 return 0;