├── consumer-rules.pro
├── README.md
├── src
└── main
│ ├── AndroidManifest.xml
│ ├── res
│ ├── values
│ │ ├── style.xml
│ │ ├── colors.xml
│ │ ├── styleable.xml
│ │ └── strings.xml
│ ├── drawable
│ │ ├── dpad.xml
│ │ ├── hcircle_top.xml
│ │ ├── hcircle_bottom.xml
│ │ ├── arrow_down.xml
│ │ ├── arrow_up.xml
│ │ ├── rotate.xml
│ │ ├── refresh.xml
│ │ ├── keyboard_button.xml
│ │ ├── close.xml
│ │ ├── fastforward.xml
│ │ ├── sound_off.xml
│ │ ├── action_back_square.xml
│ │ ├── sound_on.xml
│ │ ├── action_back_circle.xml
│ │ ├── settings.xml
│ │ ├── flare.xml
│ │ ├── dpad_front.xml
│ │ ├── dpad_back.xml
│ │ └── keyboard.xml
│ ├── anim
│ │ ├── button_touch_down.xml
│ │ ├── button_touch_up.xml
│ │ └── button_touch.xml
│ ├── layout
│ │ ├── spinner_item.xml
│ │ ├── spinner_item_keycode.xml
│ │ ├── settings_layout.xml
│ │ └── gamepad_layout.xml
│ ├── values-zh
│ │ └── strings.xml
│ ├── values-vi
│ │ └── strings.xml
│ ├── values-tr
│ │ └── strings.xml
│ ├── values-ru
│ │ └── strings.xml
│ └── values-es
│ │ └── strings.xml
│ └── java
│ └── cyou
│ └── joiplay
│ └── joipad
│ ├── animation
│ └── ButtonAnimations.java
│ ├── drawable
│ └── TextDrawable.java
│ ├── util
│ ├── DirectionUtils.java
│ ├── KeyboardUtils.java
│ └── ViewUtils.java
│ ├── view
│ ├── KeyCodeSpinner.java
│ ├── GamePadDPad.java
│ └── GamePadButton.java
│ ├── dialog
│ └── SettingsDialog.java
│ └── JoiPad.java
├── proguard-rules.pro
├── LICENSE
└── .gitignore
/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # joipad
2 | Virtual gamepad for JoiPlay plugins
3 |
--------------------------------------------------------------------------------
/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/main/res/values/style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/src/main/res/drawable/dpad.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/main/res/anim/button_touch_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/src/main/res/anim/button_touch_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/src/main/res/layout/spinner_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/main/res/layout/spinner_item_keycode.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/main/res/drawable/hcircle_top.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
11 |
--------------------------------------------------------------------------------
/src/main/res/drawable/hcircle_bottom.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
11 |
--------------------------------------------------------------------------------
/src/main/res/anim/button_touch.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
15 |
--------------------------------------------------------------------------------
/src/main/res/drawable/arrow_down.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/res/drawable/arrow_up.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/res/drawable/rotate.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #333
4 | #2a2a2a
5 | #444
6 | #ccc
7 | #fff
8 | #222
9 | #80303030
10 | #aa303030
11 | #70348564
12 |
13 |
--------------------------------------------------------------------------------
/src/main/res/drawable/refresh.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/src/main/res/drawable/keyboard_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/res/values/styleable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/res/drawable/close.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/src/main/res/drawable/fastforward.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/src/main/res/drawable/sound_off.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/src/main/java/cyou/joiplay/joipad/animation/ButtonAnimations.java:
--------------------------------------------------------------------------------
1 | package cyou.joiplay.joipad.animation;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.animation.AnimationUtils;
6 |
7 | import cyou.joiplay.joipad.R;
8 |
9 | public class ButtonAnimations {
10 | static public void animateTouch(Context context, View view, Boolean isTouched){
11 | if (isTouched) {
12 | view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.button_touch_down));
13 | } else {
14 | view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.button_touch_up));
15 | }
16 | }
17 |
18 | static public void animateTouchOnce(Context context, View view){
19 | view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.button_touch));
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/res/drawable/action_back_square.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
17 |
18 |
--------------------------------------------------------------------------------
/src/main/res/drawable/sound_on.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 JoiPlay
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/main/res/drawable/action_back_circle.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
17 |
18 |
--------------------------------------------------------------------------------
/src/main/res/values-zh/strings.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 |
--------------------------------------------------------------------------------
/src/main/res/drawable/settings.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/src/main/res/values-vi/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hủy bỏ
4 | Đóng
5 | Bạn có muốn đóng trò chơi không?
6 | Lỗi
7 | Không
8 | Đồng ý
9 | Có
10 | Xin lỗi, không thể lưu cấu hình gamepad.
11 | Độ mờ của nút
12 | Kích thước nút
13 | Nút trái
14 | Nút phải
15 | Nút đầu tiên
16 | Nút thứ hai
17 | Nút thứ ba
18 | Nút thứ tư
19 | Nút thứ năm
20 | Nút thứ sáu
21 | Cứu
22 | Nút trái nhỏ
23 | Nút mini phải
24 | Chủ yếu
25 | Thay thế
26 |
27 |
--------------------------------------------------------------------------------
/src/main/res/drawable/flare.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
27 |
34 |
35 |
--------------------------------------------------------------------------------
/src/main/res/values-tr/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | İptal
4 | Kapat
5 | Oyunu kapatmak istiyor musunuz?
6 | Hata
7 | Hayır
8 | Tamam
9 | Evet
10 | Maalesef gamepad yapılandırması kaydedilemedi.
11 | Buton Opaklığı
12 | Buton Boyutu
13 | Sol Buton
14 | Sağ Buton
15 | Birinci Buton
16 | İkinci Buton
17 | Üçüncü Buton
18 | Dördüncü Buton
19 | Beşinci Buton
20 | Altıncı Buton
21 | Kaydet
22 | Sol Mini Buton
23 | Sağ Mini Buton
24 | Ana
25 | Alternatif
26 |
27 |
--------------------------------------------------------------------------------
/src/main/res/values-ru/strings.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 |
--------------------------------------------------------------------------------
/src/main/res/values-es/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cancelar
4 | Cerrar
5 | ¿Quieres cerrar el juego?
6 | Error
7 | No
8 | Aceptar
9 | Sí
10 | Lo sentimos, no se pudo guardar la configuración del gamepad.
11 | Opacidad del botón
12 | Tamaño del botón
13 | Botón izquierdo
14 | Botón derecho
15 | Primer botón
16 | Segundo botón
17 | Tercer botón
18 | Cuarto botón
19 | Quinto botón
20 | Sexto botón
21 | Guardar
22 | Mini botón izquierdo
23 | Mini botón derecho
24 | Principal
25 | Alternativa
26 |
27 |
--------------------------------------------------------------------------------
/src/main/res/drawable/dpad_front.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
18 |
19 |
--------------------------------------------------------------------------------
/src/main/res/drawable/dpad_back.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
17 |
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.aar
4 | *.ap_
5 | *.aab
6 |
7 | # Files for the ART/Dalvik VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 | out/
17 | # Uncomment the following line in case you need and you don't have the release build type files in your app
18 | # release/
19 |
20 | # Gradle files
21 | .gradle/
22 | build/
23 |
24 | # Local configuration file (sdk path, etc)
25 | local.properties
26 |
27 | # Proguard folder generated by Eclipse
28 | proguard/
29 |
30 | # Log Files
31 | *.log
32 |
33 | # Android Studio Navigation editor temp files
34 | .navigation/
35 |
36 | # Android Studio captures folder
37 | captures/
38 |
39 | # IntelliJ
40 | *.iml
41 | .idea/workspace.xml
42 | .idea/tasks.xml
43 | .idea/gradle.xml
44 | .idea/assetWizardSettings.xml
45 | .idea/dictionaries
46 | .idea/libraries
47 | # Android Studio 3 in .gitignore file.
48 | .idea/caches
49 | .idea/modules.xml
50 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you
51 | .idea/navEditor.xml
52 |
53 | # Keystore files
54 | # Uncomment the following lines if you do not want to check your keystore files in.
55 | #*.jks
56 | #*.keystore
57 |
58 | # External native build folder generated in Android Studio 2.2 and later
59 | .externalNativeBuild
60 | .cxx/
61 |
62 | # Google Services (e.g. APIs or Firebase)
63 | # google-services.json
64 |
65 | # Freeline
66 | freeline.py
67 | freeline/
68 | freeline_project_description.json
69 |
70 | # fastlane
71 | fastlane/report.xml
72 | fastlane/Preview.html
73 | fastlane/screenshots
74 | fastlane/test_output
75 | fastlane/readme.md
76 |
77 | # Version control
78 | vcs.xml
79 |
80 | # lint
81 | lint/intermediates/
82 | lint/generated/
83 | lint/outputs/
84 | lint/tmp/
85 | # lint/reports/
86 |
--------------------------------------------------------------------------------
/src/main/java/cyou/joiplay/joipad/drawable/TextDrawable.java:
--------------------------------------------------------------------------------
1 | package cyou.joiplay.joipad.drawable;
2 |
3 | import android.content.res.Resources;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.ColorFilter;
7 | import android.graphics.Paint;
8 | import android.graphics.drawable.Drawable;
9 | import android.util.TypedValue;
10 |
11 | public class TextDrawable extends Drawable {
12 | private final int mColor = Color.WHITE;
13 | private final int mTextSize = 15;
14 | private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
15 | private int mIntrinsicWidth;
16 | private int mIntrinsicHeight;
17 | private Resources mResources;
18 | private CharSequence mText;
19 |
20 | public TextDrawable(Resources resources, CharSequence text){
21 | this.mResources = resources;
22 | this.mText = text;
23 | init();
24 | }
25 |
26 | @Override
27 | public void draw(Canvas canvas) {
28 | canvas.drawText(this.mText, 0, mText.length(), getBounds().centerX(), getBounds().centerY() - mPaint.ascent() / 2f, mPaint);
29 | }
30 |
31 | @Override
32 | public void setAlpha(int i) {
33 | mPaint.setAlpha(i);
34 | }
35 |
36 | @Override
37 | public void setColorFilter(ColorFilter colorFilter) {
38 | mPaint.setColorFilter(colorFilter);
39 | }
40 |
41 | @Override
42 | public int getOpacity() {
43 | return mPaint.getAlpha();
44 | }
45 |
46 | @Override
47 | public int getIntrinsicWidth() {
48 | return mIntrinsicWidth;
49 | }
50 |
51 | @Override
52 | public int getIntrinsicHeight() {
53 | return mIntrinsicHeight;
54 | }
55 |
56 | private void init(){
57 | mPaint.setColor(mColor);
58 | mPaint.setTextAlign(Paint.Align.CENTER);
59 | float textSize = TypedValue.applyDimension(
60 | TypedValue.COMPLEX_UNIT_SP,
61 | mTextSize, mResources.getDisplayMetrics()
62 | );
63 | mPaint.setTextSize(textSize);
64 | mIntrinsicWidth = (int) Math.round(mPaint.measureText(mText, 0, mText.length()) + .5);
65 | mIntrinsicHeight = mPaint.getFontMetricsInt(null);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/res/drawable/keyboard.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
27 |
34 |
41 |
48 |
55 |
62 |
63 |
--------------------------------------------------------------------------------
/src/main/java/cyou/joiplay/joipad/util/DirectionUtils.java:
--------------------------------------------------------------------------------
1 | package cyou.joiplay.joipad.util;
2 |
3 | public class DirectionUtils {
4 | public enum Direction{
5 | UP,
6 | UP_RIGHT,
7 | RIGHT,
8 | DOWN_RIGHT,
9 | DOWN,
10 | DOWN_LEFT,
11 | LEFT,
12 | UP_LEFT,
13 | UNKNOWN
14 | }
15 |
16 | public static Direction getDir(float x, float y, boolean isDiagonal){
17 | return getAngle(0,x,0,y,isDiagonal);
18 | }
19 |
20 | public static Direction getDir(double angle, boolean isDiagonal) {
21 | if (isDiagonal){
22 | return get8dir(angle);
23 | } else {
24 | return get4dir(angle);
25 | }
26 | }
27 |
28 | private static Direction get4dir(double angle) {
29 | if ((angle > 45) && (angle < 136)){
30 | return Direction.UP;
31 | } else if ((angle > 135) && (angle < 226)){
32 | return Direction.RIGHT;
33 | } else if ((angle > 225) && (angle < 316)){
34 | return Direction.DOWN;
35 | } else if (((angle >= 0) && (angle < 46)) || ((angle > 315) && (angle <361))){
36 | return Direction.LEFT;
37 | } else {
38 | return Direction.UNKNOWN;
39 | }
40 | }
41 |
42 | private static Direction get8dir(double angle) {
43 | if ((angle >= 67.5) && (angle < 113.5)){
44 | return Direction.UP;
45 | } else if ((angle >= 113.5) && (angle < 158.5)){
46 | return Direction.UP_RIGHT;
47 | } else if ((angle >= 158.5) && (angle < 203.5)){
48 | return Direction.RIGHT;
49 | } else if ((angle >= 203.5) && (angle < 248.5)){
50 | return Direction.DOWN_RIGHT;
51 | } else if ((angle >= 248.5) && (angle < 293.5)){
52 | return Direction.DOWN;
53 | } else if ((angle >= 293.5) && (angle < 338.5)){
54 | return Direction.DOWN_LEFT;
55 | } else if (((angle >= 0) && (angle < 23.5)) || ((angle >= 338.5) && (angle <361))){
56 | return Direction.LEFT;
57 | } else if ((angle >= 23.5) && (angle < 67.5)){
58 | return Direction.UP_LEFT;
59 | } else {
60 | return Direction.UNKNOWN;
61 | }
62 | }
63 |
64 | public static Direction getAngle(float initX, float posX, float initY, float posY, boolean isDiagonal){
65 | double angle = 0;
66 | try{
67 | angle = Math.toDegrees(Math.atan2((initY - posY), (initX - posX)));
68 | } catch (Exception e){}
69 |
70 | if (angle < 0)
71 | angle += 360;
72 |
73 | return DirectionUtils.getDir(angle, isDiagonal);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/cyou/joiplay/joipad/view/KeyCodeSpinner.java:
--------------------------------------------------------------------------------
1 | package cyou.joiplay.joipad.view;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.content.res.Resources;
6 | import android.util.AttributeSet;
7 | import android.view.KeyEvent;
8 | import android.view.View;
9 | import android.widget.AdapterView;
10 | import android.widget.ArrayAdapter;
11 | import android.widget.Spinner;
12 |
13 | import cyou.joiplay.joipad.R;
14 |
15 | public class KeyCodeSpinner extends Spinner {
16 | private ArrayAdapter adapter;
17 | private int keyCode = 0;
18 |
19 | public KeyCodeSpinner(Context context) {
20 | super(context);
21 | init(context);
22 | }
23 |
24 | public KeyCodeSpinner(Context context, int mode) {
25 | super(context, mode);
26 | init(context);
27 | }
28 |
29 | public KeyCodeSpinner(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | init(context);
32 | }
33 |
34 | public KeyCodeSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
35 | super(context, attrs, defStyleAttr);
36 | init(context);
37 | }
38 |
39 | public KeyCodeSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode) {
40 | super(context, attrs, defStyleAttr, mode);
41 | init(context);
42 | }
43 |
44 | public KeyCodeSpinner(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes, int mode) {
45 | super(context, attrs, defStyleAttr, defStyleRes, mode);
46 | init(context);
47 | }
48 |
49 | @TargetApi(23)
50 | public KeyCodeSpinner(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes, int mode, Resources.Theme popupTheme) {
51 | super(context, attrs, defStyleAttr, defStyleRes, mode, popupTheme);
52 | init(context);
53 | }
54 |
55 | private void init(Context context){
56 | adapter = ArrayAdapter.createFromResource(context, R.array.key_array, R.layout.spinner_item_keycode);
57 | adapter.setDropDownViewResource(R.layout.spinner_item_keycode);
58 | setAdapter(adapter);
59 |
60 |
61 | setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
62 | @Override
63 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
64 | try {
65 | keyCode = getKeyCode((String) parent.getItemAtPosition(position));
66 | } catch (Exception e){/*ignore*/}
67 | }
68 |
69 | @Override
70 | public void onNothingSelected(AdapterView> parent) {}
71 | });
72 | }
73 |
74 | Integer getKeyCode(String keyString){
75 | return KeyEvent.keyCodeFromString("KEYCODE_"+keyString);
76 | }
77 |
78 | String getKeyName(Integer keyCode){
79 | return KeyEvent.keyCodeToString(keyCode).replace("KEYCODE_","");
80 | }
81 |
82 | int getPosition(String value, ArrayAdapter arrayAdapter){
83 | try {
84 | return arrayAdapter.getPosition(value);
85 | } catch (Exception e){
86 | return 0;
87 | }
88 | }
89 |
90 | public void setKey(int keyCode){
91 | this.keyCode = keyCode;
92 | setSelection(getPosition(getKeyName(keyCode), adapter));
93 | }
94 |
95 | public int getKey(){
96 | return this.keyCode;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Cancel
3 | Close
4 | Do you want to close the game?
5 | Error
6 | Sorry, could not save the gamepad configuration.
7 | No
8 | OK
9 | Yes
10 | Button Opacity
11 | Button Size
12 | Left Button
13 | Right Button
14 | Left Mini Button
15 | Right Mini Button
16 | First Button
17 | Second Button
18 | Third Button
19 | Fourth Button
20 | Fifth Button
21 | Sixth Button
22 | Save
23 | Main
24 | Alternative
25 |
26 |
27 | - 0
28 | - 1
29 | - 2
30 | - 3
31 | - 4
32 | - 4
33 | - 5
34 | - 6
35 | - 7
36 | - 8
37 | - 9
38 | - A
39 | - B
40 | - C
41 | - D
42 | - E
43 | - F
44 | - G
45 | - H
46 | - I
47 | - J
48 | - K
49 | - L
50 | - M
51 | - N
52 | - O
53 | - P
54 | - Q
55 | - R
56 | - S
57 | - T
58 | - U
59 | - V
60 | - W
61 | - X
62 | - Y
63 | - Z
64 | - ALT_LEFT
65 | - ALT_RIGHT
66 | - SHIFT_LEFT
67 | - SHIFT_RIGHT
68 | - TAB
69 | - SPACE
70 | - ENTER
71 | - ESCAPE
72 | - DEL
73 | - PAGE_UP
74 | - PAGE_DOWN
75 | - CTRL_LEFT
76 | - CTRL_RIGHT
77 | - F1
78 | - F2
79 | - F3
80 | - F4
81 | - F5
82 | - F6
83 | - F7
84 | - F8
85 | - F9
86 | - F10
87 | - F11
88 | - F12
89 |
90 |
91 | - 0
92 | - 10
93 | - 20
94 | - 30
95 | - 40
96 | - 50
97 | - 60
98 | - 70
99 | - 80
100 | - 90
101 | - 100
102 |
103 |
104 | - 60
105 | - 70
106 | - 80
107 | - 90
108 | - 100
109 | - 110
110 | - 120
111 | - 130
112 | - 140
113 | - 150
114 |
115 |
--------------------------------------------------------------------------------
/src/main/java/cyou/joiplay/joipad/util/KeyboardUtils.java:
--------------------------------------------------------------------------------
1 | package cyou.joiplay.joipad.util;
2 |
3 | import android.view.KeyEvent;
4 |
5 | import java.util.Collections;
6 | import java.util.HashMap;
7 | import java.util.LinkedHashMap;
8 | import java.util.LinkedList;
9 | import java.util.List;
10 | import java.util.Map;
11 |
12 | public class KeyboardUtils {
13 | public static List