switch-examples:
- added full controller support - added multi-controller support - added splitscreen support - added touch screen support - added full camera-controller support - updated related examples
This commit is contained in:
parent
6719c57ba8
commit
65a4a0092a
22 changed files with 826 additions and 253 deletions
|
|
@ -413,6 +413,7 @@ CORE = \
|
|||
core/core_input_mouse \
|
||||
core/core_input_mouse_wheel \
|
||||
core/core_input_gamepad \
|
||||
core/core_input_multi_gamepad \
|
||||
core/core_input_multitouch \
|
||||
core/core_input_gestures \
|
||||
core/core_2d_camera \
|
||||
|
|
|
|||
|
|
@ -60,15 +60,15 @@ int main(void)
|
|||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Player movement
|
||||
if (IsKeyDown(KEY_RIGHT)) player.x += 2;
|
||||
else if (IsKeyDown(KEY_LEFT)) player.x -= 2;
|
||||
if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) > 0) player.x += 2;
|
||||
else if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) < 0) player.x -= 2;
|
||||
|
||||
// Camera target follows player
|
||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||
|
||||
// Camera rotation controls
|
||||
if (IsKeyDown(KEY_A)) camera.rotation--;
|
||||
else if (IsKeyDown(KEY_S)) camera.rotation++;
|
||||
if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X) > 0) camera.rotation--;
|
||||
else if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X) < 0) camera.rotation++;
|
||||
|
||||
// Limit camera rotation to 80 degrees (-40 to 40)
|
||||
if (camera.rotation > 40) camera.rotation = 40;
|
||||
|
|
@ -119,9 +119,9 @@ int main(void)
|
|||
|
||||
DrawText("Free 2d camera controls:", 20, 20, 10, BLACK);
|
||||
DrawText("- Right/Left to move Offset", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY);
|
||||
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY);
|
||||
DrawText("- R/L bumpers to Zoom in-out", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- Right thumbstick X-axis to Rotate", 40, 80, 10, DARKGRAY);
|
||||
DrawText("- X button to reset Zoom and Rotation", 40, 100, 10, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -106,7 +106,14 @@ int main(void)
|
|||
|
||||
UpdatePlayer(&player, envItems, envItemsLength, deltaTime);
|
||||
|
||||
camera.zoom += ((float)GetMouseWheelMove()*0.05f);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_TRIGGER_1))
|
||||
{
|
||||
camera.zoom += 0.05f;
|
||||
}
|
||||
else if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_TRIGGER_1))
|
||||
{
|
||||
camera.zoom -= 0.05f;
|
||||
}
|
||||
|
||||
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
||||
else if (camera.zoom < 0.25f) camera.zoom = 0.25f;
|
||||
|
|
@ -117,7 +124,7 @@ int main(void)
|
|||
player.position = (Vector2){ 400, 280 };
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KEY_C)) cameraOption = (cameraOption + 1)%cameraUpdatersLength;
|
||||
if (IsGamepadButtonReleased(0, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) cameraOption = (cameraOption + 1)%cameraUpdatersLength;
|
||||
|
||||
// Call update camera function by its pointer
|
||||
cameraUpdaters[cameraOption](&camera, &player, envItems, envItemsLength, deltaTime, screenWidth, screenHeight);
|
||||
|
|
@ -139,10 +146,10 @@ int main(void)
|
|||
EndMode2D();
|
||||
|
||||
DrawText("Controls:", 20, 20, 10, BLACK);
|
||||
DrawText("- Right/Left to move", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Space to jump", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- Mouse Wheel to Zoom in-out, R to reset zoom", 40, 80, 10, DARKGRAY);
|
||||
DrawText("- C to change camera mode", 40, 100, 10, DARKGRAY);
|
||||
DrawText("- Right/Left thumbstick to move", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- A button to jump", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- R/L buttons to Zoom in-out, X to reset zoom", 40, 80, 10, DARKGRAY);
|
||||
DrawText("- Y button to change camera mode", 40, 100, 10, DARKGRAY);
|
||||
DrawText("Current camera mode:", 20, 120, 10, BLACK);
|
||||
DrawText(cameraDescriptions[cameraOption], 40, 140, 10, DARKGRAY);
|
||||
|
||||
|
|
@ -160,9 +167,9 @@ int main(void)
|
|||
|
||||
void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float delta)
|
||||
{
|
||||
if (IsKeyDown(KEY_LEFT)) player->position.x -= PLAYER_HOR_SPD*delta;
|
||||
if (IsKeyDown(KEY_RIGHT)) player->position.x += PLAYER_HOR_SPD*delta;
|
||||
if (IsKeyDown(KEY_SPACE) && player->canJump)
|
||||
if (GetGamepadAxisMovement(0, 0) < 0) player->position.x -= PLAYER_HOR_SPD*delta;
|
||||
if (GetGamepadAxisMovement(0, 0) > 0) player->position.x += PLAYER_HOR_SPD*delta;
|
||||
if (IsGamepadButtonPressed(0, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT) && player->canJump)
|
||||
{
|
||||
player->speed = -PLAYER_JUMP_SPD;
|
||||
player->canJump = false;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
#include "raylib.h"
|
||||
|
||||
#define MAX_COLUMNS 20
|
||||
#define CAMERA_INVERTED_Y_TRUE -1.0f
|
||||
#define CAMERA_INVERTED_Y_FALSE 1.0f
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
|
|
@ -48,6 +50,7 @@ int main(void)
|
|||
}
|
||||
|
||||
SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
|
||||
SetGamepadYAxisInverted(0, CAMERA_INVERTED_Y_FALSE);
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
|
@ -57,7 +60,11 @@ int main(void)
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera);
|
||||
UpdateCameraGamepad(&camera, 0);
|
||||
if (IsGamepadButtonPressed(0, GAMEPAD_BUTTON_RIGHT_TRIGGER_1))
|
||||
{
|
||||
SetGamepadYAxisInverted(0, -GetGamepadYAxisInverted(0));
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
@ -82,12 +89,13 @@ int main(void)
|
|||
|
||||
EndMode3D();
|
||||
|
||||
DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines( 10, 10, 220, 70, BLUE);
|
||||
DrawRectangle( 10, 10, 220, 90, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines( 10, 10, 220, 90, BLUE);
|
||||
|
||||
DrawText("First person camera default controls:", 20, 20, 10, BLACK);
|
||||
DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- Move with Left Thumbstick", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Look around with Right Thumbstick", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- Press R to invert Look Y-Axis", 40, 80, 10, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ int main(void)
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera);
|
||||
UpdateCameraGamepad(&camera, 0);
|
||||
|
||||
if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_UP)) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
@ -69,11 +69,11 @@ int main(void)
|
|||
DrawRectangleLines( 10, 10, 320, 133, BLUE);
|
||||
|
||||
DrawText("Free camera default controls:", 20, 20, 10, BLACK);
|
||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, DARKGRAY);
|
||||
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, DARKGRAY);
|
||||
DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY);
|
||||
DrawText("- R/L Bumpers to Zoom", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Left Thumbstick to Pan", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- Right Thumbstick to Rotate", 40, 80, 10, DARKGRAY);
|
||||
DrawText("- Hold button A for Smooth Zoom with Left Thumbstick", 40, 100, 10, DARKGRAY);
|
||||
DrawText("- Press X button to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -50,14 +50,13 @@ int main(void)
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera);
|
||||
UpdateCameraGamepad(&camera, 0);
|
||||
|
||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||
if (GetTouchPointCount() > 0)
|
||||
{
|
||||
if (!collision.hit)
|
||||
{
|
||||
ray = GetMouseRay(GetMousePosition(), camera);
|
||||
|
||||
ray = GetMouseRay(GetTouchPosition(0), camera);
|
||||
// Check collision between ray and box
|
||||
collision = GetRayCollisionBox(ray,
|
||||
(BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 },
|
||||
|
|
@ -93,7 +92,7 @@ int main(void)
|
|||
|
||||
EndMode3D();
|
||||
|
||||
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
|
||||
DrawText("Try selecting the box by touching it!", 240, 10, 20, DARKGRAY);
|
||||
|
||||
if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "raylib.h"
|
||||
|
||||
#define START_BUTTON GAMEPAD_BUTTON_MIDDLE_RIGHT
|
||||
//------------------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
|
@ -41,11 +42,16 @@ int main(void)
|
|||
SetTargetFPS(60); // Set desired framerate (frames-per-second)
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Gesture detection for TAP
|
||||
bool hasScreenBeenTouched = false;
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
bool isNextButtonPressed = IsGamepadButtonPressed(0, START_BUTTON);
|
||||
|
||||
switch(currentScreen)
|
||||
{
|
||||
case LOGO:
|
||||
|
|
@ -65,33 +71,38 @@ int main(void)
|
|||
// TODO: Update TITLE screen variables here!
|
||||
|
||||
// Press enter to change to GAMEPLAY screen
|
||||
if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
|
||||
if (isNextButtonPressed || (!hasScreenBeenTouched && GetTouchPointCount() > 0))
|
||||
{
|
||||
currentScreen = GAMEPLAY;
|
||||
hasScreenBeenTouched = true;
|
||||
}
|
||||
} break;
|
||||
case GAMEPLAY:
|
||||
{
|
||||
// TODO: Update GAMEPLAY screen variables here!
|
||||
|
||||
// Press enter to change to ENDING screen
|
||||
if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
|
||||
if (isNextButtonPressed || (!hasScreenBeenTouched && GetTouchPointCount() > 0))
|
||||
{
|
||||
currentScreen = ENDING;
|
||||
hasScreenBeenTouched = true;
|
||||
}
|
||||
} break;
|
||||
case ENDING:
|
||||
{
|
||||
// TODO: Update ENDING screen variables here!
|
||||
|
||||
// Press enter to return to TITLE screen
|
||||
if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
|
||||
if (isNextButtonPressed || (!hasScreenBeenTouched && GetTouchPointCount() > 0))
|
||||
{
|
||||
currentScreen = TITLE;
|
||||
hasScreenBeenTouched = true;
|
||||
}
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// Reset TAP gesture
|
||||
hasScreenBeenTouched = GetTouchPointCount() > 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
@ -99,6 +110,8 @@ int main(void)
|
|||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
const int horizontalCenter = screenHeight / 2;
|
||||
int touchCount = GetTouchPointCount();
|
||||
|
||||
switch(currentScreen)
|
||||
{
|
||||
|
|
@ -114,7 +127,7 @@ int main(void)
|
|||
// TODO: Draw TITLE screen here!
|
||||
DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
|
||||
DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
|
||||
DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN);
|
||||
DrawText("PRESS START or TAP to JUMP to GAMEPLAY SCREEN", 120, horizontalCenter, 20, DARKGREEN);
|
||||
|
||||
} break;
|
||||
case GAMEPLAY:
|
||||
|
|
@ -122,7 +135,7 @@ int main(void)
|
|||
// TODO: Draw GAMEPLAY screen here!
|
||||
DrawRectangle(0, 0, screenWidth, screenHeight, PURPLE);
|
||||
DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
|
||||
DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, MAROON);
|
||||
DrawText("PRESS START or TAP to JUMP to ENDING SCREEN", 130, horizontalCenter, 20, MAROON);
|
||||
|
||||
} break;
|
||||
case ENDING:
|
||||
|
|
@ -130,12 +143,17 @@ int main(void)
|
|||
// TODO: Draw ENDING screen here!
|
||||
DrawRectangle(0, 0, screenWidth, screenHeight, BLUE);
|
||||
DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
|
||||
DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, DARKBLUE);
|
||||
DrawText("PRESS START or TAP to RETURN to TITLE SCREEN", 120, horizontalCenter, 20, DARKBLUE);
|
||||
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < touchCount; i++)
|
||||
{
|
||||
Vector2 touchPosition = GetTouchPosition(i);
|
||||
DrawCircle(touchPosition.x, touchPosition.y, 75, RED);
|
||||
}
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#include <switch.h>
|
||||
|
||||
// NOTE: Gamepad name ID depends on drivers and OS
|
||||
#define XBOX360_LEGACY_NAME_ID "Xbox Controller"
|
||||
|
|
@ -38,13 +39,15 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 1280;
|
||||
const int screenHeight = 720;
|
||||
|
||||
|
||||
romfsInit();
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
|
||||
|
||||
Texture2D texPs3Pad = LoadTexture("resources/ps3.png");
|
||||
Texture2D texXboxPad = LoadTexture("resources/xbox.png");
|
||||
Texture2D texPs3Pad = LoadTexture("romfs:/resources/ps3.png");
|
||||
Texture2D texXboxPad = LoadTexture("romfs:/resources/xbox.png");
|
||||
Texture2D texNinProPad = LoadTexture("romfs:/resources/switch_pro.png");
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
|
@ -66,7 +69,6 @@ int main(void)
|
|||
if (IsGamepadAvailable(0))
|
||||
{
|
||||
DrawText(TextFormat("GP1: %s", GetGamepadName(0)), 10, 10, 10, BLACK);
|
||||
|
||||
if (TextIsEqual(GetGamepadName(0), XBOX360_NAME_ID) || TextIsEqual(GetGamepadName(0), XBOX360_LEGACY_NAME_ID))
|
||||
{
|
||||
DrawTexture(texXboxPad, 0, 0, DARKGRAY);
|
||||
|
|
@ -98,13 +100,13 @@ int main(void)
|
|||
DrawCircle(259, 152, 39, BLACK);
|
||||
DrawCircle(259, 152, 34, LIGHTGRAY);
|
||||
DrawCircle(259 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X)*20),
|
||||
152 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK);
|
||||
152 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK);
|
||||
|
||||
// Draw axis: right joystick
|
||||
DrawCircle(461, 237, 38, BLACK);
|
||||
DrawCircle(461, 237, 33, LIGHTGRAY);
|
||||
DrawCircle(461 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*20),
|
||||
237 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*20), 25, BLACK);
|
||||
DrawCircle(450, 240, 60, BLACK);
|
||||
DrawCircle(450, 240, 33, LIGHTGRAY);
|
||||
DrawCircle(450 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*20),
|
||||
240 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*20), 25, BLACK);
|
||||
|
||||
// Draw axis: left-right triggers
|
||||
DrawRectangle(170, 30, 15, 70, GRAY);
|
||||
|
|
@ -146,13 +148,13 @@ int main(void)
|
|||
DrawCircle(319, 255, 35, BLACK);
|
||||
DrawCircle(319, 255, 31, LIGHTGRAY);
|
||||
DrawCircle(319 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) * 20),
|
||||
255 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) * 20), 25, BLACK);
|
||||
255 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) * 20), 25, BLACK);
|
||||
|
||||
// Draw axis: right joystick
|
||||
DrawCircle(475, 255, 35, BLACK);
|
||||
DrawCircle(475, 255, 31, LIGHTGRAY);
|
||||
DrawCircle(475 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X) * 20),
|
||||
255 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y) * 20), 25, BLACK);
|
||||
255 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y) * 20), 25, BLACK);
|
||||
|
||||
// Draw axis: left-right triggers
|
||||
DrawRectangle(169, 48, 15, 70, GRAY);
|
||||
|
|
@ -160,6 +162,59 @@ int main(void)
|
|||
DrawRectangle(169, 48, 15, (int)(((1 - GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER)) / 2) * 70), RED);
|
||||
DrawRectangle(611, 48, 15, (int)(((1 - GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER)) / 2) * 70), RED);
|
||||
}
|
||||
else if (TextIsEqual(GetGamepadName(0), "Nintendo Switch Pro Controller"))
|
||||
{
|
||||
DrawTexture(texNinProPad, screenWidth/2 - 400, screenHeight/2 - 352, DARKGRAY);
|
||||
|
||||
// Draw buttons: basic
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawCircle(screenWidth/2 + 92, 192, 15, RED);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawCircle(screenWidth/2 - 99, 192, 15, RED);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(screenWidth/2 + 143, 252, 25, GREEN);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(screenWidth/2 + 205, 308, 25, YELLOW);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(screenWidth/2 + 267, 252, 25, RED);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(screenWidth/2 + 205, 196, 25, BLUE);
|
||||
|
||||
// Draw buttons: d-pad
|
||||
// DrawRectangle(317, 202, 19, 71, BLACK);
|
||||
// DrawRectangle(293, 228, 69, 19, BLACK);
|
||||
DrawRectangle(499, 305, 40, 115, GRAY);
|
||||
DrawRectangle(460, 346, 115, 40, GRAY);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(499, 305, 40, 30, RED);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(499, 396, 40, 30, RED);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(459, 346, 25, 40, RED);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(550, 346, 26, 40, RED);
|
||||
|
||||
// Draw buttons: left-right back
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(259 + 230, 61, 20, RED);
|
||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(536 + 230, 61, 20, RED);
|
||||
|
||||
// Draw axis: left joystick
|
||||
DrawCircle(421, 251, 70, BLACK);
|
||||
DrawCircle(421, 251, 65, LIGHTGRAY);
|
||||
DrawCircle(421 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X)*20),
|
||||
251 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y)*-20), 35, BLACK);
|
||||
|
||||
// Draw axis: right joystick
|
||||
DrawCircle(screenWidth/2 + 103, 360, 70, BLACK);
|
||||
DrawCircle(screenWidth/2 + 103, 360, 65, LIGHTGRAY);
|
||||
DrawCircle(screenWidth/2 + 103 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*20),
|
||||
360 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*-20), 35, BLACK);
|
||||
|
||||
// joystick down press
|
||||
if(IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_THUMB)) DrawCircle(421 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X)*20),
|
||||
251 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y)*-20), 35, RED);
|
||||
if(IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_THUMB)) DrawCircle(screenWidth/2 + 103 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*20),
|
||||
360 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*-20), 35, RED);
|
||||
|
||||
// Draw axis: left-right triggers
|
||||
DrawRectangle(170 + 230, 30, 15, 70, GRAY);
|
||||
DrawRectangle(604 + 230, 30, 15, 70, GRAY);
|
||||
DrawRectangle(170 + 230, 30, 15, (int)(((1 + GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER))/2)*70), RED);
|
||||
DrawRectangle(604 + 230, 30, 15, (int)(((1 + GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER))/2)*70), RED);
|
||||
|
||||
//DrawText(TextFormat("Xbox axis LT: %02.02f", GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK);
|
||||
//DrawText(TextFormat("Xbox axis RT: %02.02f", GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawText("- GENERIC GAMEPAD -", 280, 180, 20, GRAY);
|
||||
|
|
@ -192,9 +247,11 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texPs3Pad);
|
||||
UnloadTexture(texXboxPad);
|
||||
UnloadTexture(texNinProPad);
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
romfsExit();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
96
examples-switch/core/core_input_multi_gamepad.c
Normal file
96
examples-switch/core/core_input_multi_gamepad.c
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Gamepad input
|
||||
*
|
||||
* NOTE: This example requires a Gamepad connected to the system
|
||||
* raylib is configured to work with the following gamepads:
|
||||
* - Xbox 360 Controller (Xbox 360, Xbox One)
|
||||
* - PLAYSTATION(R)3 Controller
|
||||
* Check raylib.h for buttons configuration
|
||||
*
|
||||
* Example originally created with raylib 1.1, last time updated with raylib 4.2
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#include <switch.h>
|
||||
|
||||
// NOTE: Gamepad name ID depends on drivers and OS
|
||||
#define XBOX360_LEGACY_NAME_ID "Xbox Controller"
|
||||
#if defined(PLATFORM_RPI)
|
||||
#define XBOX360_NAME_ID "Microsoft X-Box 360 pad"
|
||||
#define PS3_NAME_ID "PLAYSTATION(R)3 Controller"
|
||||
#else
|
||||
#define XBOX360_NAME_ID "Xbox 360 Controller"
|
||||
#define PS3_NAME_ID "PLAYSTATION(R)3 Controller"
|
||||
#endif
|
||||
#define MAX_GAMEPADS 4
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 1280;
|
||||
const int screenHeight = 720;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// ...
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(DARKGRAY);
|
||||
|
||||
for(int i = 0; i< MAX_GAMEPADS; i++) {
|
||||
int height = 75 * (i + 3);
|
||||
if(IsGamepadAvailable(i))
|
||||
{
|
||||
if (IsGamepadButtonDown(i, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT))
|
||||
{
|
||||
DrawRectangle(0, height - 22, 1280, 75, LIGHTGRAY);
|
||||
DrawText(TextFormat("Controller %i", i+1), 300, height, 30, DARKGRAY);
|
||||
DrawText(TextFormat("%s", GetGamepadName(i)), 600, height, 30, DARKGRAY);
|
||||
} else {
|
||||
DrawText(TextFormat("Controller %i", i+1), 300, height, 30, LIGHTGRAY);
|
||||
DrawText(TextFormat("%s", GetGamepadName(i)), 600, height, 30, LIGHTGRAY);
|
||||
}
|
||||
} else {
|
||||
DrawText(TextFormat("Controller %i", i+1), 300, height, 30, LIGHTGRAY);
|
||||
DrawText(TextFormat("Not Connected"), 600, height, 30, LIGHTGRAY);
|
||||
}
|
||||
}
|
||||
DrawText("Press", 1110, 670, 20, GRAY);
|
||||
DrawCircle(1200, 680, 20, GRAY);
|
||||
DrawCircle(1200, 680, 18, DARKGRAY);
|
||||
DrawText("A", 1194, 671, 20, GRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ int main(void)
|
|||
{
|
||||
// Draw circle and touch index number
|
||||
DrawCircleV(touchPositions[i], 34, ORANGE);
|
||||
DrawText(TextFormat("%d", i), (int)touchPositions[i].x - 10, (int)touchPositions[i].y - 70, 40, BLACK);
|
||||
DrawText(TextFormat("%d", GetTouchPointId(i)), (int)touchPositions[i].x - 10, (int)touchPositions[i].y - 70, 40, BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ int main(void)
|
|||
cameraPlayer1.target.y = 1.0f;
|
||||
cameraPlayer1.position.z = -3.0f;
|
||||
cameraPlayer1.position.y = 1.0f;
|
||||
cameraPlayer1.projection = CAMERA_PERSPECTIVE;
|
||||
|
||||
RenderTexture screenPlayer1 = LoadRenderTexture(screenWidth/2, screenHeight);
|
||||
|
||||
|
|
@ -68,9 +69,13 @@ int main(void)
|
|||
cameraPlayer2.target.y = 3.0f;
|
||||
cameraPlayer2.position.x = -3.0f;
|
||||
cameraPlayer2.position.y = 3.0f;
|
||||
cameraPlayer2.projection = CAMERA_PERSPECTIVE;
|
||||
|
||||
RenderTexture screenPlayer2 = LoadRenderTexture(screenWidth / 2, screenHeight);
|
||||
|
||||
SetCameraMode(cameraPlayer1, CAMERA_FIRST_PERSON);
|
||||
SetCameraMode(cameraPlayer2, CAMERA_FIRST_PERSON);
|
||||
|
||||
// Build a flipped rectangle the size of the split view to use for drawing later
|
||||
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenPlayer1.texture.width, (float)-screenPlayer1.texture.height };
|
||||
|
||||
|
|
@ -84,31 +89,10 @@ int main(void)
|
|||
//----------------------------------------------------------------------------------
|
||||
// If anyone moves this frame, how far will they move based on the time since the last frame
|
||||
// this moves thigns at 10 world units per second, regardless of the actual FPS
|
||||
float offsetThisFrame = 10.0f*GetFrameTime();
|
||||
// float offsetThisFrame = 10.0f*GetFrameTime();
|
||||
|
||||
// Move Player1 forward and backwards (no turning)
|
||||
if (IsKeyDown(KEY_W))
|
||||
{
|
||||
cameraPlayer1.position.z += offsetThisFrame;
|
||||
cameraPlayer1.target.z += offsetThisFrame;
|
||||
}
|
||||
else if (IsKeyDown(KEY_S))
|
||||
{
|
||||
cameraPlayer1.position.z -= offsetThisFrame;
|
||||
cameraPlayer1.target.z -= offsetThisFrame;
|
||||
}
|
||||
|
||||
// Move Player2 forward and backwards (no turning)
|
||||
if (IsKeyDown(KEY_UP))
|
||||
{
|
||||
cameraPlayer2.position.x += offsetThisFrame;
|
||||
cameraPlayer2.target.x += offsetThisFrame;
|
||||
}
|
||||
else if (IsKeyDown(KEY_DOWN))
|
||||
{
|
||||
cameraPlayer2.position.x -= offsetThisFrame;
|
||||
cameraPlayer2.target.x -= offsetThisFrame;
|
||||
}
|
||||
UpdateCameraGamepad(&cameraPlayer1, 0);
|
||||
UpdateCameraGamepad(&cameraPlayer2, 1);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
@ -119,16 +103,15 @@ int main(void)
|
|||
BeginMode3D(cameraPlayer1);
|
||||
DrawScene();
|
||||
EndMode3D();
|
||||
DrawText("PLAYER1 W/S to move", 10, 10, 20, RED);
|
||||
DrawText("PLAYER1", 10, 10, 20, RED);
|
||||
EndTextureMode();
|
||||
|
||||
// Draw Player2 view to the render texture
|
||||
BeginTextureMode(screenPlayer2);
|
||||
ClearBackground(SKYBLUE);
|
||||
BeginMode3D(cameraPlayer2);
|
||||
DrawScene();
|
||||
EndMode3D();
|
||||
DrawText("PLAYER2 UP/DOWN to move", 10, 10, 20, BLUE);
|
||||
DrawText("PLAYER2", 10, 10, 20, BLUE);
|
||||
EndTextureMode();
|
||||
|
||||
// Draw both views render textures to the screen side by side
|
||||
|
|
@ -136,6 +119,7 @@ int main(void)
|
|||
ClearBackground(BLACK);
|
||||
DrawTextureRec(screenPlayer1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
||||
DrawTextureRec(screenPlayer2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
||||
DrawRectangle(screenWidth/2 - 5, 0, 10, 720, BLACK);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
|
|
|
|||
4
examples-switch/romfs/resources/LICENSE (1).md
Normal file
4
examples-switch/romfs/resources/LICENSE (1).md
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
| resource | author | licence | notes |
|
||||
| :------------ | :---------: | :------ | :---- |
|
||||
| ps3.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||
| xbox.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||
52
examples-switch/romfs/resources/distortion100.fs
Normal file
52
examples-switch/romfs/resources/distortion100.fs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
uniform vec2 leftLensCenter;
|
||||
uniform vec2 rightLensCenter;
|
||||
uniform vec2 leftScreenCenter;
|
||||
uniform vec2 rightScreenCenter;
|
||||
uniform vec2 scale;
|
||||
uniform vec2 scaleIn;
|
||||
uniform vec4 deviceWarpParam;
|
||||
uniform vec4 chromaAbParam;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Compute lens distortion
|
||||
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
|
||||
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
||||
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
||||
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||
vec2 theta1 = theta*(deviceWarpParam.x + deviceWarpParam.y*rSq + deviceWarpParam.z*rSq*rSq + deviceWarpParam.w*rSq*rSq*rSq);
|
||||
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
|
||||
vec2 tcBlue = lensCenter + scale*thetaBlue;
|
||||
|
||||
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
|
||||
{
|
||||
// Set black fragment for everything outside the lens border
|
||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compute color chroma aberration
|
||||
float blue = texture2D(texture0, tcBlue).b;
|
||||
vec2 tcGreen = lensCenter + scale*theta1;
|
||||
float green = texture2D(texture0, tcGreen).g;
|
||||
|
||||
vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq);
|
||||
vec2 tcRed = lensCenter + scale*thetaRed;
|
||||
|
||||
float red = texture2D(texture0, tcRed).r;
|
||||
gl_FragColor = vec4(red, green, blue, 1.0);
|
||||
}
|
||||
}
|
||||
53
examples-switch/romfs/resources/distortion330.fs
Normal file
53
examples-switch/romfs/resources/distortion330.fs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
uniform vec2 leftLensCenter = vec2(0.288, 0.5);
|
||||
uniform vec2 rightLensCenter = vec2(0.712, 0.5);
|
||||
uniform vec2 leftScreenCenter = vec2(0.25, 0.5);
|
||||
uniform vec2 rightScreenCenter = vec2(0.75, 0.5);
|
||||
uniform vec2 scale = vec2(0.25, 0.45);
|
||||
uniform vec2 scaleIn = vec2(4, 2.2222);
|
||||
uniform vec4 deviceWarpParam = vec4(1, 0.22, 0.24, 0);
|
||||
uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
|
||||
|
||||
void main()
|
||||
{
|
||||
// Compute lens distortion
|
||||
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
|
||||
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
||||
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
||||
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||
vec2 theta1 = theta*(deviceWarpParam.x + deviceWarpParam.y*rSq + deviceWarpParam.z*rSq*rSq + deviceWarpParam.w*rSq*rSq*rSq);
|
||||
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
|
||||
vec2 tcBlue = lensCenter + scale*thetaBlue;
|
||||
|
||||
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
|
||||
{
|
||||
// Set black fragment for everything outside the lens border
|
||||
finalColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compute color chroma aberration
|
||||
float blue = texture(texture0, tcBlue).b;
|
||||
vec2 tcGreen = lensCenter + scale*theta1;
|
||||
float green = texture(texture0, tcGreen).g;
|
||||
|
||||
vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq);
|
||||
vec2 tcRed = lensCenter + scale*thetaRed;
|
||||
|
||||
float red = texture(texture0, tcRed).r;
|
||||
finalColor = vec4(red, green, blue, 1.0);
|
||||
}
|
||||
}
|
||||
BIN
examples-switch/romfs/resources/ps3.png
Normal file
BIN
examples-switch/romfs/resources/ps3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
examples-switch/romfs/resources/switch_pro.png
Normal file
BIN
examples-switch/romfs/resources/switch_pro.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 MiB |
BIN
examples-switch/romfs/resources/xbox.png
Normal file
BIN
examples-switch/romfs/resources/xbox.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
|
|
@ -141,7 +141,7 @@ int main(void)
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera);
|
||||
UpdateCameraGamepad(&camera, 0);
|
||||
|
||||
// Handle font files dropped
|
||||
if (IsFileDropped())
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
#define NX_SUPPORT_GAMEPAD_EMULATION 1
|
||||
// Enabling this flag allows debugging by USB, the application will wait for an USB connection to start
|
||||
//#define NX_USB_DEBUGGER 1
|
||||
// #define ENABLE_DEV_EXIT 1 // Allows for exit when gamepad kbm emulation is disabled
|
||||
|
||||
// rcore: Configuration values
|
||||
//------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -303,6 +303,7 @@ typedef struct Font {
|
|||
// Camera, defines position/orientation in 3d space
|
||||
typedef struct Camera3D {
|
||||
Vector3 position; // Camera position
|
||||
Vector2 angle; // Camera angle (Required for splitscreen instead of shared global)
|
||||
Vector3 target; // Camera target it looks-at
|
||||
Vector3 up; // Camera up vector (rotation over its axis)
|
||||
float fovy; // Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic
|
||||
|
|
@ -1113,6 +1114,8 @@ RLAPI int GetGamepadButtonPressed(void); // Get the last ga
|
|||
RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad
|
||||
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis
|
||||
RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB)
|
||||
RLAPI void SetGamepadYAxisInverted(int gamepad, float yInverted);
|
||||
RLAPI float GetGamepadYAxisInverted(int gamepad);
|
||||
|
||||
// Input-related functions: mouse
|
||||
RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once
|
||||
|
|
@ -1154,6 +1157,9 @@ RLAPI float GetGesturePinchAngle(void); // Get gesture pinch ang
|
|||
//------------------------------------------------------------------------------------
|
||||
RLAPI void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
|
||||
RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode
|
||||
RLAPI void UpdateCameraGamepad(Camera *camera, int Gamepad); // Update camera position for selected mode
|
||||
RLAPI void SetCameraZoomFactor(Vector2 zoomFactor); // Gamepad equivalent of mousewheel
|
||||
RLAPI void SetCameraPrevZoomFactor(Vector2 previousZoomFactor); // Gamepad equivalent for automation
|
||||
|
||||
RLAPI void SetCameraPanControl(int keyPan); // Set camera pan key to combine with mouse movement (free camera)
|
||||
RLAPI void SetCameraAltControl(int keyAlt); // Set camera alt key to combine with mouse movement (free camera)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue