diff options
| author | Lambert Wang <[email protected]> | 2021-05-08 09:26:24 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-08 18:26:24 +0200 |
| commit | 2545f62565fd246d1c59bf9a6bcf4942f4ad12ad (patch) | |
| tree | 817bd3580c3b7c4037a545d552d90f699be879b3 /examples | |
| parent | 2565c011580fda074e0f3dceacd5e6a1476b3284 (diff) | |
| download | raylib-2545f62565fd246d1c59bf9a6bcf4942f4ad12ad.tar.gz raylib-2545f62565fd246d1c59bf9a6bcf4942f4ad12ad.zip | |
Added support for additional mouse buttons (#1753)
* Added support for additional mouse buttons
* Renamed mouse button enum
Co-authored-by: Lambert Wang <[email protected]>
Diffstat (limited to 'examples')
22 files changed, 45 insertions, 41 deletions
diff --git a/examples/audio/audio_raw_stream.c b/examples/audio/audio_raw_stream.c index 219739b6..783c54a7 100644 --- a/examples/audio/audio_raw_stream.c +++ b/examples/audio/audio_raw_stream.c @@ -71,7 +71,7 @@ int main(void) // Sample mouse input. mousePosition = GetMousePosition(); - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) { float fp = (float)(mousePosition.y); frequency = 40.0f + (float)(fp); diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c index 99b681e3..58d75281 100644 --- a/examples/core/core_3d_picking.c +++ b/examples/core/core_3d_picking.c @@ -47,7 +47,7 @@ int main(void) //---------------------------------------------------------------------------------- UpdateCamera(&camera); // Update camera - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { if (!collision) { diff --git a/examples/core/core_input_mouse.c b/examples/core/core_input_mouse.c index ad205aed..c3415e8b 100644 --- a/examples/core/core_input_mouse.c +++ b/examples/core/core_input_mouse.c @@ -33,9 +33,13 @@ int main(void) //---------------------------------------------------------------------------------- ballPosition = GetMousePosition(); - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON; - else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME; - else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE; + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) ballColor = MAROON; + else if (IsMouseButtonPressed(MOUSE_BUTTON_MIDDLE)) ballColor = LIME; + 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 diff --git a/examples/core/core_input_multitouch.c b/examples/core/core_input_multitouch.c index cd074c15..32408a3b 100644 --- a/examples/core/core_input_multitouch.c +++ b/examples/core/core_input_multitouch.c @@ -42,13 +42,13 @@ int main(void) ballColor = BEIGE; - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) ballColor = MAROON; - if (IsMouseButtonDown(MOUSE_MIDDLE_BUTTON)) ballColor = LIME; - if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE; + if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) ballColor = MAROON; + if (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE)) ballColor = LIME; + if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) ballColor = DARKBLUE; - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) touchCounter = 10; - if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) touchCounter = 10; - if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) touchCounter = 10; + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) touchCounter = 10; + if (IsMouseButtonPressed(MOUSE_BUTTON_MIDDLE)) touchCounter = 10; + if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) touchCounter = 10; if (touchCounter > 0) touchCounter--; //---------------------------------------------------------------------------------- diff --git a/examples/models/models_loading.c b/examples/models/models_loading.c index f6cd0589..a7d34bbd 100644 --- a/examples/models/models_loading.c +++ b/examples/models/models_loading.c @@ -95,7 +95,7 @@ int main(void) } // Select model on mouse click - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { // Check collision between ray and box if (CheckCollisionRayBox(GetMouseRay(GetMousePosition(), camera), bounds)) selected = !selected; diff --git a/examples/models/models_mesh_generation.c b/examples/models/models_mesh_generation.c index ab11b84b..095aad82 100644 --- a/examples/models/models_mesh_generation.c +++ b/examples/models/models_mesh_generation.c @@ -113,7 +113,7 @@ int main(void) //---------------------------------------------------------------------------------- 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 } diff --git a/examples/physics/physics_demo.c b/examples/physics/physics_demo.c index 1acb0d13..fd4c1d25 100644 --- a/examples/physics/physics_demo.c +++ b/examples/physics/physics_demo.c @@ -63,8 +63,8 @@ int main(void) } // Physics body creation inputs - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10); - else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10); + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10); + else if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10); // Destroy falling physics bodies int bodiesCount = GetPhysicsBodiesCount(); diff --git a/examples/physics/physics_shatter.c b/examples/physics/physics_shatter.c index d14e9ba6..6c5bebfd 100644 --- a/examples/physics/physics_shatter.c +++ b/examples/physics/physics_shatter.c @@ -53,7 +53,7 @@ int main(void) 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(); for (int i = count - 1; i >= 0; i--) diff --git a/examples/shaders/shaders_hot_reloading.c b/examples/shaders/shaders_hot_reloading.c index 9b46a157..05da7b7a 100644 --- a/examples/shaders/shaders_hot_reloading.c +++ b/examples/shaders/shaders_hot_reloading.c @@ -67,7 +67,7 @@ int main(void) SetShaderValue(shader, mouseLoc, mousePos, SHADER_UNIFORM_VEC2); // Hot shader reloading - if (shaderAutoReloading || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) + if (shaderAutoReloading || (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))) { long currentFragShaderModTime = GetFileModTime(TextFormat(fragShaderFileName, GLSL_VERSION)); diff --git a/examples/shaders/shaders_julia_set.c b/examples/shaders/shaders_julia_set.c index b6138b7b..4a12ba02 100644 --- a/examples/shaders/shaders_julia_set.c +++ b/examples/shaders/shaders_julia_set.c @@ -115,10 +115,10 @@ int main(void) // TODO: The idea is to zoom and move around with mouse // 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_RIGHT_BUTTON)) zoom -= zoom*0.003f; + if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) zoom += zoom*0.003f; + if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) zoom -= zoom*0.003f; Vector2 mousePos = GetMousePosition(); diff --git a/examples/shapes/shapes_lines_bezier.c b/examples/shapes/shapes_lines_bezier.c index 00b68c9f..634eb284 100644 --- a/examples/shapes/shapes_lines_bezier.c +++ b/examples/shapes/shapes_lines_bezier.c @@ -32,8 +32,8 @@ int main(void) { // Update //---------------------------------------------------------------------------------- - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) start = GetMousePosition(); - else if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) end = GetMousePosition(); + if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) start = GetMousePosition(); + else if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) end = GetMousePosition(); //---------------------------------------------------------------------------------- // Draw diff --git a/examples/shapes/shapes_rectangle_scaling.c b/examples/shapes/shapes_rectangle_scaling.c index 6940cbcd..bd1f0648 100644 --- a/examples/shapes/shapes_rectangle_scaling.c +++ b/examples/shapes/shapes_rectangle_scaling.c @@ -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 })) { mouseScaleReady = true; - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) mouseScaleMode = true; + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) mouseScaleMode = true; } 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.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; } //---------------------------------------------------------------------------------- diff --git a/examples/text/text_draw_3d.c b/examples/text/text_draw_3d.c index 4a385f7a..bc4c5529 100644 --- a/examples/text/text_draw_3d.c +++ b/examples/text/text_draw_3d.c @@ -186,7 +186,7 @@ int main(void) } // Handle clicking the cube - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { Ray ray = GetMouseRay(GetMousePosition(), camera); diff --git a/examples/text/text_rectangle_bounds.c b/examples/text/text_rectangle_bounds.c index cb246955..9754cd45 100644 --- a/examples/text/text_rectangle_bounds.c +++ b/examples/text/text_rectangle_bounds.c @@ -61,7 +61,7 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris // Container resizing logic if (resizing) { - if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) resizing = false; + if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) resizing = false; float width = container.width + (mouse.x - lastMouse.x); 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 { // 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 diff --git a/examples/text/text_unicode.c b/examples/text/text_unicode.c index f481cb2d..fa336de7 100644 --- a/examples/text/text_unicode.c +++ b/examples/text/text_unicode.c @@ -180,7 +180,7 @@ int main(int argc, char **argv) if (IsKeyPressed(KEY_SPACE)) RandomizeEmoji(); // 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; selectedPos = hoveredPos; diff --git a/examples/textures/textures_bunnymark.c b/examples/textures/textures_bunnymark.c index b92b3d41..9be7c596 100644 --- a/examples/textures/textures_bunnymark.c +++ b/examples/textures/textures_bunnymark.c @@ -49,7 +49,7 @@ int main(void) { // Update //---------------------------------------------------------------------------------- - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) { // Create more bunnies for (int i = 0; i < 100; i++) diff --git a/examples/textures/textures_draw_tiled.c b/examples/textures/textures_draw_tiled.c index 842be11e..bc2b1724 100644 --- a/examples/textures/textures_draw_tiled.c +++ b/examples/textures/textures_draw_tiled.c @@ -75,7 +75,7 @@ int main(int argc, char **argv) screenHeight = GetScreenHeight(); // Handle mouse - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { const Vector2 mouse = GetMousePosition(); diff --git a/examples/textures/textures_image_generation.c b/examples/textures/textures_image_generation.c index 0bb10583..e2513a87 100644 --- a/examples/textures/textures_image_generation.c +++ b/examples/textures/textures_image_generation.c @@ -59,7 +59,7 @@ int main(void) { // 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 } diff --git a/examples/textures/textures_image_processing.c b/examples/textures/textures_image_processing.c index a18b1572..bb47330b 100644 --- a/examples/textures/textures_image_processing.c +++ b/examples/textures/textures_image_processing.c @@ -80,7 +80,7 @@ int main(void) { mouseHoverRec = i; - if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) { currentProcess = i; textureReload = true; diff --git a/examples/textures/textures_mouse_painting.c b/examples/textures/textures_mouse_painting.c index 5cfbe6e0..3001e853 100644 --- a/examples/textures/textures_mouse_painting.c +++ b/examples/textures/textures_mouse_painting.c @@ -88,7 +88,7 @@ int main(void) else colorMouseHover = -1; } - if ((colorMouseHover >= 0) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + if ((colorMouseHover >= 0) && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { colorSelected = colorMouseHover; colorSelectedPrev = colorSelected; @@ -107,7 +107,7 @@ int main(void) EndTextureMode(); } - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) || (GetGestureDetected() == GESTURE_DRAG)) + if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) || (GetGestureDetected() == GESTURE_DRAG)) { // Paint circle into render texture // NOTE: To avoid discontinuous circles, we could store @@ -117,7 +117,7 @@ int main(void) EndTextureMode(); } - if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) + if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) { if (!mouseWasPressed) { @@ -132,7 +132,7 @@ int main(void) if (mousePos.y > 50) DrawCircle((int)mousePos.x, (int)mousePos.y, brushSize, colors[0]); EndTextureMode(); } - else if (IsMouseButtonReleased(MOUSE_RIGHT_BUTTON) && mouseWasPressed) + else if (IsMouseButtonReleased(MOUSE_BUTTON_RIGHT) && mouseWasPressed) { colorSelected = colorSelectedPrev; mouseWasPressed = false; @@ -144,7 +144,7 @@ int main(void) // Image saving logic // NOTE: Saving painted texture to a default named image - if ((btnSaveMouseHover && IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) || IsKeyPressed(KEY_S)) + if ((btnSaveMouseHover && IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) || IsKeyPressed(KEY_S)) { Image image = GetTextureData(target.texture); ImageFlipVertical(&image); @@ -177,7 +177,7 @@ int main(void) // Draw drawing circle for reference if (mousePos.y > 50) { - if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) DrawCircleLines((int)mousePos.x, (int)mousePos.y, brushSize, GRAY); + if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) DrawCircleLines((int)mousePos.x, (int)mousePos.y, brushSize, GRAY); else DrawCircle(GetMouseX(), GetMouseY(), brushSize, colors[colorSelected]); } diff --git a/examples/textures/textures_sprite_button.c b/examples/textures/textures_sprite_button.c index 6ca4ea90..3d1a1834 100644 --- a/examples/textures/textures_sprite_button.c +++ b/examples/textures/textures_sprite_button.c @@ -53,10 +53,10 @@ int main(void) // Check button state if (CheckCollisionPointRec(mousePoint, btnBounds)) { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) btnState = 2; + if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) btnState = 2; else btnState = 1; - if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) btnAction = true; + if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) btnAction = true; } else btnState = 0; diff --git a/examples/textures/textures_sprite_explosion.c b/examples/textures/textures_sprite_explosion.c index 2394f6a8..4cb76906 100644 --- a/examples/textures/textures_sprite_explosion.c +++ b/examples/textures/textures_sprite_explosion.c @@ -53,7 +53,7 @@ int main(void) //---------------------------------------------------------------------------------- // Check for mouse button pressed and activate explosion (if not active) - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && !active) + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && !active) { position = GetMousePosition(); active = true; |
