Commit Graph

94 Commits

Author SHA1 Message Date
lynxnb
655ca8f89b Ignore OSC roll-over events if the button is already pressed 2023-05-02 12:27:57 +01:00
lynxnb
560fcd9442 Implement toggle mode for OSC buttons
When toggle mode is enabled, the button will toggle between the `Pressed` and `Released` state when it's pressed.

Without toggle mode:
ACTION_DOWN -> Pressed
ACTION_UP -> Released
ACTION_DOWN -> Pressed
ACTION_UP -> Released

With toggle mode:
ACTION_DOWN -> Pressed
ACTION_UP -> No event
ACTION_DOWN -> No event
ACTION_UP -> Released
2023-05-02 12:27:57 +01:00
lynxnb
78252fbcbd Show current input values in OnScreenEditActivity
This was made primarily for debugging on-screen controls, but it might be useful to users too.
2023-05-02 12:27:57 +01:00
lynxnb
69fb15ffc9 Improve separation between OSCEditActivity and OSCView
The activity shouldn't access the edit button directly, but should only access data available through the public interface.
2023-05-02 12:27:57 +01:00
lynxnb
7e3d3bd281 Draw a box around disabled OSC buttons in edit mode
The box is also drawn if the alpha is configured too low (<5%).
2023-05-02 12:27:57 +01:00
lynxnb
659e090d38 Enable OSC per-button text and color selection 2023-05-02 12:27:57 +01:00
lynxnb
c7d213c3ea Make the OSC edit panel collapsible
The panel can now be closed to try out the buttons.
2023-05-02 12:27:57 +01:00
lynxnb
3f2fd7a653 Make some properties constant in OnScreenButton
They were initially made variable by mistake
2023-05-02 12:27:57 +01:00
lynxnb
37a2a2fbad Fix inconsistent OSC button movements when using the arrow buttons
A combination of factors caused inconsistent button movements when using the arrow buttons to move it, namely floating point approximation and the round down performed when snapping a button to the grid. Sometimes the layman solution is the best one: adding/subtracting one to the move amount depending on the direction ensures that the button always ends up on a grid line.
2023-05-02 12:27:57 +01:00
lynxnb
1d6b075d5c Draw a selection rectangle around the active button while editing 2023-05-02 12:27:57 +01:00
lynxnb
e91993698f Remove OSC EditMode enum
An enum isn't needed anymore, as there's no state to enumerate anymore.
2023-05-02 12:27:57 +01:00
lynxnb
2556b25ebf Fix OSC incorrect pressed alpha when low values are used
OSC would "light up" when the alpha value was low because of the value being coerced to an arbitrary range. Divide the alpha value by 3 instead.
2023-05-02 12:27:57 +01:00
lynxnb
d69c9f472f Make the OSC control panel draggable 2023-05-02 12:27:57 +01:00
lynxnb
d7e38e9556 Introduce a control panel to edit buttons instead of a fab bar
An unusual big commit, unfortunately needed because none of these changes would make sense nor work individual. A quick list of what have been done follows.
* Introduced a control panel to control buttons replacing the FAB bar
* `ConfigurableButton` and `OnScreenConfiguration` interfaces have been introduced to allow for easier proxying of actions when applying the same changes to all buttons
* Button resize logic has been stripped from the buttons in favor of the new sliders
* General cleanup and renaming of various methods to better reflect their functionality
2023-05-02 12:27:57 +01:00
lynxnb
49de8a8f38 Rework OSC action bar appearance
FABs are now placed on top of a sheet hanging from the top. Actions are now properly enumerated and don't rely on the icon resource ID anymore.
2023-05-02 12:27:57 +01:00
Dima
1841727c56 Remove header rom filter 2023-04-22 19:54:04 +01:00
lynxnb
816599749b Fix Android Studio OSC layout preview (again)
The layout preview/editor doesn't instantiate an Application instance, therefore accessing `displayMetrics` from the app context would lead to a crash, and the view being mocked in the preview.
Additionally a default grid value is defined for `AlignmentGridView` to avoid a crash because of an invalid iteration step in the drawing loop.
2023-04-02 18:16:10 +02:00
lynxnb
3cbbdeda33 Improve OSC default position of sticks and buttons 2023-04-02 18:16:10 +02:00
lynxnb
a799cb63f1 Add separate L3 and R3 buttons to OSC
As part of this commit, a `defaultEnabled` property was added to `OnScreenButton` to determine the default visibility of buttons. This is required because L3 and R3 should be hidden by default and only enabled by the user on demand.
Additionally, the buttons' mask values were added to `ButtonId` members, as adding entries in the middle of the class conflicted with the `ordinal` enum property, making it unfit to use for our purposes.
Finally, the `ControllerType` class was extended with an array of optional buttons. Optional buttons represent buttons that are allowed to be displayed on screen, but shouldn't be included in the controller mapping activity.
2023-04-02 18:16:10 +02:00
lynxnb
acdf4e6823 Introduce constants for default OSC config values 2023-04-02 18:16:10 +02:00
lynxnb
83bc93601f Use EFFECT_TICK instead of CLICK as OSC vibration effect 2023-04-02 18:16:10 +02:00
lynxnb
88e6fc9888 Implement OSC snap to grid functionality 2023-04-02 18:16:10 +02:00
lynxnb
88084016a1 Implement OSC per-button scale functionality 2023-04-02 18:16:10 +02:00
lynxnb
2794af6d06 OSC: delegate config reset to individual buttons 2023-04-02 18:16:10 +02:00
lynxnb
3fc09f0953 Add OnScreenButton properties' missing comments 2023-04-02 18:16:10 +02:00
lynxnb
81eb8fd231 Rework OSC edit mode handling for better extensibility
Edit mode configuration parameters are now shared between the view and the buttons in a small `OnScreenEditInfo` object, avoiding variable duplication about edit state. The `editingTouchHandler` has also been simplified to only lookup the button if one wasn't being edited already.
2023-04-02 18:16:10 +02:00
lynxnb
c4d0d02509 Simplify OnScreenConfiguration
`ControllerConfigurationDummy` was removed as it isn't needed anymore, and the remaining classes simplified.
2023-04-02 18:16:10 +02:00
lynxnb
17f45c0366 Retrieve the vibrator service outside of OSC View
Retrieving the vibrator service inside the view crashes the layout editor. Fix by retrieving it in the activity and passing it to the view.
2023-04-02 18:16:10 +02:00
lynxnb
ab553c9671 Use MD3 divider in ControllerActivity 2023-03-22 21:57:50 +01:00
lynxnb
b12a2bdc3e Replace preference checkboxes with material switches 2023-03-22 21:57:50 +01:00
lynxnb
2bcf0e2abd Update themes and styles to Material Design 3
This commit transitions all layouts and views to the use the new stuff from MD3.
2023-03-22 21:57:50 +01:00
Abandoned Cart
0949d51871 Clear or suppress some easy lint warnings 2023-03-18 16:16:15 +01:00
lynxnb
b724bc2309 Adjust default OSC opacity and color 2023-03-05 12:45:07 +01:00
KikiManjaro
1282362fce Add color selection to OSC
* Add bold text and antialiasing for osc buttons
* Fix osc dpad and button position (widder than taller)
* Set default OSC color to white background with black text
2023-03-05 12:45:07 +01:00
KikiManjaro
66d2965c63 Fix resetControls for opacity of OSC 2023-03-05 12:45:07 +01:00
lynxnb
cd426d9f18 Split PreferenceSettings into AppSettings and EmulationSettings
`PreferenceSettings` was removed in favor of:
* `AppSettings`: stores general purpose settings mostly used for UI configuration and state
* `EmulationSettings`: stores emulation-related settings, most of these are passed to native emulation code
2023-02-27 19:56:53 +01:00
lynxnb
a1ca84f95e Move Kotlin settings to a dedicate package 2023-02-27 19:56:53 +01:00
Abandoned Cart
b20c6e9fc4 onBackPressed -> onBackPressedDispatcher 2023-02-16 14:50:02 +01:00
german77
9e1c9caa36 input: Fix motion orientation based on phone orientation 2023-02-07 16:16:41 +00:00
german77
56d43a70c0 Implement SixAxis sensor 2023-02-07 16:16:41 +00:00
lynxnb
aa36c591c6 Exclude Home button from controller setup guide 2023-01-11 20:51:18 +00:00
Abandoned Cart
b08fcd7027 Favor a predefined "click" over system vibration 2022-12-10 14:57:33 +00:00
Abandoned Cart
cfd3bfecba Add a rudimentary OSC button vibration setting 2022-12-10 14:57:33 +00:00
lynxnb
163f4f2014 Fix window insets handling when in landscape mode
To avoid code duplication, insets handling has been moved to a separate interface.
2022-11-23 19:49:42 +05:30
lynxnb
b209ae8e90 Account for stick flat area when retrieving axes value from a MotionEvent 2022-11-17 21:54:15 +01:00
lynxnb
c966220bab Zero-initialize axes history instead of using null values
Use zero initialization for axes history instead of using null values. Fixes the first axis event after launching a game being completely ignored.
2022-11-17 21:54:15 +01:00
lynxnb
3a657c44cc Don't ignore HAT axes input events
Capture HAT axes events ourselves instead of relying on the android framework to turn them into KeyCodes. Fixes handling of DPAD button presses on most controllers.
2022-11-17 21:54:15 +01:00
lynxnb
f1ec771944 Fix inverted axis polarity
In the case of axis value being zero, polarity would favor one side of the stick resulting in invalid values. Fix that by taking into account axis history when calculating polarity.
2022-11-17 21:54:15 +01:00
lynxnb
675e8dbb2e Move input handling code to a dedicated class 2022-11-17 21:54:15 +01:00
lybxlpsv
18861d73a3 Set systemUiVisibility during onResume for A11 2022-11-17 14:04:57 +01:00