├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── gamecontroller
├── build.gradle
├── gradle.properties
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── andretietz
│ │ └── android
│ │ └── controller
│ │ ├── ActionView.java
│ │ ├── DirectionView.java
│ │ └── InputView.java
│ └── res
│ ├── drawable
│ ├── action_background.xml
│ ├── action_pressed.xml
│ ├── action_usual.xml
│ ├── direction_background.xml
│ ├── direction_down_pressed.xml
│ ├── direction_down_usual.xml
│ ├── direction_left_pressed.xml
│ ├── direction_left_usual.xml
│ ├── direction_right_pressed.xml
│ ├── direction_right_usual.xml
│ ├── direction_up_pressed.xml
│ └── direction_up_usual.xml
│ └── values
│ ├── colors.xml
│ ├── default_styles.xml
│ ├── dimen.xml
│ ├── input_attrs.xml
│ └── strings.xml
├── gradle.properties
├── gradle
├── publish.gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── andretietz
│ │ └── controllerlib
│ │ └── demo
│ │ └── ControllerActivity.java
│ └── res
│ ├── layout
│ └── activity_controller.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .idea
3 | build
4 | .gradle
5 | local.properties
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # controller-lib
2 | This Android-library should help you to show a common game controller on the screen and react to its user input
3 |
4 | At the moment the only supported Buttons are the Directionbuttons (8-way) and the Action-Input of a user, such as on the Playstation- or the XBox-Controller
5 |
6 | This library uses VectorDrawable and has downward-support down to API Level 14
7 |
8 | ## Dependencies:
9 | * appcompat 25.1.0
10 |
11 | ## How to use in your project:
12 | Add this library as a dependency
13 |
14 | ```groovy
15 | compile 'com.andretietz.android:gamecontroller:1.1.1'
16 | ```
17 |
18 | ## Add both of the Views to your layout:
19 |
20 | ```xml
21 |
28 |
29 |
36 | ```
37 |
38 | and create listeners for them
39 | ```java
40 | ActionView actionView = (ActionView) findViewById(R.id.viewAction);
41 | actionView.setOnButtonListener(new InputView.InputEventListener() {
42 | @Override public void onInputEvent(View view, int buttons) {
43 | // foreach button (there are 4 action buttons)
44 | for(int i=0;i<4;i++) {
45 | // if the bit on position i is set
46 | if(((0x01 << i)&buttons)>0) {
47 | // Button Number (i+1) is pressed
48 | }
49 | }
50 | // if buttons == 0, the user stopped touching the view
51 | }
52 | });
53 | ...
54 | // same for DirectionView
55 | DirectionView directionView = (DirectionView) findViewById(R.id.viewDirection);
56 | directionView.setOnButtonListener(new InputView.InputEventListener() {
57 | @Override public void onInputEvent(View view, int buttons) {
58 | switch (buttons&0xff) {
59 | case DirectionView.DIRECTION_DOWN:
60 | // do smth.
61 | break;
62 | case DirectionView.DIRECTION_LEFT:
63 | break;
64 | case DirectionView.DIRECTION_RIGHT:
65 | break;
66 | case DirectionView.DIRECTION_UP:
67 | break;
68 | case DirectionView.DIRECTION_DOWN_LEFT:
69 | break;
70 | case DirectionView.DIRECTION_UP_LEFT:
71 | break;
72 | case DirectionView.DIRECTION_DOWN_RIGHT:
73 | break;
74 | case DirectionView.DIRECTION_UP_RIGHT:
75 | break;
76 | }
77 |
78 | // if buttons == 0, the user stopped touching the view
79 | }
80 | });
81 | ```
82 |
83 | ## Customizing:
84 | If you want to customize the views, you can do it in the layout xml. I recommend creating a style for it, but thats up to you.
85 |
86 | Since both views extend from InputView, you can customize a lot with this already. Both views will react on this attributes.
87 |
88 | ### InputView options:
89 |
90 | * inputBackground (drawable reference)
91 | * This attribute takes a Drawable (Create VectorDrawables (xml) vector-compat compatible!)
92 | * The size of this drawable defines the maximum size of this View
93 | * deadZone (0...1)
94 | * All Buttons are around the center of the view, like pieces of cake. If the user goes too close to the
95 | center of the view it could happen that he accidentially hits other buttons than he wanted to. To avoid that you can set a deadZone. The value has to be between 0 and 1. 0 means no deadZone, 1 means everything is deadZone ;)
96 | * buttonCenterDistance (0...1)
97 | * each button on the view can have its own drawable. This value tells the view how far from the center of the view the buttons will be drawn. 0 means all buttons get drawn in the middle of the view. 1 means on the edge of the view. As origin of the buttons, the center of the drawables will be used.
98 | * rotateButtons (0...360)
99 | * Rotate the whole Button Circle
100 | * vibrate (true|false)
101 | * Vibrates on touch. Remember the Vibrate permissions!
102 | * debug_drawDeadZone (true|false)
103 | * This is for debugging only, but if you need it, use it. It draws the deadZone ontop of everything else
104 | * debug_drawPieces (true|false)
105 | * This is for debugging only, but if you need it, use it. It draws the button pieces, when klicking on them
106 |
107 | Example:
108 | ```xml
109 |
111 | ...
112 |
121 | ```
122 | ### DirectionView options
123 |
124 | * button_r_normal - VectorDrawable for the unpressed Button: Right
125 | * button_r_pressed - VectorDrawable for the pressed Button: Right
126 | * button_d_normal - VectorDrawable for the unpressed Button: Down
127 | * button_d_pressed - VectorDrawable for the pressed Button: Down
128 | * button_l_normal - VectorDrawable for the unpressed Button: Left
129 | * button_l_pressed - VectorDrawable for the pressed Button: Left
130 | * button_u_normal - VectorDrawable for the unpressed Button: Up
131 | * button_u_pressed - VectorDrawable for the pressed Button: Up
132 | * diagonal_mode (true|false)
133 | * When this is set to true, the DirectionView will not draw the between buttons (ul,ur,dr,dl), it will highlight the buttons arround it. So in case of ul it will highlight the buttons Up and Left. The result in the Listener will stay the same in both cases.
134 |
135 | These values will only be drawn, if diagonal_mode is set to false
136 | * button_ur_normal
137 | * button_ur_pressed
138 | * button_ul_normal
139 | * button_ul_pressed
140 | * button_dr_normal
141 | * button_dr_pressed
142 | * button_dl_normal
143 | * button_dl_pressed
144 |
145 | ### ActionView
146 |
147 | The buttons are drawn from the right to the bottom, to the left - up and to the right again. So there indexes are as well. This is a bit inconsistent (i.e. to the listener), I should fix that in future releases.
148 |
149 | * button1_enabled - VectorDrawable for the right button if not pressed
150 | * button1_pressed - VectorDrawable for the right button if pressed
151 | * button2_enabled - VectorDrawable for the bottom button if not pressed
152 | * button2_pressed - VectorDrawable for the bottom button if pressed
153 | * button3_enabled - VectorDrawable for the left button if not pressed
154 | * button3_pressed - VectorDrawable for the left button if pressed
155 | * button4_enabled - VectorDrawable for the top button if not pressed
156 | * button4_pressed - VectorDrawable for the top button if pressed
157 |
158 | # Screenshot
159 | 
160 |
161 | ## License
162 | Copyright 2017 André Tietz
163 |
164 | Licensed under the Apache License, Version 2.0 (the "License");
165 | you may not use this file except in compliance with the License.
166 | You may obtain a copy of the License at
167 |
168 | http://www.apache.org/licenses/LICENSE-2.0
169 |
170 | Unless required by applicable law or agreed to in writing, software
171 | distributed under the License is distributed on an "AS IS" BASIS,
172 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
173 | See the License for the specific language governing permissions and
174 | limitations under the License.
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | jcenter()
4 | google()
5 | mavenLocal()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:4.1.1'
9 | }
10 | }
11 |
12 | allprojects {
13 | repositories {
14 | jcenter()
15 | google()
16 | mavenLocal()
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/gamecontroller/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 27
5 |
6 | defaultConfig {
7 | minSdkVersion 14
8 | targetSdkVersion 27
9 | vectorDrawables.useSupportLibrary = true
10 | }
11 |
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
16 | }
17 | }
18 | }
19 |
20 | dependencies {
21 | api "com.android.support:appcompat-v7:$supportLibraryVersion"
22 | }
23 |
24 | apply from: rootProject.file('gradle/publish.gradle')
25 |
--------------------------------------------------------------------------------
/gamecontroller/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=gamecontroller
2 | POM_NAME=This is an Android Library that supports Views to emulate a simple gamecontroller on android devices
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/gamecontroller/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\dev\tools\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/java/com/andretietz/android/controller/ActionView.java:
--------------------------------------------------------------------------------
1 | package com.andretietz.android.controller;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.content.res.TypedArray;
6 | import android.graphics.drawable.Drawable;
7 | import android.os.Build;
8 | import android.support.v7.content.res.AppCompatResources;
9 | import android.util.AttributeSet;
10 |
11 |
12 | /**
13 | * This view can be used for action inputs. it has 4 Button, as it is usual
14 | * for common game controllers such as PS,XBox and similar ones
15 | */
16 | public class ActionView extends InputView {
17 |
18 | private static final int BUTTON_COUNT = 4;
19 | private Drawable[][] drawables = new Drawable[BUTTON_COUNT][2];
20 | private int[][] resources = new int[BUTTON_COUNT][2];
21 |
22 | public ActionView(Context context) {
23 | super(context);
24 | }
25 |
26 | public ActionView(Context context, AttributeSet attrs) {
27 | super(context, attrs);
28 | init(context, attrs);
29 | }
30 |
31 | public ActionView(Context context, AttributeSet attrs, int defStyleAttr) {
32 | super(context, attrs, defStyleAttr);
33 | init(context, attrs);
34 | }
35 |
36 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
37 | public ActionView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
38 | super(context, attrs, defStyleAttr, defStyleRes);
39 | init(context, attrs);
40 | }
41 |
42 | protected void init(Context context, AttributeSet attrs) {
43 | // read the attributes from xml
44 | TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ActionView, 0, R.style.default_actionview);
45 | super.init(context, attrs, R.style.default_actionview);
46 | try {
47 | resources[0][0] = a.getResourceId(R.styleable.ActionView_button1_enabled, R.drawable.action_usual);
48 | resources[0][1] = a.getResourceId(R.styleable.ActionView_button1_pressed, R.drawable.action_pressed);
49 | resources[1][0] = a.getResourceId(R.styleable.ActionView_button2_enabled, R.drawable.action_usual);
50 | resources[1][1] = a.getResourceId(R.styleable.ActionView_button2_pressed, R.drawable.action_pressed);
51 | resources[2][0] = a.getResourceId(R.styleable.ActionView_button3_enabled, R.drawable.action_usual);
52 | resources[2][1] = a.getResourceId(R.styleable.ActionView_button3_pressed, R.drawable.action_pressed);
53 | resources[3][0] = a.getResourceId(R.styleable.ActionView_button4_enabled, R.drawable.action_usual);
54 | resources[3][1] = a.getResourceId(R.styleable.ActionView_button4_pressed, R.drawable.action_pressed);
55 | } finally {
56 | a.recycle();
57 | }
58 | }
59 |
60 | @Override
61 | protected Drawable getStateDrawable(int buttonIndex, ButtonState state) {
62 | if (null == drawables[buttonIndex][state.ordinal()]) {
63 | drawables[buttonIndex][state.ordinal()] = AppCompatResources
64 | .getDrawable(getContext(), resources[buttonIndex][state.ordinal()]);
65 | }
66 | return drawables[buttonIndex][state.ordinal()];
67 | }
68 |
69 | @Override
70 | protected int getButtonCount() {
71 | return BUTTON_COUNT;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/java/com/andretietz/android/controller/DirectionView.java:
--------------------------------------------------------------------------------
1 | package com.andretietz.android.controller;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.content.res.TypedArray;
6 | import android.graphics.drawable.Drawable;
7 | import android.os.Build;
8 | import android.support.v7.content.res.AppCompatResources;
9 | import android.util.AttributeSet;
10 |
11 | /**
12 | * This View can be used for direction input on a game controller. it has 8 different directions,
13 | * as it was on older controllers.
14 | */
15 | public class DirectionView extends InputView {
16 |
17 | public static final int DIRECTION_RIGHT = 0x01;
18 | public static final int DIRECTION_DOWN_RIGHT = 0x02;
19 | public static final int DIRECTION_DOWN = 0x04;
20 | public static final int DIRECTION_DOWN_LEFT = 0x08;
21 | public static final int DIRECTION_LEFT = 0x10;
22 | public static final int DIRECTION_UP_LEFT = 0x20;
23 | public static final int DIRECTION_UP = 0x40;
24 | public static final int DIRECTION_UP_RIGHT = 0x80;
25 | private static final int BUTTON_COUNT = 8;
26 | // @formatter:off
27 | private static final int BUTTON_RIGHT = 0;
28 | private static final int BUTTON_DOWN_RIGHT = 1;
29 | private static final int BUTTON_DOWN = 2;
30 | private static final int BUTTON_DOWN_LEFT = 3;
31 | private static final int BUTTON_LEFT = 4;
32 | private static final int BUTTON_UP_LEFT = 5;
33 | private static final int BUTTON_UP = 6;
34 | private static final int BUTTON_UP_RIGHT = 7;
35 | // @formatter:on
36 | private boolean diagonalMode = false;
37 | private Drawable[][] drawables = new Drawable[BUTTON_COUNT][2];
38 | private int[][] resources = new int[BUTTON_COUNT][2];
39 |
40 | public DirectionView(Context context) {
41 | super(context);
42 | }
43 |
44 | public DirectionView(Context context, AttributeSet attrs) {
45 | super(context, attrs);
46 | init(context, attrs);
47 | }
48 |
49 | public DirectionView(Context context, AttributeSet attrs, int defStyleAttr) {
50 | super(context, attrs, defStyleAttr);
51 | init(context, attrs);
52 | }
53 |
54 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
55 | public DirectionView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
56 | super(context, attrs, defStyleAttr, defStyleRes);
57 | init(context, attrs);
58 | }
59 |
60 | protected void init(Context context, AttributeSet attrs) {
61 | if (null != attrs) {
62 | TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DirectionView, 0, R.style.default_directionview);
63 | super.init(context, attrs, R.style.default_directionview);
64 | try {
65 | resources[BUTTON_RIGHT][0] = a.getResourceId(R.styleable.DirectionView_button_r_normal, 0);
66 | resources[BUTTON_RIGHT][1] = a.getResourceId(R.styleable.DirectionView_button_r_pressed, 0);
67 | resources[BUTTON_DOWN][0] = a.getResourceId(R.styleable.DirectionView_button_d_normal, 0);
68 | resources[BUTTON_DOWN][1] = a.getResourceId(R.styleable.DirectionView_button_d_pressed, 0);
69 | resources[BUTTON_LEFT][0] = a.getResourceId(R.styleable.DirectionView_button_l_normal, 0);
70 | resources[BUTTON_LEFT][1] = a.getResourceId(R.styleable.DirectionView_button_l_pressed, 0);
71 | resources[BUTTON_UP][0] = a.getResourceId(R.styleable.DirectionView_button_u_normal, 0);
72 | resources[BUTTON_UP][1] = a.getResourceId(R.styleable.DirectionView_button_u_pressed, 0);
73 |
74 |
75 | diagonalMode = a.getBoolean(R.styleable.DirectionView_diagonal_mode, false);
76 | if (diagonalMode) {
77 | resources[BUTTON_DOWN_RIGHT][0] = a.getResourceId(R.styleable.DirectionView_button_dr_normal, 0);
78 | resources[BUTTON_DOWN_RIGHT][1] = a.getResourceId(R.styleable.DirectionView_button_dr_pressed, 0);
79 | resources[BUTTON_DOWN_LEFT][0] = a.getResourceId(R.styleable.DirectionView_button_dl_normal, 0);
80 | resources[BUTTON_DOWN_LEFT][1] = a.getResourceId(R.styleable.DirectionView_button_dl_pressed, 0);
81 | resources[BUTTON_UP_LEFT][0] = a.getResourceId(R.styleable.DirectionView_button_ul_normal, 0);
82 | resources[BUTTON_UP_LEFT][1] = a.getResourceId(R.styleable.DirectionView_button_ul_pressed, 0);
83 | resources[BUTTON_UP_RIGHT][0] = a.getResourceId(R.styleable.DirectionView_button_ur_normal, 0);
84 | resources[BUTTON_UP_RIGHT][1] = a.getResourceId(R.styleable.DirectionView_button_ur_pressed, 0);
85 | }
86 | } finally {
87 | a.recycle();
88 | }
89 | }
90 | }
91 |
92 | @Override
93 | protected Drawable getStateDrawable(int buttonIndex, ButtonState state) {
94 | // if diagonal mode is activated and one of the diagonal buttons are pressed
95 | if (diagonalMode && (buttonIndex == 1 || buttonIndex == 3 || buttonIndex == 5 || buttonIndex == 7)) {
96 | return null;
97 | }
98 | if (null == drawables[buttonIndex][state.ordinal()]) {
99 | drawables[buttonIndex][state.ordinal()] = AppCompatResources.getDrawable(getContext(), resources[buttonIndex][state.ordinal()]);
100 | }
101 | return drawables[buttonIndex][state.ordinal()];
102 | }
103 |
104 | @SuppressWarnings("PointlessBitwiseExpression")
105 | @Override
106 | protected int forceDrawButtons(int buttonPressed) {
107 | if (diagonalMode) {
108 | for (int i = 1; i < BUTTON_COUNT; i += 2) {
109 | if (((0x1 << i) & buttonPressed) > 0) {
110 | switch (i) {
111 | case BUTTON_DOWN_RIGHT:
112 | return buttonPressed | (0x1 << BUTTON_DOWN) | (0x1 << BUTTON_RIGHT);
113 | case BUTTON_DOWN_LEFT:
114 | return buttonPressed | (0x1 << BUTTON_DOWN) | (0x1 << BUTTON_LEFT);
115 | case BUTTON_UP_LEFT:
116 | return buttonPressed | (0x1 << BUTTON_UP) | (0x1 << BUTTON_LEFT);
117 | case BUTTON_UP_RIGHT:
118 | return buttonPressed | (0x1 << BUTTON_UP) | (0x1 << BUTTON_RIGHT);
119 | }
120 | }
121 | }
122 | }
123 | return buttonPressed;
124 | }
125 |
126 | @Override
127 | protected int getButtonCount() {
128 | return BUTTON_COUNT;
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/java/com/andretietz/android/controller/InputView.java:
--------------------------------------------------------------------------------
1 | package com.andretietz.android.controller;
2 |
3 | import android.Manifest;
4 | import android.annotation.SuppressLint;
5 | import android.annotation.TargetApi;
6 | import android.content.Context;
7 | import android.content.pm.PackageManager;
8 | import android.content.res.TypedArray;
9 | import android.graphics.Canvas;
10 | import android.graphics.Color;
11 | import android.graphics.Matrix;
12 | import android.graphics.Paint;
13 | import android.graphics.Rect;
14 | import android.graphics.RectF;
15 | import android.graphics.drawable.Drawable;
16 | import android.os.Build;
17 | import android.os.Vibrator;
18 | import android.support.annotation.NonNull;
19 | import android.support.v4.content.ContextCompat;
20 | import android.support.v4.view.MotionEventCompat;
21 | import android.support.v7.content.res.AppCompatResources;
22 | import android.util.AttributeSet;
23 | import android.view.MotionEvent;
24 | import android.view.View;
25 |
26 |
27 | /**
28 | * This View abstracts the input of the two main controller units of a game controller.
29 | */
30 | public abstract class InputView extends View {
31 |
32 | private static final long VIBRATION_DURATION = 30;
33 | private final Matrix pointMat = new Matrix();
34 | private final Rect utilRect = new Rect();
35 | private final RectF utilRectF = new RectF();
36 | private final float[] pointCenter = new float[]{0, 0};
37 | int width;
38 | int height;
39 | private Mode mode;
40 | private Paint paint = new Paint();
41 | private int radius;
42 | private Matrix utilMat;
43 | // Vibration Setup
44 | private boolean vibratingEnabled = true;
45 | private Vibrator vibrator;
46 | // angle
47 | private float degrees = 0f;
48 | private int buttonCount;
49 | private float deadZone;
50 | private int buttonsPressed = 0;
51 | private float singleButtonAngle;
52 | private float buttonCenterDistance;
53 | private InputEventListener listener;
54 | private boolean drawPieces = false;
55 | private boolean drawDeadZone = false;
56 |
57 | public InputView(Context context) {
58 | super(context);
59 | }
60 |
61 | public InputView(Context context, AttributeSet attrs) {
62 | super(context, attrs);
63 | }
64 |
65 | public InputView(Context context, AttributeSet attrs, int defStyleAttr) {
66 | super(context, attrs, defStyleAttr);
67 | }
68 |
69 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
70 | public InputView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
71 | super(context, attrs, defStyleAttr, defStyleRes);
72 | }
73 |
74 | /**
75 | * @param inputEventListener which is called, when buttons are pressed or released
76 | */
77 | public void setOnButtonListener(InputEventListener inputEventListener) {
78 | listener = inputEventListener;
79 | }
80 |
81 | protected void init(Context context, AttributeSet attrs, int defStyle) {
82 | // set the number of buttons that should appear
83 | buttonCount = getButtonCount();
84 | singleButtonAngle = 360f / buttonCount;
85 |
86 | TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.InputView, 0, defStyle);
87 | if (!isInEditMode()) {
88 | // setup the vibrator only when not in edit mode
89 | vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
90 | }
91 | // read the attributes from xml
92 | int background = a.getResourceId(R.styleable.InputView_inputBackground, R.drawable.action_background);
93 | try {
94 | // this is an additional spin parameter,where you can rotate the whole view
95 | degrees = a.getFloat(R.styleable.InputView_rotateButtons, 0);
96 |
97 | mode = Mode.values()[a.getInteger(R.styleable.InputView_mode, 0)];
98 | // enable/disable vibrating
99 | vibratingEnabled = a.getBoolean(R.styleable.InputView_vibrate, false);
100 | // set the size of the dead zone of the buttons
101 | deadZone = a.getFloat(R.styleable.InputView_deadZone, 0);
102 | // this is the radius of where the bitmaps should appear (from center in percent)
103 | buttonCenterDistance = a.getFloat(R.styleable.InputView_buttonCenterDistance, 0f);
104 | drawDeadZone = a.getBoolean(R.styleable.InputView_debug_drawDeadZone, false);
105 | drawPieces = a.getBoolean(R.styleable.InputView_debug_drawPieces, false);
106 | } finally {
107 | a.recycle();
108 | }
109 |
110 | Drawable backgroundDrawable = AppCompatResources.getDrawable(getContext(), background);
111 | if (backgroundDrawable == null)
112 | throw new IllegalStateException("Could not load Background Drawable!");
113 | height = backgroundDrawable.getIntrinsicHeight();
114 | width = backgroundDrawable.getIntrinsicWidth();
115 |
116 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
117 | setBackground(backgroundDrawable);
118 | else
119 | setBackgroundDrawable(backgroundDrawable);
120 |
121 | paint = new Paint(Paint.ANTI_ALIAS_FLAG);
122 | paint.setColor(Color.WHITE);
123 | }
124 |
125 | @Override
126 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
127 | int widthMode = MeasureSpec.getMode(widthMeasureSpec);
128 | int widthSize = MeasureSpec.getSize(widthMeasureSpec);
129 | int heightMode = MeasureSpec.getMode(heightMeasureSpec);
130 | int heightSize = MeasureSpec.getSize(heightMeasureSpec);
131 | //Measure Width
132 | if (widthMode == MeasureSpec.EXACTLY) {
133 | //Must be this size
134 | width = widthSize;
135 | } else if (widthMode == MeasureSpec.AT_MOST) {
136 | //Can't be bigger than...
137 | width = Math.min(width, widthSize);
138 | }
139 |
140 | //Measure Height
141 | if (heightMode == MeasureSpec.EXACTLY) {
142 | //Must be this size
143 | height = heightSize;
144 | } else if (heightMode == MeasureSpec.AT_MOST) {
145 | //Can't be bigger than...
146 | height = Math.min(height, heightSize);
147 | }
148 | if (height > width) {
149 | radius = width;
150 | } else {
151 | radius = height;
152 | }
153 | setMeasuredDimension(radius, radius);
154 | // radius is just half of the view side
155 | radius /= 2;
156 | utilMat = null;
157 | }
158 |
159 | @Override
160 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
161 | super.onLayout(changed, left, top, right, bottom);
162 | // reset the centerpoint to 0,0
163 | pointCenter[0] = pointCenter[1] = 0;
164 | // when there is no util matrix
165 | if (null == utilMat) {
166 | // reset the pointmatrix, cause the sized could've changed
167 | pointMat.reset();
168 | // setup matrix for rotating the points
169 | pointMat.setRotate(degrees);
170 | // create a util matrix
171 | utilMat = new Matrix();
172 | // translate smth to the middle of the screen
173 | utilMat.postTranslate(radius, radius);
174 | // apply this transformation onto the centerpoint
175 | utilMat.mapPoints(pointCenter);
176 | // get the actual rectangle of the view
177 | getDrawingRect(utilRect);
178 | // store it as RectF
179 | utilRectF.set(utilRect);
180 | }
181 |
182 | }
183 |
184 | @Override
185 | protected void onDraw(Canvas canvas) {
186 | super.onDraw(canvas);
187 | float tmp = radius * buttonCenterDistance;
188 | int drawButtons = forceDrawButtons(buttonsPressed);
189 | for (int i = 0; i < buttonCount; i++) {
190 | float cAngle = (singleButtonAngle * i);
191 | Drawable drawable;
192 | if (((0x1 << i) & drawButtons) > 0) {
193 | if (drawPieces) {
194 | paint.setColor(Color.GRAY);
195 | canvas.drawArc(utilRectF, cAngle - degrees, singleButtonAngle, true, paint);
196 | }
197 | drawable = getStateDrawable(i, ButtonState.PRESSED);
198 | } else {
199 | drawable = getStateDrawable(i, ButtonState.NORMAL);
200 | }
201 | if (null != drawable) {
202 | int height = drawable.getIntrinsicHeight();
203 | int width = drawable.getIntrinsicWidth();
204 | int left = (int) ((tmp * Math.cos(Math.toRadians(cAngle - degrees + singleButtonAngle / 2f))) + radius) - width / 2;
205 | int top = (int) ((tmp * Math.sin(Math.toRadians(cAngle - degrees + singleButtonAngle / 2f))) + radius) - height / 2;
206 | drawable.setBounds(left, top, left + width, top + height);
207 | drawable.draw(canvas);
208 | }
209 | }
210 | // Deadpart
211 | if (drawDeadZone) {
212 | paint.setColor(Color.DKGRAY);
213 | canvas.drawCircle(pointCenter[0], pointCenter[1], deadZone * radius, paint);
214 | }
215 | }
216 |
217 | @Override
218 | public boolean onTouchEvent(@NonNull MotionEvent event) {
219 | int action = MotionEventCompat.getActionMasked(event);
220 | float xPos = event.getX();
221 | float yPos = event.getY();
222 | switch (action) {
223 | case MotionEvent.ACTION_DOWN:
224 | case MotionEvent.ACTION_POINTER_DOWN:
225 | case MotionEvent.ACTION_MOVE:
226 | update(xPos - radius, yPos - radius);
227 | return true;
228 | case MotionEvent.ACTION_UP:
229 | buttonsPressed = 0;
230 | if (null != listener) {
231 | listener.onInputEvent(this, buttonsPressed);
232 | }
233 | invalidate();
234 | }
235 |
236 | return super.onTouchEvent(event);
237 | }
238 |
239 | private void update(float x, float y) {
240 | float[] point = new float[]{x, y};
241 | float tmp = radius * deadZone;
242 | // if touch is outside of deadzone
243 | if ((x * x + y * y) > tmp * tmp) {
244 | pointMat.mapPoints(point);
245 | x = point[0];
246 | y = point[1];
247 | float angle = (float) ((Math.atan2(y, x) * 180 / Math.PI) + 360f) % 360f;
248 | int field = (int) (angle / singleButtonAngle);
249 | int current = (0x1 << field);
250 |
251 | if ((buttonsPressed & current) == 0) {
252 | vibrate();
253 | if (Mode.MULTI.equals(mode)) {
254 | buttonsPressed |= current;
255 | } else {
256 | buttonsPressed = current;
257 | }
258 | if (null != listener) {
259 | listener.onInputEvent(this, buttonsPressed);
260 | }
261 | }
262 | }
263 | postInvalidate();
264 | }
265 |
266 | /**
267 | * if this method is called, the device is vibrating, if this feature is enabled
268 | * and the permissions are set
269 | */
270 | @SuppressLint("MissingPermission")
271 | protected void vibrate() {
272 | if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.VIBRATE)
273 | == PackageManager.PERMISSION_GRANTED && vibratingEnabled) {
274 | vibrator.vibrate(VIBRATION_DURATION);
275 | }
276 | }
277 |
278 | /**
279 | * This can be used to force some buttons to be drawn
280 | * i.e. the default DirectionView uses this method to
281 | * draw the pressed buttons up and left instead of an own
282 | * drawable for up-left
283 | *
284 | * @param buttonPressed Buttons which the user is pressing
285 | * @return Buttons the view is supposed to draw
286 | */
287 | protected int forceDrawButtons(int buttonPressed) {
288 | return buttonPressed;
289 | }
290 |
291 | /**
292 | * This method has to return a drawable for a button or null
293 | *
294 | * @param buttonIndex Index of the button, which needs to be drawn
295 | * @param state State of the button ({@link ButtonState})
296 | * @return a Drawable to draw this button
297 | */
298 | protected abstract Drawable getStateDrawable(int buttonIndex, ButtonState state);
299 |
300 | /**
301 | * @return The amount of Buttons this View represents
302 | */
303 | protected abstract int getButtonCount();
304 |
305 | /**
306 | * Button States the buttons could be in
307 | */
308 | public enum ButtonState {
309 | NORMAL,
310 | PRESSED
311 | }
312 |
313 | /**
314 | * Modes this view can be used in.
315 | * single means, that only a single button can be pressed
316 | * at the same time
317 | */
318 | protected enum Mode {
319 | SINGLE,
320 | MULTI
321 | }
322 |
323 | /**
324 | * The callback for any events on the buttons
325 | */
326 | public interface InputEventListener {
327 | /**
328 | * this method is called, when some button is pressed or released
329 | *
330 | * @param view on which the user is pressing the button
331 | * @param buttons Bit-Encoded buttons
332 | */
333 | void onInputEvent(View view, int buttons);
334 | }
335 | }
336 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/action_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/action_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/action_usual.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/direction_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/direction_down_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/direction_down_usual.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/direction_left_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/direction_left_usual.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/direction_right_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/direction_right_usual.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/direction_up_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/drawable/direction_up_usual.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFF
4 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/values/default_styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
41 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/values/dimen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 150dp
4 | 50dp
5 |
6 | 150dp
7 | 50dp
8 |
9 | 2
10 | 100
11 | 30
12 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/values/input_attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/gamecontroller/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | M50,50 m-15,-15 a 20,20 0 1,1 30,0 a 20,20 0 1,1 0,30 a 20,20 0 1,1 -30,0 a 20,20 0 1,1 0,-30z
3 | M1,15 a 14,14 0 1,1 28,0 a 14,14 0 1,1 -28,0z
4 | M0,15 a 15,15 0 1,1 30,0 a 15,15 0 1,1 -30,0z
5 |
6 | M1,29 l28,0 l0,-28 l42,0 l0,28 l28,0 l0,42 l-28,0 l0,28 l-42,0 l0,-28 l-28,0 l0,-42z
7 | M15,29 m-2,-2 l-8,-8 l0,-14 a17,17 0 0,1 20,0 l0,14 l-8,8 a3,3 0 0,1 -4,0z
8 | M15,1 m2,2 l8,8 l0,14 a17,17 0 0,1 -20,0 l0,-14 l8,-8 a3,3 0 0,1 4,0z
9 | M1,15 m2,-2 l8,-8 l14,0 a17,17 0 0,1 0,20 l-14,0 l-8,-8 a3,3 0 0,1 0,-4z
10 | M29,15 m-2,-2 l-8,-8 l-14,0 a17,17 0 0,0 0,20 l14,0 l8,-8 a3,3 0 0,0 0,-4z
11 |
12 |
13 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | supportLibraryVersion=27.0.2
2 |
3 | GROUP=com.andretietz.android
4 | VERSION_NAME=1.1.1
5 | POM_DESCRIPTION=This is an Android Library that supports Views to emulate a simple gamecontroller on android devices
6 | POM_URL=https://github.com/andretietz/controller-lib/
7 | POM_SCM_URL=https://github.com/andretietz/controller-lib/
8 | POM_SCM_CONNECTION=scm:git:git://github.com/andretietz/controller-lib.git
9 | POM_SCM_DEV_CONNECTION=scm:git:git://github.com/andretietz/controller-lib.git
10 |
--------------------------------------------------------------------------------
/gradle/publish.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Chris Banes
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'maven'
18 | apply plugin: 'signing'
19 |
20 | group = GROUP
21 | version = VERSION_NAME
22 |
23 | def getRepositoryUsername() {
24 | return project.hasProperty('bintrayUser') ? project.bintrayUser : System.getenv("BINTRAY_USER") ?: ""
25 | }
26 |
27 | def getRepositoryPassword() {
28 | return project.hasProperty('bintrayKey') ? project.bintrayKey : System.getenv("BINTRAY_PASSWORD") ?: ""
29 | }
30 |
31 | afterEvaluate { project ->
32 | uploadArchives {
33 | repositories {
34 | mavenDeployer {
35 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
36 |
37 | pom.groupId = GROUP
38 | pom.artifactId = POM_ARTIFACT_ID
39 | pom.version = VERSION_NAME
40 |
41 | repository(url: "https://api.bintray.com/maven/unicate/java/gamecontroller/;publish=1") {
42 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
43 | }
44 | // snapshotRepository(url: "file://" + System.getProperty("user.home") + "/.m2/repository/") {
45 | snapshotRepository(url: "https://oss.jfrog.org/artifactory/oss-snapshot-local/") {
46 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
47 | }
48 |
49 | pom.project {
50 | name POM_NAME
51 | packaging POM_PACKAGING
52 | description POM_DESCRIPTION
53 | url POM_URL
54 |
55 | scm {
56 | url POM_SCM_URL
57 | connection POM_SCM_CONNECTION
58 | developerConnection POM_SCM_DEV_CONNECTION
59 | }
60 | }
61 | }
62 | }
63 | }
64 |
65 | signing {
66 | required { gradle.taskGraph.hasTask("uploadArchives") }
67 | sign configurations.archives
68 | }
69 |
70 | if (plugins.hasPlugin('com.android.application') || plugins.hasPlugin('com.android.library')) {
71 | task androidJavadocs(type: Javadoc) {
72 | if (!project.plugins.hasPlugin('kotlin')) {
73 | if (!project.plugins.hasPlugin('kotlin-android')) {
74 | source = android.sourceSets.main.java.srcDirs
75 | }
76 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
77 | }
78 | exclude '**/internal/*'
79 | }
80 |
81 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
82 | classifier = 'javadoc'
83 | from androidJavadocs.destinationDir
84 | }
85 |
86 | task androidSourcesJar(type: Jar) {
87 | classifier = 'sources'
88 | from android.sourceSets.main.java.sourceFiles
89 | }
90 |
91 | artifacts {
92 | archives androidSourcesJar
93 | archives androidJavadocsJar
94 | }
95 | } else {
96 | task sourcesJar(type: Jar, dependsOn: classes) {
97 | classifier = 'sources'
98 | from sourceSets.main.allSource
99 | }
100 |
101 | task javadocsJar(type: Jar, dependsOn: javadoc) {
102 | classifier = 'javadoc'
103 | from javadoc.destinationDir
104 | }
105 |
106 | artifacts {
107 | archives sourcesJar
108 | archives javadocsJar
109 | }
110 | }
111 |
112 | if (JavaVersion.current().isJava8Compatible()) {
113 | allprojects {
114 | tasks.withType(Javadoc) {
115 | options.addStringOption('Xdoclint:none', '-quiet')
116 | }
117 | }
118 | }
119 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andretietz/controller-lib/f9cc1ace430322a26a4ff01e104e6bec6dc41f5a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jan 03 03:55:43 PST 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 |
6 | defaultConfig {
7 | applicationId "com.andretietz.controllerlib.demo"
8 | minSdkVersion 14
9 | targetSdkVersion 27
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | api "com.android.support:appcompat-v7:$supportLibraryVersion"
23 | implementation project(':gamecontroller')
24 | }
25 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\dev\tools\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/andretietz/controllerlib/demo/ControllerActivity.java:
--------------------------------------------------------------------------------
1 | package com.andretietz.controllerlib.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.widget.TextView;
8 |
9 | import com.andretietz.android.controller.ActionView;
10 | import com.andretietz.android.controller.DirectionView;
11 | import com.andretietz.android.controller.InputView;
12 |
13 | /**
14 | * a simple activity to show a demo of the ControllerView
15 | */
16 | public class ControllerActivity extends AppCompatActivity implements InputView.InputEventListener {
17 |
18 | private TextView textAction;
19 | private TextView textDirection;
20 |
21 | @Override protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_controller);
24 | textAction = findViewById(R.id.textAction);
25 | textDirection = findViewById(R.id.textDirection);
26 | DirectionView directionView = findViewById(R.id.viewDirection);
27 | ActionView actionView = findViewById(R.id.viewAction);
28 | actionView.setOnButtonListener(this);
29 | directionView.setOnButtonListener(this);
30 |
31 | }
32 |
33 | @Override public void onInputEvent(View view, int buttons) {
34 | switch (view.getId()) {
35 | case R.id.viewAction:
36 | Log.e("ACTION", "buttons: " + buttons);
37 | textAction.setText(String.format("Action: %s", actionButtonsToString(buttons)));
38 | break;
39 | case R.id.viewDirection:
40 | Log.e("DIRECTION", "buttons: " + buttons);
41 | textDirection.setText(String.format("Direction: %s", directionButtonsToString(buttons)));
42 | break;
43 | }
44 | }
45 |
46 | /**
47 | *
Action buttons can be multiple presses at the same time. Therefore they are
48 | * binary coded. The last four bits of the parameter are used to do so.
49 | * 0b0001 is Button 1
50 | * 0b0010 is Button 2
51 | * 0b0100 is Button 3
52 | * 0b1000 is Button 4
53 | * On that way you can receive multiple touches in one integer
54 | * 0b0101 or 0x05 i.e. would mean that button 1 and 3 is pressed
55 | *
56 | * @param buttons Bitcoded button touches
57 | * @return simple string to see which buttons are pressed
58 | */
59 | private String actionButtonsToString(int buttons) {
60 | StringBuilder sb = new StringBuilder();
61 | // foreach button (there are 4 action buttons)
62 | for(int i=0;i<4;i++) {
63 | // if the bit on position i is set
64 | if(((0x01 << i)&buttons)>0) {
65 | // add the number of the button to the string
66 | sb.append((i+1)).append(',');
67 | }
68 | }
69 | return sb.toString();
70 | }
71 |
72 | /**
73 | * Works almost the same as the ActionView but only one button can be active
74 | * @param buttons
75 | * @return
76 | */
77 | private String directionButtonsToString(int buttons) {
78 | String direction = "NONE";
79 | switch (buttons&0xff) {
80 | case DirectionView.DIRECTION_DOWN:
81 | direction = "Down";
82 | break;
83 | case DirectionView.DIRECTION_LEFT:
84 | direction = "Left";
85 | break;
86 | case DirectionView.DIRECTION_RIGHT:
87 | direction = "Right";
88 | break;
89 | case DirectionView.DIRECTION_UP:
90 | direction = "Up";
91 | break;
92 | case DirectionView.DIRECTION_DOWN_LEFT:
93 | direction = "Down Left";
94 | break;
95 | case DirectionView.DIRECTION_UP_LEFT:
96 | direction = "Up Left";
97 | break;
98 | case DirectionView.DIRECTION_DOWN_RIGHT:
99 | direction = "Down Right";
100 | break;
101 | case DirectionView.DIRECTION_UP_RIGHT:
102 | direction = "Up Right";
103 | break;
104 |
105 | }
106 | return direction;
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_controller.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
16 |
17 |
25 |
26 |
33 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andretietz/controller-lib/f9cc1ace430322a26a4ff01e104e6bec6dc41f5a/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andretietz/controller-lib/f9cc1ace430322a26a4ff01e104e6bec6dc41f5a/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andretietz/controller-lib/f9cc1ace430322a26a4ff01e104e6bec6dc41f5a/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andretietz/controller-lib/f9cc1ace430322a26a4ff01e104e6bec6dc41f5a/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ControllerLib
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':gamecontroller'
2 |
--------------------------------------------------------------------------------