MCPcopy Create free account
hub / github.com/TASEmulators/fceux / ButtonName

Function ButtonName

src/drivers/Qt/input.cpp:2039–2102  ·  view source on GitHub ↗

* Get the display name of the key or joystick button mapped to a specific * NES gamepad button. * @param bc the NES gamepad's button config * @param which the index of the button */

Source from the content-addressed store, hash-verified

2037 * @param which the index of the button
2038 */
2039const char *ButtonName(const ButtConfig *bc)
2040{
2041 static char name[256];
2042
2043 name[0] = 0;
2044
2045 if (bc->ButtonNum == -1)
2046 {
2047 return name;
2048 }
2049 switch (bc->ButtType)
2050 {
2051 case BUTTC_KEYBOARD:
2052 return SDL_GetKeyName(bc->ButtonNum);
2053 break;
2054 case BUTTC_JOYSTICK:
2055 {
2056 int joyNum, inputNum;
2057 const char *inputType, *inputDirection;
2058 char direction[128] = "";
2059
2060 joyNum = bc->DeviceNum;
2061
2062 if (bc->ButtonNum & 0x8000)
2063 {
2064 inputType = "Axis";
2065 inputNum = bc->ButtonNum & 0x3FFF;
2066 inputDirection = bc->ButtonNum & 0x4000 ? "-" : "+";
2067 }
2068 else if (bc->ButtonNum & 0x2000)
2069 {
2070 int inputValue;
2071
2072 inputType = "Hat";
2073 inputNum = (bc->ButtonNum >> 8) & 0x1F;
2074 inputValue = bc->ButtonNum & 0xF;
2075
2076 if (inputValue & SDL_HAT_UP)
2077 strncat(direction, "Up ", sizeof(direction) - 1);
2078 if (inputValue & SDL_HAT_DOWN)
2079 strncat(direction, "Down ", sizeof(direction) - 1);
2080 if (inputValue & SDL_HAT_LEFT)
2081 strncat(direction, "Left ", sizeof(direction) - 1);
2082 if (inputValue & SDL_HAT_RIGHT)
2083 strncat(direction, "Right ", sizeof(direction) - 1);
2084
2085 if (direction[0])
2086 inputDirection = direction;
2087 else
2088 inputDirection = "Center";
2089 }
2090 else
2091 {
2092 inputType = "Button";
2093 inputNum = bc->ButtonNum;
2094 inputDirection = "";
2095 }
2096 sprintf(name, "js%i:%s%i%s", joyNum, inputType, inputNum, inputDirection);

Callers 6

updateBindingListMethod · 0.70
FKBKeyMapDialogMethod · 0.70
refreshKeyBindTreeMethod · 0.70
updateCntrlrDpyMethod · 0.70
changeButtonMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected