Added support for additional mouse buttons (#1753)
* Added support for additional mouse buttons * Renamed mouse button enum Co-authored-by: Lambert Wang <lambert.ww@gmail.com>
This commit is contained in:
parent
2565c01158
commit
2545f62565
27 changed files with 81 additions and 65 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -55,8 +55,6 @@ packages/
|
||||||
|
|
||||||
# Ignore all examples files
|
# Ignore all examples files
|
||||||
examples/*
|
examples/*
|
||||||
# Unignore all examples dirs
|
|
||||||
!examples/*/
|
|
||||||
# Unignore all examples files with extension
|
# Unignore all examples files with extension
|
||||||
!examples/*.c
|
!examples/*.c
|
||||||
!examples/*.png
|
!examples/*.png
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ int main(void)
|
||||||
// Sample mouse input.
|
// Sample mouse input.
|
||||||
mousePosition = GetMousePosition();
|
mousePosition = GetMousePosition();
|
||||||
|
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
float fp = (float)(mousePosition.y);
|
float fp = (float)(mousePosition.y);
|
||||||
frequency = 40.0f + (float)(fp);
|
frequency = 40.0f + (float)(fp);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera); // Update camera
|
UpdateCamera(&camera); // Update camera
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
if (!collision)
|
if (!collision)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,13 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
ballPosition = GetMousePosition();
|
ballPosition = GetMousePosition();
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) ballColor = MAROON;
|
||||||
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
|
else if (IsMouseButtonPressed(MOUSE_BUTTON_MIDDLE)) ballColor = LIME;
|
||||||
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
|
else if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) ballColor = DARKBLUE;
|
||||||
|
else if (IsMouseButtonPressed(MOUSE_BUTTON_SIDE)) ballColor = PURPLE;
|
||||||
|
else if (IsMouseButtonPressed(MOUSE_BUTTON_EXTRA)) ballColor = YELLOW;
|
||||||
|
else if (IsMouseButtonPressed(MOUSE_BUTTON_FORWARD)) ballColor = ORANGE;
|
||||||
|
else if (IsMouseButtonPressed(MOUSE_BUTTON_BACK)) ballColor = BEIGE;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
|
||||||
|
|
@ -42,13 +42,13 @@ int main(void)
|
||||||
|
|
||||||
ballColor = BEIGE;
|
ballColor = BEIGE;
|
||||||
|
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) ballColor = MAROON;
|
||||||
if (IsMouseButtonDown(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
|
if (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE)) ballColor = LIME;
|
||||||
if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
|
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) ballColor = DARKBLUE;
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) touchCounter = 10;
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) touchCounter = 10;
|
||||||
if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) touchCounter = 10;
|
if (IsMouseButtonPressed(MOUSE_BUTTON_MIDDLE)) touchCounter = 10;
|
||||||
if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) touchCounter = 10;
|
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) touchCounter = 10;
|
||||||
|
|
||||||
if (touchCounter > 0) touchCounter--;
|
if (touchCounter > 0) touchCounter--;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select model on mouse click
|
// Select model on mouse click
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
// Check collision between ray and box
|
// Check collision between ray and box
|
||||||
if (CheckCollisionRayBox(GetMouseRay(GetMousePosition(), camera), bounds)) selected = !selected;
|
if (CheckCollisionRayBox(GetMouseRay(GetMousePosition(), camera), bounds)) selected = !selected;
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera); // Update internal camera and our camera
|
UpdateCamera(&camera); // Update internal camera and our camera
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
currentModel = (currentModel + 1)%NUM_MODELS; // Cycle between the textures
|
currentModel = (currentModel + 1)%NUM_MODELS; // Cycle between the textures
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,8 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Physics body creation inputs
|
// Physics body creation inputs
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
|
||||||
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
|
else if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
|
||||||
|
|
||||||
// Destroy falling physics bodies
|
// Destroy falling physics bodies
|
||||||
int bodiesCount = GetPhysicsBodiesCount();
|
int bodiesCount = GetPhysicsBodiesCount();
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ int main(void)
|
||||||
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) // Physics shatter input
|
||||||
{
|
{
|
||||||
int count = GetPhysicsBodiesCount();
|
int count = GetPhysicsBodiesCount();
|
||||||
for (int i = count - 1; i >= 0; i--)
|
for (int i = count - 1; i >= 0; i--)
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ int main(void)
|
||||||
SetShaderValue(shader, mouseLoc, mousePos, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shader, mouseLoc, mousePos, SHADER_UNIFORM_VEC2);
|
||||||
|
|
||||||
// Hot shader reloading
|
// Hot shader reloading
|
||||||
if (shaderAutoReloading || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)))
|
if (shaderAutoReloading || (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)))
|
||||||
{
|
{
|
||||||
long currentFragShaderModTime = GetFileModTime(TextFormat(fragShaderFileName, GLSL_VERSION));
|
long currentFragShaderModTime = GetFileModTime(TextFormat(fragShaderFileName, GLSL_VERSION));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,10 +115,10 @@ int main(void)
|
||||||
|
|
||||||
// TODO: The idea is to zoom and move around with mouse
|
// TODO: The idea is to zoom and move around with mouse
|
||||||
// Probably offset movement should be proportional to zoom level
|
// Probably offset movement should be proportional to zoom level
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) || IsMouseButtonDown(MOUSE_RIGHT_BUTTON))
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) || IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
|
||||||
{
|
{
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) zoom += zoom*0.003f;
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) zoom += zoom*0.003f;
|
||||||
if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) zoom -= zoom*0.003f;
|
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) zoom -= zoom*0.003f;
|
||||||
|
|
||||||
Vector2 mousePos = GetMousePosition();
|
Vector2 mousePos = GetMousePosition();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) start = GetMousePosition();
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) start = GetMousePosition();
|
||||||
else if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) end = GetMousePosition();
|
else if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) end = GetMousePosition();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ int main(void)
|
||||||
CheckCollisionPointRec(mousePosition, (Rectangle){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height - MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE }))
|
CheckCollisionPointRec(mousePosition, (Rectangle){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height - MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE }))
|
||||||
{
|
{
|
||||||
mouseScaleReady = true;
|
mouseScaleReady = true;
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) mouseScaleMode = true;
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) mouseScaleMode = true;
|
||||||
}
|
}
|
||||||
else mouseScaleReady = false;
|
else mouseScaleReady = false;
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ int main(void)
|
||||||
if (rec.width < MOUSE_SCALE_MARK_SIZE) rec.width = MOUSE_SCALE_MARK_SIZE;
|
if (rec.width < MOUSE_SCALE_MARK_SIZE) rec.width = MOUSE_SCALE_MARK_SIZE;
|
||||||
if (rec.height < MOUSE_SCALE_MARK_SIZE) rec.height = MOUSE_SCALE_MARK_SIZE;
|
if (rec.height < MOUSE_SCALE_MARK_SIZE) rec.height = MOUSE_SCALE_MARK_SIZE;
|
||||||
|
|
||||||
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) mouseScaleMode = false;
|
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) mouseScaleMode = false;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle clicking the cube
|
// Handle clicking the cube
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
Ray ray = GetMouseRay(GetMousePosition(), camera);
|
Ray ray = GetMouseRay(GetMousePosition(), camera);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris
|
||||||
// Container resizing logic
|
// Container resizing logic
|
||||||
if (resizing)
|
if (resizing)
|
||||||
{
|
{
|
||||||
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) resizing = false;
|
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) resizing = false;
|
||||||
|
|
||||||
float width = container.width + (mouse.x - lastMouse.x);
|
float width = container.width + (mouse.x - lastMouse.x);
|
||||||
container.width = (width > minWidth)? ((width < maxWidth)? width : maxWidth) : minWidth;
|
container.width = (width > minWidth)? ((width < maxWidth)? width : maxWidth) : minWidth;
|
||||||
|
|
@ -72,7 +72,7 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check if we're resizing
|
// Check if we're resizing
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) && CheckCollisionPointRec(mouse, resizer)) resizing = true;
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) && CheckCollisionPointRec(mouse, resizer)) resizing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move resizer rectangle properly
|
// Move resizer rectangle properly
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ int main(int argc, char **argv)
|
||||||
if (IsKeyPressed(KEY_SPACE)) RandomizeEmoji();
|
if (IsKeyPressed(KEY_SPACE)) RandomizeEmoji();
|
||||||
|
|
||||||
// Set the selected emoji and copy its text to clipboard
|
// Set the selected emoji and copy its text to clipboard
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && (hovered != -1) && (hovered != selected))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && (hovered != -1) && (hovered != selected))
|
||||||
{
|
{
|
||||||
selected = hovered;
|
selected = hovered;
|
||||||
selectedPos = hoveredPos;
|
selectedPos = hoveredPos;
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
// Create more bunnies
|
// Create more bunnies
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ int main(int argc, char **argv)
|
||||||
screenHeight = GetScreenHeight();
|
screenHeight = GetScreenHeight();
|
||||||
|
|
||||||
// Handle mouse
|
// Handle mouse
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
const Vector2 mouse = GetMousePosition();
|
const Vector2 mouse = GetMousePosition();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_RIGHT))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) || IsKeyPressed(KEY_RIGHT))
|
||||||
{
|
{
|
||||||
currentTexture = (currentTexture + 1)%NUM_TEXTURES; // Cycle between the textures
|
currentTexture = (currentTexture + 1)%NUM_TEXTURES; // Cycle between the textures
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
mouseHoverRec = i;
|
mouseHoverRec = i;
|
||||||
|
|
||||||
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
currentProcess = i;
|
currentProcess = i;
|
||||||
textureReload = true;
|
textureReload = true;
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue