MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/FleX / ControllerButtonEvent

Function ControllerButtonEvent

demo/main.cpp:2558–2590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2556}
2557
2558void ControllerButtonEvent(SDL_ControllerButtonEvent event)
2559{
2560 // map controller buttons to keyboard keys
2561 if (event.type == SDL_CONTROLLERBUTTONDOWN)
2562 {
2563 InputKeyboardDown(GetKeyFromGameControllerButton(SDL_GameControllerButton(event.button)), 0, 0);
2564 InputArrowKeysDown(GetKeyFromGameControllerButton(SDL_GameControllerButton(event.button)), 0, 0);
2565
2566 if (event.button == SDL_CONTROLLER_BUTTON_LEFT_TRIGGER)
2567 {
2568 // Handle picking events using the game controller
2569 g_lastx = g_screenWidth / 2;
2570 g_lasty = g_screenHeight / 2;
2571 g_lastb = 1;
2572
2573 // record that we need to update the picked particle
2574 g_mousePicked = true;
2575 }
2576 }
2577 else
2578 {
2579 InputKeyboardUp(GetKeyFromGameControllerButton(SDL_GameControllerButton(event.button)), 0, 0);
2580 InputArrowKeysUp(GetKeyFromGameControllerButton(SDL_GameControllerButton(event.button)), 0, 0);
2581
2582 if (event.button == SDL_CONTROLLER_BUTTON_LEFT_TRIGGER)
2583 {
2584 // Handle picking events using the game controller
2585 g_lastx = g_screenWidth / 2;
2586 g_lasty = g_screenHeight / 2;
2587 g_lastb = -1;
2588 }
2589 }
2590}
2591
2592void ControllerDeviceUpdate()
2593{

Callers 2

UpdateFrameFunction · 0.85
SDLMainLoopFunction · 0.85

Calls 5

InputKeyboardDownFunction · 0.85
InputArrowKeysDownFunction · 0.85
InputKeyboardUpFunction · 0.85
InputArrowKeysUpFunction · 0.85

Tested by

no test coverage detected