Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

Add get mouse button fn input utils #1582

Merged
merged 2 commits into from
May 12, 2019

Conversation

alex-eg
Copy link
Contributor

@alex-eg alex-eg commented May 8, 2019

Description

I found myself in need of functions to get mouse button state from Event instance in state handle_event function, so I wrote a couple.
It also seemed to me that as they are analogous to get_key and is_key_down for keyboard key status, new functions should reside in the same file, so I placed it in amethyst_input/util.rs

Then I enhanced a bit fly_camera example to demonstrate how to capture and release mouse input and hide and show cursor. Here I made use of newly created functions.
It also turned out that fly_camera example behaves a bit odd, so I fixed this by providing explicit transform for it's prefab.

Additions

get_mouse_button function to amethist_utlils
is_mouse_button_pressed function to amethist_utils

Removals

None.

Modifications

fly_camera example: add cursor show/hide, mouse input release/capture, also fix prefab so mouse lookout directions are not inverted, and camera looks at cube at the start.

PR Checklist

By placing an x in the boxes I certify that I have:

  • Ran cargo test --all locally if this modified any rs files.
  • Ran cargo +stable fmt --all locally if this modified any rs files.
  • Updated the content of the book if this PR would make the book outdated.
  • Added a changelog entry if this will impact users, or modified more than 5 lines of Rust that wasn't a doc comment.
  • Added unit tests for new APIs if any were added in this PR.
  • Acknowledged that by making this pull request I release this code under an MIT/Apache 2.0 dual licensing scheme.

@@ -78,6 +79,8 @@ extra bounds from `AnimatablePrefab` and `AnimationSetPrefab` ([#1435])
* `NetConnection` is automatically created when client starts sends data to server. ([#1539])
* User will receive `NetEvent::Connected` on new connection and `NetEvent::Dissconnected` on disconnect. ([#1539])
* Added a `pivot` field to `UiTransform`. ([#1571])
* Fix fly_camera example initial camera and cube position. ([#1582])
* Add to fly_camera example code to release and capture back mouse input, and to show and hide cursor. ([#1582])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add the link to the #1582 pr. you can see how it is done for other pull requests a bit lower in the same file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay!

@alex-eg alex-eg force-pushed the add-get-mouse-button-fn-input-utils branch 2 times, most recently from 4d80255 to f72a6c7 Compare May 10, 2019 10:04
@alex-eg
Copy link
Contributor Author

alex-eg commented May 10, 2019

@Jojolepro, I have fixed the changelog file and also fixed merge conflict there.

@alex-eg
Copy link
Contributor Author

alex-eg commented May 11, 2019

Thanks for reviewing!

It seems Jenkins hadn't started checks yet. Is some action required at this point?

@azriel91
Copy link
Member

yeap, just this 😄:

bors r=jojolepro, jaynus

@bors
Copy link
Contributor

bors bot commented May 11, 2019

Merge conflict (retrying...)

1 similar comment
@bors
Copy link
Contributor

bors bot commented May 11, 2019

Merge conflict (retrying...)

@bors
Copy link
Contributor

bors bot commented May 11, 2019

Merge conflict

@alex-eg alex-eg force-pushed the add-get-mouse-button-fn-input-utils branch from f72a6c7 to 988566a Compare May 12, 2019 09:50
@alex-eg
Copy link
Contributor Author

alex-eg commented May 12, 2019

bors r=jojolepro, jaynus

@bors
Copy link
Contributor

bors bot commented May 12, 2019

🔒 Permission denied

Existing reviewers: click here to make alex-eg a reviewer

@alex-eg
Copy link
Contributor Author

alex-eg commented May 12, 2019

Oh it seems I didn't quite understood how bors works.

@Moxinilian
Copy link
Member

bors r=jojolepro, jaynus

bors bot added a commit that referenced this pull request May 12, 2019
1582: Add get mouse button fn input utils r=jojolepro,jaynus a=alex-eg

## Description

I found myself in need of functions to get mouse button state from `Event` instance in state `handle_event` function, so I wrote a couple. 
It also seemed to me that as they are analogous to `get_key` and `is_key_down` for keyboard key status, new functions should reside in the same file, so I placed it in amethyst_input/util.rs

Then I enhanced a bit fly_camera example to demonstrate how to capture and release mouse input and hide and show cursor. Here I made use of newly created functions.
It also turned out that fly_camera example behaves a bit odd, so I fixed this by providing explicit transform for it's prefab.

## Additions
`get_mouse_button` function to amethist_utlils
`is_mouse_button_pressed` function to amethist_utils

## Removals
None.

## Modifications
fly_camera example: add cursor show/hide, mouse input release/capture, also fix prefab so mouse lookout directions are not inverted, and camera looks at cube at the start.

## PR Checklist

By placing an x in the boxes I certify that I have:

- [x] Ran `cargo test --all` locally if this modified any rs files.
- [x] Ran `cargo +stable fmt --all` locally if this modified any rs files.
- [x] Updated the content of the book if this PR would make the book outdated.
- [x] Added a changelog entry if this will impact users, or modified more than 5 lines of Rust that wasn't a doc comment.
- [x] Added unit tests for new APIs if any were added in this PR.
- [x] Acknowledged that by making this pull request I release this code under an MIT/Apache 2.0 dual licensing scheme.


Co-authored-by: taptap <alexey.e.egorov@gmail.com>
@Moxinilian
Copy link
Member

bors r-

@bors
Copy link
Contributor

bors bot commented May 12, 2019

Canceled

@alex-eg alex-eg closed this May 12, 2019
@alex-eg alex-eg reopened this May 12, 2019
Add two functions: get_mouse_button and is_mouse_button_down,
analoguous to get_key and is_key_down for keyboard keys.
Due to void transform component, camera loaded from prefab with up
vector pointing down y aixs, i.e. mouse lookout left and right
direction were swapped.

Cube position seemed a bit to distant, so it moved closer to the
viewer.

Add to flying camera example cursor uncapture and re-capture
Also add info about it to examples README.md.
@alex-eg alex-eg force-pushed the add-get-mouse-button-fn-input-utils branch from 988566a to 4df3627 Compare May 12, 2019 17:26
@Moxinilian
Copy link
Member

bors r=jojolepro, jaynus

bors bot added a commit that referenced this pull request May 12, 2019
1582: Add get mouse button fn input utils r=jojolepro,jaynus a=alex-eg

## Description

I found myself in need of functions to get mouse button state from `Event` instance in state `handle_event` function, so I wrote a couple. 
It also seemed to me that as they are analogous to `get_key` and `is_key_down` for keyboard key status, new functions should reside in the same file, so I placed it in amethyst_input/util.rs

Then I enhanced a bit fly_camera example to demonstrate how to capture and release mouse input and hide and show cursor. Here I made use of newly created functions.
It also turned out that fly_camera example behaves a bit odd, so I fixed this by providing explicit transform for it's prefab.

## Additions
`get_mouse_button` function to amethist_utlils
`is_mouse_button_pressed` function to amethist_utils

## Removals
None.

## Modifications
fly_camera example: add cursor show/hide, mouse input release/capture, also fix prefab so mouse lookout directions are not inverted, and camera looks at cube at the start.

## PR Checklist

By placing an x in the boxes I certify that I have:

- [x] Ran `cargo test --all` locally if this modified any rs files.
- [x] Ran `cargo +stable fmt --all` locally if this modified any rs files.
- [x] Updated the content of the book if this PR would make the book outdated.
- [x] Added a changelog entry if this will impact users, or modified more than 5 lines of Rust that wasn't a doc comment.
- [x] Added unit tests for new APIs if any were added in this PR.
- [x] Acknowledged that by making this pull request I release this code under an MIT/Apache 2.0 dual licensing scheme.


Co-authored-by: taptap <alexey.e.egorov@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 12, 2019

Build succeeded

@bors bors bot merged commit 4df3627 into amethyst:master May 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants