2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-25 11:19:59 +01:00

CRLF to LF on all files

This commit is contained in:
Alibek Omarov 2015-05-22 20:59:49 +06:00
parent 58295431a0
commit 7615914e86
38 changed files with 4406 additions and 4406 deletions

14
.gitignore vendored
View File

@ -1,7 +1,7 @@
libs
obj
bin
gen
local.properties
libs
obj
bin
gen
local.properties

View File

@ -1,51 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Replace org.libsdl.app with the identifier of your game below, e.g.
com.gamemaker.game
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.celest.xash3d.hl"
android:versionCode="0"
android:versionName="0.12"
android:installLocation="preferExternal">
<!-- Create a Java class extending SDLActivity and place it in a
directory under src matching the package, e.g.
src/com/gamemaker/game/MyGame.java
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
in the XML below.
An example Java class can be found in README-android.txt
-->
<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:allowBackup="true"
android:hardwareAccelerated="true">
<activity android:name="org.libsdl.app.SDLActivity"
android:screenOrientation="landscape"
android:label="@string/app_name"
android:configChanges="orientation|screenSize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- <activity android:name=".XashActivity"
android:screenOrientation="landscape"
android:label="@string/app_name">
</activity> -->
</application>
<!-- Android 2.3.3 -->
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" />
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />
<!-- Allow writing to external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<!-- Replace org.libsdl.app with the identifier of your game below, e.g.
com.gamemaker.game
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.celest.xash3d.hl"
android:versionCode="0"
android:versionName="0.12"
android:installLocation="preferExternal">
<!-- Create a Java class extending SDLActivity and place it in a
directory under src matching the package, e.g.
src/com/gamemaker/game/MyGame.java
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
in the XML below.
An example Java class can be found in README-android.txt
-->
<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:allowBackup="true"
android:hardwareAccelerated="true">
<activity android:name="org.libsdl.app.SDLActivity"
android:screenOrientation="landscape"
android:label="@string/app_name"
android:configChanges="orientation|screenSize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- <activity android:name=".XashActivity"
android:screenOrientation="landscape"
android:label="@string/app_name">
</activity> -->
</application>
<!-- Android 2.3.3 -->
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" />
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />
<!-- Allow writing to external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

View File

@ -1,7 +1,7 @@
====
Xash3D Android project
====
Just put into jni/src/XXXX/ a symlink to a repository. For example, for HLSDK it will be jni/src/HLSDK/halflife/
Write here any issues related to Android port.
====
Xash3D Android project
====
Just put into jni/src/XXXX/ a symlink to a repository. For example, for HLSDK it will be jni/src/HLSDK/halflife/
Write here any issues related to Android port.

View File

@ -1,17 +1,17 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

View File

@ -1,4 +1,4 @@
These PNG files are copyright to Emile Belanger.
They are permitted for use in SDLxash3D Android port, full copyright is owned by Emile Belanger.
Other use not permitted without permission from Emile Belanger.
These PNG files are copyright to Emile Belanger.
They are permitted for use in SDLxash3D Android port, full copyright is owned by Emile Belanger.
Other use not permitted without permission from Emile Belanger.
emile.belanger@gmail.com

View File

@ -1,17 +1,17 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

View File

@ -1,8 +1,8 @@
#!/bin/sh
ndk-build NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=0 SUPPORT_WEBP=false V=1
ant release
#jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../myks.keystore bin/xashdroid-release-unsigned.apk xashdroid
#adb install -r -f bin/xashdroid-debug.apk
rm bin/xashdroid-release.apk
/opt/android-sdk-update-manager/build-tools/19.1.0/zipalign 4 bin/xashdroid-release-unsigned.apk bin/xashdroid-release.apk
#!/bin/sh
ndk-build NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=0 SUPPORT_WEBP=false V=1
ant release
#jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../myks.keystore bin/xashdroid-release-unsigned.apk xashdroid
#adb install -r -f bin/xashdroid-debug.apk
rm bin/xashdroid-release.apk
/opt/android-sdk-update-manager/build-tools/19.1.0/zipalign 4 bin/xashdroid-release-unsigned.apk bin/xashdroid-release.apk

184
build.xml
View File

@ -1,92 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="xashdroid" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project name="xashdroid" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -1,8 +1,8 @@
#!/bin/sh
ndk-build NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=1 SUPPORT_WEBP=false V=1 -j3 APP_CFLAGS="-gdwarf-3"
ant debug
#jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../myks.keystore bin/xashdroid-release-unsigned.apk xashdroid -storepass 529459
adb install -r -f bin/xashdroid-debug.apk
#rm bin/xashdroid-release.apk
#/opt/android-sdk-update-manager/build-tools/19.1.0/zipalign 4 bin/xashdroid-release-unsigned.apk bin/xashdroid-release.apk
#!/bin/sh
ndk-build NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=1 SUPPORT_WEBP=false V=1 -j3 APP_CFLAGS="-gdwarf-3"
ant debug
#jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../myks.keystore bin/xashdroid-release-unsigned.apk xashdroid -storepass 529459
adb install -r -f bin/xashdroid-debug.apk
#rm bin/xashdroid-release.apk
#/opt/android-sdk-update-manager/build-tools/19.1.0/zipalign 4 bin/xashdroid-release-unsigned.apk bin/xashdroid-release.apk

View File

@ -1,11 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-12
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-12

View File

@ -1 +1 @@
include $(call all-subdir-makefiles)
include $(call all-subdir-makefiles)

View File

@ -1,29 +1,29 @@
# Uncomment this if you're using STL in your project
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
APP_STL := stlport_static
APPLICATIONMK_PATH = $(call my-dir)
ifeq ($(EMILE),1)
SDL_PATH := $(APPLICATIONMK_PATH)/src/SDL-mirror
else
SDL_PATH := $(APPLICATIONMK_PATH)/src/SDL2
endif
TOUCHCONTROLS_PATH := $(APPLICATIONMK_PATH)/src/MobileTouchControls
NANOGL_PATH := $(APPLICATIONMK_PATH)/src/NanoGL/nanogl
XASH3D_PATH := $(APPLICATIONMK_PATH)/src/Xash3D/xash3d
XASHXT_PATH := $(APPLICATIONMK_PATH)/src/XashXT/XashXT
HLSDK_PATH := $(APPLICATIONMK_PATH)/src/HLSDK/halflife/
APP_ABI := armeabi-v7a x86
APP_MODULES := SDL2 xash menu client server NanoGL
# Uncomment this if you're using STL in your project
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
APP_STL := stlport_static
APPLICATIONMK_PATH = $(call my-dir)
ifeq ($(EMILE),1)
SDL_PATH := $(APPLICATIONMK_PATH)/src/SDL-mirror
else
SDL_PATH := $(APPLICATIONMK_PATH)/src/SDL2
endif
TOUCHCONTROLS_PATH := $(APPLICATIONMK_PATH)/src/MobileTouchControls
NANOGL_PATH := $(APPLICATIONMK_PATH)/src/NanoGL/nanogl
XASH3D_PATH := $(APPLICATIONMK_PATH)/src/Xash3D/xash3d
XASHXT_PATH := $(APPLICATIONMK_PATH)/src/XashXT/XashXT
HLSDK_PATH := $(APPLICATIONMK_PATH)/src/HLSDK/halflife/
APP_ABI := armeabi-v7a x86
APP_MODULES := SDL2 xash menu client server NanoGL

View File

@ -1 +1 @@
include $(call all-subdir-makefiles)
include $(call all-subdir-makefiles)

View File

@ -1 +1 @@
include $(call all-subdir-makefiles)
include $(call all-subdir-makefiles)

View File

@ -1 +1 @@
include $(call all-subdir-makefiles)
include $(call all-subdir-makefiles)

View File

@ -1 +1 @@
include $(call all-subdir-makefiles)
include $(call all-subdir-makefiles)

View File

@ -1 +1 @@
include $(call all-subdir-makefiles)
include $(call all-subdir-makefiles)

View File

@ -1,20 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#805fd1e2"/>
<stroke
android:width="2dp"
android:color="@android:color/holo_blue_light" />
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp" />
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#805fd1e2"/>
<stroke
android:width="2dp"
android:color="@android:color/holo_blue_light" />
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp" />
</shape>

View File

@ -1,42 +1,42 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/joystick" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_toRightOf="@+id/imageView"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/binding_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/tertiary_text_dark" />
</LinearLayout>
<ImageView
android:id="@+id/settings_imageview"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="@drawable/cog" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/joystick" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_toRightOf="@+id/imageView"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/binding_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/tertiary_text_dark" />
</LinearLayout>
<ImageView
android:id="@+id/settings_imageview"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="@drawable/cog" />
</RelativeLayout>

View File

@ -1,34 +1,34 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/joystick" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/imageView"
android:orientation="vertical" >
<TextView
android:id="@+id/name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<ToggleButton
android:id="@+id/hidden_switch"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/joystick" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/imageView"
android:orientation="vertical" >
<TextView
android:id="@+id/name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<ToggleButton
android:id="@+id/hidden_switch"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp" />
</RelativeLayout>

View File

@ -1,49 +1,49 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/gamepad_enable_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enable Game Pad" />
<CheckBox
android:id="@+id/gamepad_hide_touch_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hide Touch Controls" />
<Button
android:id="@+id/gamepad_help_button"
style="@android:style/Animation"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="10dp"
android:background="@drawable/help" />
<TextView
android:id="@+id/gamepad_info_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<ListView
android:id="@+id/gamepad_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="10dp" >
</ListView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/gamepad_enable_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enable Game Pad" />
<CheckBox
android:id="@+id/gamepad_hide_touch_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hide Touch Controls" />
<Button
android:id="@+id/gamepad_help_button"
style="@android:style/Animation"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="10dp"
android:background="@drawable/help" />
<TextView
android:id="@+id/gamepad_info_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<ListView
android:id="@+id/gamepad_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="10dp" >
</ListView>
</LinearLayout>

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, SDLActivity"
/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, SDLActivity"
/>
</LinearLayout>

View File

@ -1,221 +1,221 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="500dp"
android:orientation="vertical" >
<Button
android:id="@+id/add_remove_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add/remove buttons" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fwd/Back:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="@+id/fwd_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Strafe:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="@+id/strafe_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Look Up/Down:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="@+id/pitch_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Turn:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="@+id/yaw_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100" />
</TableRow>
<TableRow
android:id="@+id/tableRow5"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Transparency:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="@+id/alpha_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/mouse_turn_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="&apos;Mouse&apos; mode turning" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/invert_loop_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Invert Look" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/precision_shoot_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Precision Shoot" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/show_next_weapon_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Next/Prev Weapon" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/show_sticks_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Movement arrows" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/enable_weapon_wheel_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enable Weapon Wheel" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Double tap Move:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Spinner
android:id="@+id/move_dbl_tap_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Double tap Look:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Spinner
android:id="@+id/look_dbl_tap_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/save_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
<Button
android:id="@+id/cancel_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
</TableLayout>
</LinearLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="500dp"
android:orientation="vertical" >
<Button
android:id="@+id/add_remove_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add/remove buttons" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fwd/Back:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="@+id/fwd_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Strafe:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="@+id/strafe_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Look Up/Down:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="@+id/pitch_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Turn:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="@+id/yaw_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100" />
</TableRow>
<TableRow
android:id="@+id/tableRow5"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Transparency:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="@+id/alpha_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/mouse_turn_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="&apos;Mouse&apos; mode turning" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/invert_loop_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Invert Look" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/precision_shoot_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Precision Shoot" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/show_next_weapon_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Next/Prev Weapon" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/show_sticks_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Movement arrows" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/enable_weapon_wheel_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enable Weapon Wheel" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Double tap Move:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Spinner
android:id="@+id/move_dbl_tap_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Double tap Look:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Spinner
android:id="@+id/look_dbl_tap_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/save_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
<Button
android:id="@+id/cancel_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
</TableLayout>
</LinearLayout>
</ScrollView>

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Half-life</string>
<string-array name="double_tap_actions">
<item>None</item>
<item>Shoot</item>
<item>Jump</item>
<item>Use</item>
</string-array>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Half-life</string>
<string-array name="double_tap_actions">
<item>None</item>
<item>Shoot</item>
<item>Jump</item>
<item>Use</item>
</string-array>
</resources>

View File

@ -1,81 +1,81 @@
package com.beloko.games.hl;
import com.beloko.touchcontrols.ControlInterface;
public class NativeLib implements ControlInterface{
public static native int init(String graphics_dir,int mem,String[] args,int game,String path);
public static native int initTouchControls(String graphics_dir,int width,int height);
public static native void setScreenSize( int width, int height );
public static native boolean touchEvent( int action, int pid, float x, float y);
public static native void keypress(int down, int qkey, int unicode);
public static native void doAction(int state, int action);
public static native void analogFwd(float v);
public static native void analogSide(float v);
public static native void analogPitch(int mode,float v);
public static native void analogYaw(int mode,float v);
public static native void setTouchSettings(float alpha,float strafe,float fwd,float pitch,float yaw,int other);
public static native void quickCommand(String command);
@Override
public void initTouchControls_if(String pngPath,int width,int height) {
initTouchControls(pngPath,width,height);
}
@Override
public void quickCommand_if(String command){
quickCommand(command);
}
@Override
public boolean touchEvent_if(int action, int pid, float x, float y) {
return touchEvent( action, pid, x, y);
}
@Override
public void keyPress_if(int down, int qkey, int unicode) {
keypress(down,qkey,unicode);
}
@Override
public void doAction_if(int state, int action) {
doAction(state,action);
}
@Override
public void analogFwd_if(float v) {
analogFwd(v);
}
@Override
public void analogSide_if(float v) {
analogSide(v);
}
@Override
public void analogPitch_if(int mode,float v)
{
analogPitch(mode,v);
}
@Override
public void analogYaw_if(int mode,float v)
{
analogYaw(mode,v);
}
@Override
public void setTouchSettings_if(float alpha,float strafe, float fwd, float pitch,
float yaw, int other) {
setTouchSettings(alpha,strafe, fwd, pitch, yaw, other);
}
@Override
public int mapKey(int acode, int unicode) {
// TODO Auto-generated method stub
return 0;
}
}
package com.beloko.games.hl;
import com.beloko.touchcontrols.ControlInterface;
public class NativeLib implements ControlInterface{
public static native int init(String graphics_dir,int mem,String[] args,int game,String path);
public static native int initTouchControls(String graphics_dir,int width,int height);
public static native void setScreenSize( int width, int height );
public static native boolean touchEvent( int action, int pid, float x, float y);
public static native void keypress(int down, int qkey, int unicode);
public static native void doAction(int state, int action);
public static native void analogFwd(float v);
public static native void analogSide(float v);
public static native void analogPitch(int mode,float v);
public static native void analogYaw(int mode,float v);
public static native void setTouchSettings(float alpha,float strafe,float fwd,float pitch,float yaw,int other);
public static native void quickCommand(String command);
@Override
public void initTouchControls_if(String pngPath,int width,int height) {
initTouchControls(pngPath,width,height);
}
@Override
public void quickCommand_if(String command){
quickCommand(command);
}
@Override
public boolean touchEvent_if(int action, int pid, float x, float y) {
return touchEvent( action, pid, x, y);
}
@Override
public void keyPress_if(int down, int qkey, int unicode) {
keypress(down,qkey,unicode);
}
@Override
public void doAction_if(int state, int action) {
doAction(state,action);
}
@Override
public void analogFwd_if(float v) {
analogFwd(v);
}
@Override
public void analogSide_if(float v) {
analogSide(v);
}
@Override
public void analogPitch_if(int mode,float v)
{
analogPitch(mode,v);
}
@Override
public void analogYaw_if(int mode,float v)
{
analogYaw(mode,v);
}
@Override
public void setTouchSettings_if(float alpha,float strafe, float fwd, float pitch,
float yaw, int other) {
setTouchSettings(alpha,strafe, fwd, pitch, yaw, other);
}
@Override
public int mapKey(int acode, int unicode) {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -1,37 +1,37 @@
package com.beloko.touchcontrols;
import java.io.Serializable;
import com.beloko.touchcontrols.ControlConfig.Type;
public class ActionInput implements Serializable
{
private static final long serialVersionUID = 1L;
public String tag;
public String description;
public boolean invert;
public float scale = 1; //senstivty for analog
public int source = -1;
public Type sourceType;
public boolean sourcePositive=true; //Used when using analog as a button
public int actionCode;
public Type actionType;
public ActionInput(String t,String n,int action,Type actiontype)
{
tag = t;
description = n;
actionCode = action;
actionType = actiontype;
}
public String toString()
{
return description + ":" + sourceType.toString() + " source: " + source + " sourcePositive: " + sourcePositive;
}
}
package com.beloko.touchcontrols;
import java.io.Serializable;
import com.beloko.touchcontrols.ControlConfig.Type;
public class ActionInput implements Serializable
{
private static final long serialVersionUID = 1L;
public String tag;
public String description;
public boolean invert;
public float scale = 1; //senstivty for analog
public int source = -1;
public Type sourceType;
public boolean sourcePositive=true; //Used when using analog as a button
public int actionCode;
public Type actionType;
public ActionInput(String t,String n,int action,Type actiontype)
{
tag = t;
description = n;
actionCode = action;
actionType = actiontype;
}
public String toString()
{
return description + ":" + sourceType.toString() + " source: " + source + " sourcePositive: " + sourcePositive;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,22 @@
package com.beloko.touchcontrols;
import android.view.KeyEvent;
public interface ControlInterface {
public void initTouchControls_if(String pngPath,int width,int height);
public boolean touchEvent_if( int action, int pid, float x, float y);
public void keyPress_if(int down, int qkey, int unicode);
public void doAction_if(int state, int action);
public void analogFwd_if(float v);
public void analogSide_if(float v);
public void analogPitch_if(int mode,float v);
public void analogYaw_if(int mode,float v);
public void setTouchSettings_if(float alpha,float strafe,float fwd,float pitch,float yaw,int other);
public void quickCommand_if(String command);
public int mapKey(int acode,int unicode);
}
package com.beloko.touchcontrols;
import android.view.KeyEvent;
public interface ControlInterface {
public void initTouchControls_if(String pngPath,int width,int height);
public boolean touchEvent_if( int action, int pid, float x, float y);
public void keyPress_if(int down, int qkey, int unicode);
public void doAction_if(int state, int action);
public void analogFwd_if(float v);
public void analogSide_if(float v);
public void analogPitch_if(int mode,float v);
public void analogYaw_if(int mode,float v);
public void setTouchSettings_if(float alpha,float strafe,float fwd,float pitch,float yaw,int other);
public void quickCommand_if(String command);
public int mapKey(int acode,int unicode);
}

View File

@ -1,304 +1,304 @@
package com.beloko.touchcontrols;
import java.io.IOException;
import java.util.HashMap;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import com.bda.controller.Controller;
import com.beloko.touchcontrols.ControlConfig.Type;
import com.beloko.touchcontrols.Settings.IDGame;
public class ControlInterpreter {
String LOG = "QuakeControlInterpreter";
ControlInterface quakeIf;
ControlConfig config;
boolean gamePadEnabled;
float screenWidth, screenHeight;
HashMap<Integer, Boolean> analogButtonState = new HashMap<Integer, Boolean>(); //Saves current state of analog buttons so all sent each time
public ControlInterpreter(ControlInterface qif,IDGame game,String controlfile,boolean ctrlEn)
{
Log.d("QuakeControlInterpreter", "file = " + controlfile);
gamePadEnabled = ctrlEn;
config = new ControlConfig(controlfile,game);
try {
config.loadControls();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
for (ActionInput ai: config.actions)
{
if ((ai.sourceType == Type.ANALOG) && ((ai.actionType == Type.MENU) || (ai.actionType == Type.BUTTON)))
{
analogButtonState.put(ai.actionCode, false);
}
}
quakeIf = qif;
}
public void setScreenSize(int w,int h)
{
screenWidth = w;
screenHeight = h;
}
public boolean onTouchEvent(MotionEvent event)
{
int action = event.getAction();
int actionCode = action & MotionEvent.ACTION_MASK;
if (actionCode == MotionEvent.ACTION_MOVE)
{
for (int i = 0; i < event.getPointerCount(); i++) {
float x = event.getX(i)/screenWidth;
float y = event.getY(i)/screenHeight;
int pid = event.getPointerId(i);
quakeIf.touchEvent_if(3, pid, x, y);
}
}
else if (actionCode == MotionEvent.ACTION_DOWN)
{
float x = event.getX()/screenWidth;
float y = event.getY()/screenHeight;
quakeIf.touchEvent_if(1, 0, x, y);
}
else if (actionCode == MotionEvent.ACTION_POINTER_DOWN)
{
int index = event.getActionIndex();
if (index != -1)
{
float x = event.getX(index)/screenWidth;
float y = event.getY(index)/screenHeight;
int pid = event.getPointerId(index);
quakeIf.touchEvent_if(1, pid, x, y);
}
}
else if (actionCode == MotionEvent.ACTION_POINTER_UP)
{
int index = event.getActionIndex();
if (index != -1)
{
float x = event.getX(index)/screenWidth;
float y = event.getY(index)/screenHeight;
int pid = event.getPointerId(index);
quakeIf.touchEvent_if(2, pid, x, y);
}
}
else if (actionCode == MotionEvent.ACTION_UP)
{
float x = event.getX()/screenWidth;
float y = event.getY()/screenHeight;
int index = event.getActionIndex();
int pid = event.getPointerId(index);
quakeIf.touchEvent_if(2, pid, x, y);
}
return true;
}
public void onMogaKeyEvent(com.bda.controller.KeyEvent event,int pad_version)
{
int keycode = event.getKeyCode();
if (pad_version == Controller.ACTION_VERSION_MOGA)
{
//Log.d(LOG,"removed");
if ((keycode == com.bda.controller.KeyEvent.KEYCODE_DPAD_DOWN) ||
(keycode == com.bda.controller.KeyEvent.KEYCODE_DPAD_UP) ||
(keycode == com.bda.controller.KeyEvent.KEYCODE_DPAD_LEFT) ||
(keycode == com.bda.controller.KeyEvent.KEYCODE_DPAD_RIGHT))
return;
}
if (event.getAction() == com.bda.controller.KeyEvent.ACTION_DOWN)
onKeyDown(keycode, null);
else if (event.getAction() == com.bda.controller.KeyEvent.ACTION_UP)
onKeyUp(keycode, null);
}
public boolean onKeyDown(int keyCode, KeyEvent event)
{
boolean used = false;;
if (gamePadEnabled)
{
for (ActionInput ai: config.actions)
{
if (((ai.sourceType == Type.BUTTON)||(ai.sourceType == Type.MENU)) && (ai.source == keyCode))
{
quakeIf.doAction_if(1, ai.actionCode);
Log.d(LOG,"key down intercept");
used = true;
}
}
}
if (used)
return true;
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || //If these were mapped it would have already returned
(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))
return false;
else
{
int uc = 0;
if (event !=null)
uc = event.getUnicodeChar();
quakeIf.keyPress_if(1, quakeIf.mapKey(keyCode, uc), uc);
return true;
}
}
public boolean onKeyUp(int keyCode, KeyEvent event)
{
boolean used = false;
if (gamePadEnabled)
{
for (ActionInput ai: config.actions)
{
if (((ai.sourceType == Type.BUTTON) || (ai.sourceType == Type.MENU)) && (ai.source == keyCode))
{
quakeIf.doAction_if(0, ai.actionCode);
used = true;
}
}
}
if (used)
return true;
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || //If these were mapped it would have already returned
(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))
return false;
else
{
int uc = 0;
if (event !=null)
uc = event.getUnicodeChar();
quakeIf.keyPress_if(0, quakeIf.mapKey(keyCode, uc), uc);
return true;
}
}
float deadRegion = 0.2f;
private float analogCalibrate(float v)
{
if ((v < deadRegion) && (v > -deadRegion))
return 0;
else
{
if (v > 0)
return(v-deadRegion) / (1-deadRegion);
else
return(v+deadRegion) / (1-deadRegion);
//return v;
}
}
GenericAxisValues genericAxisValues = new GenericAxisValues();
//This is for normal Android motioon event
public boolean onGenericMotionEvent(MotionEvent event) {
genericAxisValues.setAndroidValues(event);
return onGenericMotionEvent(genericAxisValues);
}
//This is for Moga event
public boolean onGenericMotionEvent(com.bda.controller.MotionEvent event) {
genericAxisValues.setMogaValues(event);
return onGenericMotionEvent(genericAxisValues);
}
public boolean onGenericMotionEvent(GenericAxisValues event) {
if (Settings.DEBUG) Log.d(LOG,"onGenericMotionEvent" );
boolean used = false;
if (gamePadEnabled)
{
for (ActionInput ai: config.actions)
{
if ((ai.sourceType == Type.ANALOG) && (ai.source != -1))
{
int invert;
invert = ai.invert?-1:1;
if (ai.actionCode == ControlConfig.ACTION_ANALOG_PITCH)
quakeIf.analogPitch_if(ControlConfig.LOOK_MODE_JOYSTICK, analogCalibrate(event.getAxisValue(ai.source)) * invert * ai.scale);
else if (ai.actionCode == ControlConfig.ACTION_ANALOG_YAW)
quakeIf.analogYaw_if(ControlConfig.LOOK_MODE_JOYSTICK, -analogCalibrate(event.getAxisValue(ai.source)) * invert * ai.scale);
else if (ai.actionCode == ControlConfig.ACTION_ANALOG_FWD)
quakeIf.analogFwd_if(-analogCalibrate(event.getAxisValue(ai.source)) * invert * ai.scale);
else if (ai.actionCode == ControlConfig.ACTION_ANALOG_STRAFE)
quakeIf.analogSide_if(analogCalibrate(event.getAxisValue(ai.source)) * invert * ai.scale);
else //Must be using analog as a button
{
if (Settings.DEBUG) Log.d(LOG,"Analog as button" );
if (Settings.DEBUG) Log.d(LOG,ai.toString());
if (((ai.sourcePositive) && (event.getAxisValue(ai.source)) > 0.5) ||
((!ai.sourcePositive) && (event.getAxisValue(ai.source)) < -0.5) )
{
if (!analogButtonState.get(ai.actionCode)) //Check internal state, only send if different
{
quakeIf.doAction_if(1, ai.actionCode); //press
analogButtonState.put(ai.actionCode, true);
}
}
else
{
if (analogButtonState.get(ai.actionCode)) //Check internal state, only send if different
{
quakeIf.doAction_if(0, ai.actionCode); //un-press
analogButtonState.put(ai.actionCode, false);
}
}
}
used = true;
}
/*
//Menu buttons
if ((ai.sourceType == Type.ANALOG) && (ai.actionType == Type.MENU) && (ai.source != -1))
{
if (GD.DEBUG) Log.d(LOG,"Analog as MENU button" );
if (GD.DEBUG) Log.d(LOG,ai.toString());
if (((ai.sourcePositive) && (event.getAxisValue(ai.source)) > 0.5) ||
((!ai.sourcePositive) && (event.getAxisValue(ai.source)) < -0.5) )
quakeIf.doAction_if(1, ai.actionCode); //press
else
quakeIf.doAction_if(0, ai.actionCode); //un-press
}
*/
}
}
return used;
}
}
package com.beloko.touchcontrols;
import java.io.IOException;
import java.util.HashMap;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import com.bda.controller.Controller;
import com.beloko.touchcontrols.ControlConfig.Type;
import com.beloko.touchcontrols.Settings.IDGame;
public class ControlInterpreter {
String LOG = "QuakeControlInterpreter";
ControlInterface quakeIf;
ControlConfig config;
boolean gamePadEnabled;
float screenWidth, screenHeight;
HashMap<Integer, Boolean> analogButtonState = new HashMap<Integer, Boolean>(); //Saves current state of analog buttons so all sent each time
public ControlInterpreter(ControlInterface qif,IDGame game,String controlfile,boolean ctrlEn)
{
Log.d("QuakeControlInterpreter", "file = " + controlfile);
gamePadEnabled = ctrlEn;
config = new ControlConfig(controlfile,game);
try {
config.loadControls();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
for (ActionInput ai: config.actions)
{
if ((ai.sourceType == Type.ANALOG) && ((ai.actionType == Type.MENU) || (ai.actionType == Type.BUTTON)))
{
analogButtonState.put(ai.actionCode, false);
}
}
quakeIf = qif;
}
public void setScreenSize(int w,int h)
{
screenWidth = w;
screenHeight = h;
}
public boolean onTouchEvent(MotionEvent event)
{
int action = event.getAction();
int actionCode = action & MotionEvent.ACTION_MASK;
if (actionCode == MotionEvent.ACTION_MOVE)
{
for (int i = 0; i < event.getPointerCount(); i++) {
float x = event.getX(i)/screenWidth;
float y = event.getY(i)/screenHeight;
int pid = event.getPointerId(i);
quakeIf.touchEvent_if(3, pid, x, y);
}
}
else if (actionCode == MotionEvent.ACTION_DOWN)
{
float x = event.getX()/screenWidth;
float y = event.getY()/screenHeight;
quakeIf.touchEvent_if(1, 0, x, y);
}
else if (actionCode == MotionEvent.ACTION_POINTER_DOWN)
{
int index = event.getActionIndex();
if (index != -1)
{
float x = event.getX(index)/screenWidth;
float y = event.getY(index)/screenHeight;
int pid = event.getPointerId(index);
quakeIf.touchEvent_if(1, pid, x, y);
}
}
else if (actionCode == MotionEvent.ACTION_POINTER_UP)
{
int index = event.getActionIndex();
if (index != -1)
{
float x = event.getX(index)/screenWidth;
float y = event.getY(index)/screenHeight;
int pid = event.getPointerId(index);
quakeIf.touchEvent_if(2, pid, x, y);
}
}
else if (actionCode == MotionEvent.ACTION_UP)
{
float x = event.getX()/screenWidth;
float y = event.getY()/screenHeight;
int index = event.getActionIndex();
int pid = event.getPointerId(index);
quakeIf.touchEvent_if(2, pid, x, y);
}
return true;
}
public void onMogaKeyEvent(com.bda.controller.KeyEvent event,int pad_version)
{
int keycode = event.getKeyCode();
if (pad_version == Controller.ACTION_VERSION_MOGA)
{
//Log.d(LOG,"removed");
if ((keycode == com.bda.controller.KeyEvent.KEYCODE_DPAD_DOWN) ||
(keycode == com.bda.controller.KeyEvent.KEYCODE_DPAD_UP) ||
(keycode == com.bda.controller.KeyEvent.KEYCODE_DPAD_LEFT) ||
(keycode == com.bda.controller.KeyEvent.KEYCODE_DPAD_RIGHT))
return;
}
if (event.getAction() == com.bda.controller.KeyEvent.ACTION_DOWN)
onKeyDown(keycode, null);
else if (event.getAction() == com.bda.controller.KeyEvent.ACTION_UP)
onKeyUp(keycode, null);
}
public boolean onKeyDown(int keyCode, KeyEvent event)
{
boolean used = false;;
if (gamePadEnabled)
{
for (ActionInput ai: config.actions)
{
if (((ai.sourceType == Type.BUTTON)||(ai.sourceType == Type.MENU)) && (ai.source == keyCode))
{
quakeIf.doAction_if(1, ai.actionCode);
Log.d(LOG,"key down intercept");
used = true;
}
}
}
if (used)
return true;
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || //If these were mapped it would have already returned
(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))
return false;
else
{
int uc = 0;
if (event !=null)
uc = event.getUnicodeChar();
quakeIf.keyPress_if(1, quakeIf.mapKey(keyCode, uc), uc);
return true;
}
}
public boolean onKeyUp(int keyCode, KeyEvent event)
{
boolean used = false;
if (gamePadEnabled)
{
for (ActionInput ai: config.actions)
{
if (((ai.sourceType == Type.BUTTON) || (ai.sourceType == Type.MENU)) && (ai.source == keyCode))
{
quakeIf.doAction_if(0, ai.actionCode);
used = true;
}
}
}
if (used)
return true;
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || //If these were mapped it would have already returned
(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))
return false;
else
{
int uc = 0;
if (event !=null)
uc = event.getUnicodeChar();
quakeIf.keyPress_if(0, quakeIf.mapKey(keyCode, uc), uc);
return true;
}
}
float deadRegion = 0.2f;
private float analogCalibrate(float v)
{
if ((v < deadRegion) && (v > -deadRegion))
return 0;
else
{
if (v > 0)
return(v-deadRegion) / (1-deadRegion);
else
return(v+deadRegion) / (1-deadRegion);
//return v;
}
}
GenericAxisValues genericAxisValues = new GenericAxisValues();
//This is for normal Android motioon event
public boolean onGenericMotionEvent(MotionEvent event) {
genericAxisValues.setAndroidValues(event);
return onGenericMotionEvent(genericAxisValues);
}
//This is for Moga event
public boolean onGenericMotionEvent(com.bda.controller.MotionEvent event) {
genericAxisValues.setMogaValues(event);
return onGenericMotionEvent(genericAxisValues);
}
public boolean onGenericMotionEvent(GenericAxisValues event) {
if (Settings.DEBUG) Log.d(LOG,"onGenericMotionEvent" );
boolean used = false;
if (gamePadEnabled)
{
for (ActionInput ai: config.actions)
{
if ((ai.sourceType == Type.ANALOG) && (ai.source != -1))
{
int invert;
invert = ai.invert?-1:1;
if (ai.actionCode == ControlConfig.ACTION_ANALOG_PITCH)
quakeIf.analogPitch_if(ControlConfig.LOOK_MODE_JOYSTICK, analogCalibrate(event.getAxisValue(ai.source)) * invert * ai.scale);
else if (ai.actionCode == ControlConfig.ACTION_ANALOG_YAW)
quakeIf.analogYaw_if(ControlConfig.LOOK_MODE_JOYSTICK, -analogCalibrate(event.getAxisValue(ai.source)) * invert * ai.scale);
else if (ai.actionCode == ControlConfig.ACTION_ANALOG_FWD)
quakeIf.analogFwd_if(-analogCalibrate(event.getAxisValue(ai.source)) * invert * ai.scale);
else if (ai.actionCode == ControlConfig.ACTION_ANALOG_STRAFE)
quakeIf.analogSide_if(analogCalibrate(event.getAxisValue(ai.source)) * invert * ai.scale);
else //Must be using analog as a button
{
if (Settings.DEBUG) Log.d(LOG,"Analog as button" );
if (Settings.DEBUG) Log.d(LOG,ai.toString());
if (((ai.sourcePositive) && (event.getAxisValue(ai.source)) > 0.5) ||
((!ai.sourcePositive) && (event.getAxisValue(ai.source)) < -0.5) )
{
if (!analogButtonState.get(ai.actionCode)) //Check internal state, only send if different
{
quakeIf.doAction_if(1, ai.actionCode); //press
analogButtonState.put(ai.actionCode, true);
}
}
else
{
if (analogButtonState.get(ai.actionCode)) //Check internal state, only send if different
{
quakeIf.doAction_if(0, ai.actionCode); //un-press
analogButtonState.put(ai.actionCode, false);
}
}
}
used = true;
}
/*
//Menu buttons
if ((ai.sourceType == Type.ANALOG) && (ai.actionType == Type.MENU) && (ai.source != -1))
{
if (GD.DEBUG) Log.d(LOG,"Analog as MENU button" );
if (GD.DEBUG) Log.d(LOG,ai.toString());
if (((ai.sourcePositive) && (event.getAxisValue(ai.source)) > 0.5) ||
((!ai.sourcePositive) && (event.getAxisValue(ai.source)) < -0.5) )
quakeIf.doAction_if(1, ai.actionCode); //press
else
quakeIf.doAction_if(0, ai.actionCode); //un-press
}
*/
}
}
return used;
}
}

View File

@ -1,289 +1,289 @@
package com.beloko.touchcontrols;
import in.celest.xash3d.hl.R;
import java.io.IOException;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ListView;
import android.widget.TextView;
import com.bda.controller.Controller;
import com.bda.controller.ControllerListener;
import com.bda.controller.StateEvent;
public class GamePadFragment extends Fragment{
final String LOG = "GamePadFragment";
ListView listView;
ControlListAdapter adapter;
TextView info;
ControlConfig config;
GenericAxisValues genericAxisValues = new GenericAxisValues();
Controller mogaController = null;
final MogaControllerListener mListener = new MogaControllerListener();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
config = new ControlConfig(Settings.gamePadControlsFile,Settings.game);
try {
config.loadControls();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
mogaController = Controller.getInstance(getActivity());
mogaController.init();
mogaController.setListener(mListener,new Handler());
}
boolean isHidden = true;
@Override
public void onHiddenChanged(boolean hidden) {
isHidden = hidden;
super.onHiddenChanged(hidden);
}
@Override
public void onPause()
{
super.onPause();
mogaController.onPause();
}
@Override
public void onResume()
{
super.onResume();
mogaController.onResume();
}
@Override
public void onDestroy()
{
super.onDestroy();
mogaController.exit();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.fragment_gamepad, null);
CheckBox enableCb = (CheckBox)mainView.findViewById(R.id.gamepad_enable_checkbox);
enableCb.setChecked(Settings.gamePadEnabled);
enableCb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Settings.setBoolOption(getActivity(), "gamepad_enabled", isChecked);
Settings.gamePadEnabled = isChecked;
setListViewEnabled(Settings.gamePadEnabled);
}
});
CheckBox hideCtrlCb = (CheckBox)mainView.findViewById(R.id.gamepad_hide_touch_checkbox);
hideCtrlCb.setChecked(Settings.hideTouchControls);
hideCtrlCb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Settings.setBoolOption(getActivity(), "hide_touch_controls", isChecked);
Settings.hideTouchControls = isChecked;
}
});
Button help = (Button)mainView.findViewById(R.id.gamepad_help_button);
help.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//NoticeDialog.show(getActivity(),"Gamepad Help", R.raw.gamepad);
}
});
listView = (ListView)mainView.findViewById(R.id.gamepad_listview);
adapter = new ControlListAdapter(getActivity());
listView.setAdapter(adapter);
setListViewEnabled(Settings.gamePadEnabled);
listView.setSelector(R.drawable.layout_sel_background);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, int pos,
long id) {
config.startMonitor(getActivity(), pos);
}
});
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View v, int pos,
long id) {
return config.showExtraOptions(getActivity(), pos);
}
});
adapter.notifyDataSetChanged();
info = (TextView)mainView.findViewById(R.id.gamepad_info_textview);
info.setText("Select Action");
info.setTextColor(getResources().getColor(android.R.color.holo_blue_light));
config.setTextView(getActivity(),info);
return mainView;
}
private void setListViewEnabled(boolean v)
{
listView.setEnabled(v);
if (v)
{
listView.setAlpha(1);
}
else
{
listView.setAlpha(0.3f);
//listView.setBackgroundColor(Color.GRAY);
}
}
public boolean onGenericMotionEvent(MotionEvent event)
{
genericAxisValues.setAndroidValues(event);
if (config.onGenericMotionEvent(genericAxisValues))
adapter.notifyDataSetChanged();
//return config.isMonitoring(); //This does not work, mouse appears anyway
return !isHidden; //If gamepas tab visible always steal
}
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (config.onKeyDown(keyCode, event))
{
adapter.notifyDataSetChanged();
return true;
}
return false;
}
public boolean onKeyUp(int keyCode, KeyEvent event)
{
if(config.onKeyUp(keyCode, event))
{
adapter.notifyDataSetChanged();
return true;
}
return false;
}
class ControlListAdapter extends BaseAdapter{
private Activity context;
public ControlListAdapter(Activity context){
this.context=context;
}
public void add(String string){
}
public int getCount() {
return config.getSize();
}
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
public View getView (int position, View convertView, ViewGroup list) {
View v = config.getView(getActivity(), position);
return v;
}
}
class MogaControllerListener implements ControllerListener {
@Override
public void onKeyEvent(com.bda.controller.KeyEvent event) {
//Log.d(LOG,"onKeyEvent " + event.getKeyCode());
if (event.getAction() == com.bda.controller.KeyEvent.ACTION_DOWN)
onKeyDown(event.getKeyCode(),null);
else if (event.getAction() == com.bda.controller.KeyEvent.ACTION_UP)
onKeyUp(event.getKeyCode(),null);
}
@Override
public void onMotionEvent(com.bda.controller.MotionEvent event) {
//Log.d(LOG,"onGenericMotionEvent " + event.toString());
genericAxisValues.setMogaValues(event);
if (config.onGenericMotionEvent(genericAxisValues))
adapter.notifyDataSetChanged();
}
@Override
public void onStateEvent(StateEvent event) {
Log.d(LOG,"onStateEvent " + event.getState());
}
}
}
package com.beloko.touchcontrols;
import in.celest.xash3d.hl.R;
import java.io.IOException;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ListView;
import android.widget.TextView;
import com.bda.controller.Controller;
import com.bda.controller.ControllerListener;
import com.bda.controller.StateEvent;
public class GamePadFragment extends Fragment{
final String LOG = "GamePadFragment";
ListView listView;
ControlListAdapter adapter;
TextView info;
ControlConfig config;
GenericAxisValues genericAxisValues = new GenericAxisValues();
Controller mogaController = null;
final MogaControllerListener mListener = new MogaControllerListener();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
config = new ControlConfig(Settings.gamePadControlsFile,Settings.game);
try {
config.loadControls();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
mogaController = Controller.getInstance(getActivity());
mogaController.init();
mogaController.setListener(mListener,new Handler());
}
boolean isHidden = true;
@Override
public void onHiddenChanged(boolean hidden) {
isHidden = hidden;
super.onHiddenChanged(hidden);
}
@Override
public void onPause()
{
super.onPause();
mogaController.onPause();
}
@Override
public void onResume()
{
super.onResume();
mogaController.onResume();
}
@Override
public void onDestroy()
{
super.onDestroy();
mogaController.exit();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.fragment_gamepad, null);
CheckBox enableCb = (CheckBox)mainView.findViewById(R.id.gamepad_enable_checkbox);
enableCb.setChecked(Settings.gamePadEnabled);
enableCb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Settings.setBoolOption(getActivity(), "gamepad_enabled", isChecked);
Settings.gamePadEnabled = isChecked;
setListViewEnabled(Settings.gamePadEnabled);
}
});
CheckBox hideCtrlCb = (CheckBox)mainView.findViewById(R.id.gamepad_hide_touch_checkbox);
hideCtrlCb.setChecked(Settings.hideTouchControls);
hideCtrlCb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Settings.setBoolOption(getActivity(), "hide_touch_controls", isChecked);
Settings.hideTouchControls = isChecked;
}
});
Button help = (Button)mainView.findViewById(R.id.gamepad_help_button);
help.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//NoticeDialog.show(getActivity(),"Gamepad Help", R.raw.gamepad);
}
});
listView = (ListView)mainView.findViewById(R.id.gamepad_listview);
adapter = new ControlListAdapter(getActivity());
listView.setAdapter(adapter);
setListViewEnabled(Settings.gamePadEnabled);
listView.setSelector(R.drawable.layout_sel_background);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, int pos,
long id) {
config.startMonitor(getActivity(), pos);
}
});
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View v, int pos,
long id) {
return config.showExtraOptions(getActivity(), pos);
}
});
adapter.notifyDataSetChanged();
info = (TextView)mainView.findViewById(R.id.gamepad_info_textview);
info.setText("Select Action");
info.setTextColor(getResources().getColor(android.R.color.holo_blue_light));
config.setTextView(getActivity(),info);
return mainView;
}
private void setListViewEnabled(boolean v)
{
listView.setEnabled(v);
if (v)
{
listView.setAlpha(1);
}
else
{
listView.setAlpha(0.3f);
//listView.setBackgroundColor(Color.GRAY);
}
}
public boolean onGenericMotionEvent(MotionEvent event)
{
genericAxisValues.setAndroidValues(event);
if (config.onGenericMotionEvent(genericAxisValues))
adapter.notifyDataSetChanged();
//return config.isMonitoring(); //This does not work, mouse appears anyway
return !isHidden; //If gamepas tab visible always steal
}
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (config.onKeyDown(keyCode, event))
{
adapter.notifyDataSetChanged();
return true;
}
return false;
}
public boolean onKeyUp(int keyCode, KeyEvent event)
{
if(config.onKeyUp(keyCode, event))
{
adapter.notifyDataSetChanged();
return true;
}
return false;
}
class ControlListAdapter extends BaseAdapter{
private Activity context;
public ControlListAdapter(Activity context){
this.context=context;
}
public void add(String string){
}
public int getCount() {
return config.getSize();
}
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
public View getView (int position, View convertView, ViewGroup list) {
View v = config.getView(getActivity(), position);
return v;
}
}
class MogaControllerListener implements ControllerListener {
@Override
public void onKeyEvent(com.bda.controller.KeyEvent event) {
//Log.d(LOG,"onKeyEvent " + event.getKeyCode());
if (event.getAction() == com.bda.controller.KeyEvent.ACTION_DOWN)
onKeyDown(event.getKeyCode(),null);
else if (event.getAction() == com.bda.controller.KeyEvent.ACTION_UP)
onKeyUp(event.getKeyCode(),null);
}
@Override
public void onMotionEvent(com.bda.controller.MotionEvent event) {
//Log.d(LOG,"onGenericMotionEvent " + event.toString());
genericAxisValues.setMogaValues(event);
if (config.onGenericMotionEvent(genericAxisValues))
adapter.notifyDataSetChanged();
}
@Override
public void onStateEvent(StateEvent event) {
Log.d(LOG,"onStateEvent " + event.getState());
}
}
}

View File

@ -1,29 +1,29 @@
package com.beloko.touchcontrols;
import android.view.MotionEvent;
public class GenericAxisValues {
float[] values = new float[64];
public float getAxisValue(int a)
{
return values[a];
}
public void setAxisValue(int a,float v)
{
values[a] = v;
}
public void setAndroidValues(MotionEvent event){
for (int n=0;n<64;n++)
values[n] = event.getAxisValue(n);
}
public void setMogaValues(com.bda.controller.MotionEvent event){
values[MotionEvent.AXIS_X] = event.getAxisValue(MotionEvent.AXIS_X);
values[MotionEvent.AXIS_Y] = event.getAxisValue(MotionEvent.AXIS_Y);
values[MotionEvent.AXIS_Z] = event.getAxisValue(MotionEvent.AXIS_Z);
values[MotionEvent.AXIS_RZ] = event.getAxisValue(MotionEvent.AXIS_RZ);
}
}
package com.beloko.touchcontrols;
import android.view.MotionEvent;
public class GenericAxisValues {
float[] values = new float[64];
public float getAxisValue(int a)
{
return values[a];
}
public void setAxisValue(int a,float v)
{
values[a] = v;
}
public void setAndroidValues(MotionEvent event){
for (int n=0;n<64;n++)
values[n] = event.getAxisValue(n);
}
public void setMogaValues(com.bda.controller.MotionEvent event){
values[MotionEvent.AXIS_X] = event.getAxisValue(MotionEvent.AXIS_X);
values[MotionEvent.AXIS_Y] = event.getAxisValue(MotionEvent.AXIS_Y);
values[MotionEvent.AXIS_Z] = event.getAxisValue(MotionEvent.AXIS_Z);
values[MotionEvent.AXIS_RZ] = event.getAxisValue(MotionEvent.AXIS_RZ);
}
}

View File

@ -1,36 +1,36 @@
package com.beloko.touchcontrols;
import java.io.Serializable;
public class QuickCommand implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
String title;
String command;
QuickCommand(String title, String command)
{
this.title = title;
this.command = command;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getCommand() {
return command;
}
public void setCommand(String command) {
this.command = command;
}
}
package com.beloko.touchcontrols;
import java.io.Serializable;
public class QuickCommand implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
String title;
String command;
QuickCommand(String title, String command)
{
this.title = title;
this.command = command;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getCommand() {
return command;
}
public void setCommand(String command) {
this.command = command;
}
}

View File

@ -1,144 +1,144 @@
package com.beloko.touchcontrols;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.util.Log;
public class Settings {
public static boolean DEBUG = false;
public static String gamePadControlsFile = "gamepadSettings.dat";
public static String graphicsDir = "";
public static boolean gamePadEnabled;
public static boolean hideTouchControls;
public enum IDGame{Quake,Quake2,Doom,Duke3d,Quake3,Hexen2,RTCW,Wolf3d,JK2,JK3,Heretic,Hexen,Strife,AVP,Shadow,Gish,Descent1,Descent2,Homeworld,BlakeStone,Noah,Doom3};
public static IDGame game;
public static float getFloatOption(Context ctx,String name, float def)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
return settings.getFloat(name, def);
}
public static void setFloatOption(Context ctx,String name, float value)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = settings.edit();
editor.putFloat(name, value);
editor.commit();
}
public static boolean getBoolOption(Context ctx,String name, boolean def)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
return settings.getBoolean(name, def);
}
public static void setBoolOption(Context ctx,String name, boolean value)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean(name, value);
editor.commit();
}
public static int getIntOption(Context ctx,String name, int def)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
return settings.getInt(name, def);
}
public static void setIntOption(Context ctx,String name, int value)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = settings.edit();
editor.putInt(name, value);
editor.commit();
}
public static long getLongOption(Context ctx,String name, long def)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
return settings.getLong(name, def);
}
public static void setLongOption(Context ctx,String name, long value)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = settings.edit();
editor.putLong(name, value);
editor.commit();
}
public static String getStringOption(Context ctx,String name, String def)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
return settings.getString(name, def);
}
public static void setStringOption(Context ctx,String name, String value)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = settings.edit();
editor.putString(name, value);
editor.commit();
}
static public void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
out.close();
}
static public void copyPNGAssets(Context ctx,String dir,String prefix) {
if (prefix == null)
prefix = "";
File d = new File(dir);
if (!d.exists())
d.mkdirs();
AssetManager assetManager = ctx.getAssets();
String[] files = null;
try {
files = assetManager.list("");
} catch (IOException e) {
Log.e("tag", "Failed to get asset file list.", e);
}
for(String filename : files) {
if (filename.endsWith("png") && filename.startsWith(prefix)){
InputStream in = null;
OutputStream out = null;
//Log.d("test","file = " + filename);
try {
in = assetManager.open(filename);
out = new FileOutputStream(dir + "/" + filename.substring(prefix.length()));
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch(IOException e) {
Log.e("tag", "Failed to copy asset file: " + filename, e);
}
}
}
}
}
package com.beloko.touchcontrols;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.util.Log;
public class Settings {
public static boolean DEBUG = false;
public static String gamePadControlsFile = "gamepadSettings.dat";
public static String graphicsDir = "";
public static boolean gamePadEnabled;
public static boolean hideTouchControls;
public enum IDGame{Quake,Quake2,Doom,Duke3d,Quake3,Hexen2,RTCW,Wolf3d,JK2,JK3,Heretic,Hexen,Strife,AVP,Shadow,Gish,Descent1,Descent2,Homeworld,BlakeStone,Noah,Doom3};
public static IDGame game;
public static float getFloatOption(Context ctx,String name, float def)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
return settings.getFloat(name, def);
}
public static void setFloatOption(Context ctx,String name, float value)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = settings.edit();
editor.putFloat(name, value);
editor.commit();
}
public static boolean getBoolOption(Context ctx,String name, boolean def)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
return settings.getBoolean(name, def);
}
public static void setBoolOption(Context ctx,String name, boolean value)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean(name, value);
editor.commit();
}
public static int getIntOption(Context ctx,String name, int def)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
return settings.getInt(name, def);
}
public static void setIntOption(Context ctx,String name, int value)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = settings.edit();
editor.putInt(name, value);
editor.commit();
}
public static long getLongOption(Context ctx,String name, long def)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
return settings.getLong(name, def);
}
public static void setLongOption(Context ctx,String name, long value)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = settings.edit();
editor.putLong(name, value);
editor.commit();
}
public static String getStringOption(Context ctx,String name, String def)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
return settings.getString(name, def);
}
public static void setStringOption(Context ctx,String name, String value)
{
SharedPreferences settings = ctx.getSharedPreferences("OPTIONS", Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = settings.edit();
editor.putString(name, value);
editor.commit();
}
static public void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
out.close();
}
static public void copyPNGAssets(Context ctx,String dir,String prefix) {
if (prefix == null)
prefix = "";
File d = new File(dir);
if (!d.exists())
d.mkdirs();
AssetManager assetManager = ctx.getAssets();
String[] files = null;
try {
files = assetManager.list("");
} catch (IOException e) {
Log.e("tag", "Failed to get asset file list.", e);
}
for(String filename : files) {
if (filename.endsWith("png") && filename.startsWith(prefix)){
InputStream in = null;
OutputStream out = null;
//Log.d("test","file = " + filename);
try {
in = assetManager.open(filename);
out = new FileOutputStream(dir + "/" + filename.substring(prefix.length()));
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch(IOException e) {
Log.e("tag", "Failed to copy asset file: " + filename, e);
}
}
}
}
}

View File

@ -1,68 +1,68 @@
package com.beloko.touchcontrols;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
public class ShowKeyboard {
static Activity activity;
static View view;;
public static void setup(Activity a,View v)
{
activity = a;
view = v;
}
public static void toggleKeyboard()
{
Log.d("ShowKeyboard","toggleKeyboard");
InputMethodManager im = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (im != null)
{
Log.d("ShowKeyboard","toggleKeyboard...");
im.toggleSoftInput(0, 0);
}
}
public static void showKeyboard(int show)
{
Log.d("ShowKeyboard","showKeyboard " + show);
InputMethodManager im = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (im != null)
{
if (show == 0)
{
im.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}
if (show == 1)
if (!im.isAcceptingText())
toggleKeyboard();
if (show == 2)
toggleKeyboard();
}
/*
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (show == 1)
imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
else
imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
*/
}
public static boolean hasHardwareKeyboard()
{
if(activity == null)
return false;
return activity.getApplicationContext().getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
}
}
package com.beloko.touchcontrols;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
public class ShowKeyboard {
static Activity activity;
static View view;;
public static void setup(Activity a,View v)
{
activity = a;
view = v;
}
public static void toggleKeyboard()
{
Log.d("ShowKeyboard","toggleKeyboard");
InputMethodManager im = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (im != null)
{
Log.d("ShowKeyboard","toggleKeyboard...");
im.toggleSoftInput(0, 0);
}
}
public static void showKeyboard(int show)
{
Log.d("ShowKeyboard","showKeyboard " + show);
InputMethodManager im = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (im != null)
{
if (show == 0)
{
im.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}
if (show == 1)
if (!im.isAcceptingText())
toggleKeyboard();
if (show == 2)
toggleKeyboard();
}
/*
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (show == 1)
imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
else
imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
*/
}
public static boolean hasHardwareKeyboard()
{
if(activity == null)
return false;
return activity.getApplicationContext().getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
}
}

View File

@ -1,145 +1,145 @@
package com.beloko.touchcontrols;
import in.celest.xash3d.hl.R;
import android.app.Activity;
import android.app.Dialog;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.ToggleButton;
public class TouchControlsEditing {
static String TAG = "TouchControlsEditing";
static class ControlInfo
{
String tag;
String image;
boolean enabled;
boolean hidden;
}
static ListAdapter adapter;
static Activity activity;
public static native void JNIGetControlInfo(int pos,ControlInfo info);
public static native int JNIGetNbrControls();
public static native void JNISetHidden(int pos, boolean hidden);
public static void setup(Activity a)
{
activity = a;
}
public static void show()
{
show(activity);
}
public static void show(Activity act)
{
Log.d(TAG,"showSettings");
if (act != null)
activity = act;
activity.runOnUiThread(new Runnable(){
public void run() {
final Dialog dialog = new Dialog(activity);
ListView listView = new ListView(activity);
dialog.setContentView(listView);
dialog.setTitle("Add/remove buttons");
dialog.setCancelable(true);
adapter = new ListAdapter(activity);
listView.setAdapter(adapter);
dialog.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
dialog.show();
}
});
}
static class ListAdapter extends BaseAdapter{
private Activity context;
public ListAdapter(Activity context){
this.context=context;
}
public void add(String string){
}
public int getCount() {
return TouchControlsEditing.JNIGetNbrControls();
}
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
public View getView (int position, View convertView, ViewGroup list) {
//if (convertView == null) dont reuse view otherwise check change get called
convertView = activity.getLayoutInflater().inflate(R.layout.edit_controls_listview_item, null);
final int my_pos = position;
ImageView image = (ImageView)convertView.findViewById(R.id.imageView);
TextView name = (TextView)convertView.findViewById(R.id.name_textview);
ToggleButton hidden = (ToggleButton)convertView.findViewById(R.id.hidden_switch);
TouchControlsEditing.ControlInfo ci = new TouchControlsEditing.ControlInfo();
TouchControlsEditing.JNIGetControlInfo(position, ci);
name.setText(ci.tag);
hidden.setChecked(!ci.hidden);
hidden.setTag(new Integer(position));
hidden.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Integer pos = (Integer)buttonView.getTag();
TouchControlsEditing.JNISetHidden(pos, !isChecked);
adapter.notifyDataSetChanged();
}
});
String png = activity.getFilesDir() + "/" + ci.image + ".png";
Log.d(TAG,"png = " + png);
BitmapDrawable bm = new BitmapDrawable(png);
image.setImageDrawable(bm);
return convertView;
}
}
}
package com.beloko.touchcontrols;
import in.celest.xash3d.hl.R;
import android.app.Activity;
import android.app.Dialog;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.ToggleButton;
public class TouchControlsEditing {
static String TAG = "TouchControlsEditing";
static class ControlInfo
{
String tag;
String image;
boolean enabled;
boolean hidden;
}
static ListAdapter adapter;
static Activity activity;
public static native void JNIGetControlInfo(int pos,ControlInfo info);
public static native int JNIGetNbrControls();
public static native void JNISetHidden(int pos, boolean hidden);
public static void setup(Activity a)
{
activity = a;
}
public static void show()
{
show(activity);
}
public static void show(Activity act)
{
Log.d(TAG,"showSettings");
if (act != null)
activity = act;
activity.runOnUiThread(new Runnable(){
public void run() {
final Dialog dialog = new Dialog(activity);
ListView listView = new ListView(activity);
dialog.setContentView(listView);
dialog.setTitle("Add/remove buttons");
dialog.setCancelable(true);
adapter = new ListAdapter(activity);
listView.setAdapter(adapter);
dialog.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
dialog.show();
}
});
}
static class ListAdapter extends BaseAdapter{
private Activity context;
public ListAdapter(Activity context){
this.context=context;
}
public void add(String string){
}
public int getCount() {
return TouchControlsEditing.JNIGetNbrControls();
}
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
public View getView (int position, View convertView, ViewGroup list) {
//if (convertView == null) dont reuse view otherwise check change get called
convertView = activity.getLayoutInflater().inflate(R.layout.edit_controls_listview_item, null);
final int my_pos = position;
ImageView image = (ImageView)convertView.findViewById(R.id.imageView);
TextView name = (TextView)convertView.findViewById(R.id.name_textview);
ToggleButton hidden = (ToggleButton)convertView.findViewById(R.id.hidden_switch);
TouchControlsEditing.ControlInfo ci = new TouchControlsEditing.ControlInfo();
TouchControlsEditing.JNIGetControlInfo(position, ci);
name.setText(ci.tag);
hidden.setChecked(!ci.hidden);
hidden.setTag(new Integer(position));
hidden.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Integer pos = (Integer)buttonView.getTag();
TouchControlsEditing.JNISetHidden(pos, !isChecked);
adapter.notifyDataSetChanged();
}
});
String png = activity.getFilesDir() + "/" + ci.image + ".png";
Log.d(TAG,"png = " + png);
BitmapDrawable bm = new BitmapDrawable(png);
image.setImageDrawable(bm);
return convertView;
}
}
}

View File

@ -1,265 +1,265 @@
package com.beloko.touchcontrols;
import in.celest.xash3d.hl.R;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.SeekBar;
import android.widget.Spinner;
public class TouchControlsSettings {
static Activity activity;
static ControlInterface quakeIf;
static int alpha,fwdSens,strafeSens,pitchSens,yawSens;
static boolean mouseMode,showWeaponCycle,showSticks,enableWeaponWheel;
static boolean invertLook,precisionShoot;
static int doubleTapMove,doubleTapLook;
public static void setup(Activity a,ControlInterface qif)
{
activity = a;
quakeIf = qif;
}
public static void showSettings()
{
Log.d("settings","showSettings");
activity.runOnUiThread(new Runnable(){
public void run() {
final Dialog dialog = new Dialog(activity);
dialog.setContentView(R.layout.touch_controls_settings);
dialog.setTitle("Touch Control Sensitivity Settings");
dialog.setCancelable(true);
final SeekBar alphaSeek = (SeekBar)dialog.findViewById(R.id.alpha_seekbar);
final SeekBar fwdSeek = (SeekBar)dialog.findViewById(R.id.fwd_seekbar);
final SeekBar strafeSeek = (SeekBar)dialog.findViewById(R.id.strafe_seekbar);
final SeekBar pitchSeek = (SeekBar)dialog.findViewById(R.id.pitch_seekbar);
final SeekBar yawSeek = (SeekBar)dialog.findViewById(R.id.yaw_seekbar);
final CheckBox mouseModeCheck = (CheckBox)dialog.findViewById(R.id.mouse_turn_checkbox);
final CheckBox showWeaponCycleCheckBox = (CheckBox)dialog.findViewById(R.id.show_next_weapon_checkbox);
final CheckBox invertLookCheckBox = (CheckBox)dialog.findViewById(R.id.invert_loop_checkbox);
final CheckBox precisionShootCheckBox = (CheckBox)dialog.findViewById(R.id.precision_shoot_checkbox);
final CheckBox showSticksCheckBox = (CheckBox)dialog.findViewById(R.id.show_sticks_checkbox);
final CheckBox enableWeaponWheelCheckBox = (CheckBox)dialog.findViewById(R.id.enable_weapon_wheel_checkbox);
/*
//Hide controls for lookup/down
if (Settings.game == IDGame.Doom)
{
//pitchSeek.setVisibility(View.GONE);
invertLookCheckBox.setVisibility(View.GONE);
}
*/
Button add_rem_button = (Button)dialog.findViewById(R.id.add_remove_button);
add_rem_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TouchControlsEditing.show(activity);
}
});
alphaSeek.setProgress(alpha);
fwdSeek.setProgress(fwdSens);
strafeSeek.setProgress(strafeSens);
pitchSeek.setProgress(pitchSens);
yawSeek.setProgress(yawSens);
mouseModeCheck.setChecked(mouseMode);
showWeaponCycleCheckBox.setChecked(showWeaponCycle);
invertLookCheckBox.setChecked(invertLook);
precisionShootCheckBox.setChecked(precisionShoot);
showSticksCheckBox.setChecked(showSticks);
enableWeaponWheelCheckBox.setChecked(enableWeaponWheel);
Spinner move_spinner = (Spinner) dialog.findViewById(R.id.move_dbl_tap_spinner);
ArrayAdapter<CharSequence> adapterm;
adapterm = ArrayAdapter.createFromResource(activity,
R.array.double_tap_actions, android.R.layout.simple_spinner_item);
adapterm.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
move_spinner.setAdapter(adapterm);
move_spinner.setSelection(doubleTapMove);
move_spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
doubleTapMove = pos;
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
Spinner look_spinner = (Spinner) dialog.findViewById(R.id.look_dbl_tap_spinner);
ArrayAdapter<CharSequence> adapterl = ArrayAdapter.createFromResource(activity,
R.array.double_tap_actions, android.R.layout.simple_spinner_item);
adapterl.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
look_spinner.setAdapter(adapterl);
look_spinner.setSelection(doubleTapLook);
look_spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
doubleTapLook = pos;
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
dialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
alpha = alphaSeek.getProgress();
fwdSens = fwdSeek.getProgress();
strafeSens = strafeSeek.getProgress();
pitchSens = pitchSeek.getProgress();
yawSens = yawSeek.getProgress();
mouseMode = mouseModeCheck.isChecked();
showWeaponCycle = showWeaponCycleCheckBox.isChecked();
invertLook = invertLookCheckBox.isChecked();
precisionShoot = precisionShootCheckBox.isChecked();
showSticks = showSticksCheckBox.isChecked();
enableWeaponWheel = enableWeaponWheelCheckBox.isChecked();
saveSettings(activity);
sendToQuake();
}
});
Button save = (Button)dialog.findViewById(R.id.save_button);
save.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
alpha = alphaSeek.getProgress();
fwdSens = fwdSeek.getProgress();
strafeSens = strafeSeek.getProgress();
pitchSens = pitchSeek.getProgress();
yawSens = yawSeek.getProgress();
mouseMode = mouseModeCheck.isChecked();
showWeaponCycle = showWeaponCycleCheckBox.isChecked();
invertLook = invertLookCheckBox.isChecked();
precisionShoot = precisionShootCheckBox.isChecked();
showSticks = showSticksCheckBox.isChecked();
enableWeaponWheel = enableWeaponWheelCheckBox.isChecked();
saveSettings(activity);
sendToQuake();
dialog.dismiss();
}
});
Button cancel = (Button)dialog.findViewById(R.id.cancel_button);
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
}
public static void sendToQuake()
{
int other = 0;
other += showWeaponCycle?0x1:0;
other += mouseMode?0x2:0;
other += invertLook?0x4:0;
other += precisionShoot?0x8:0;
other += (doubleTapMove << 4) & 0xF0;
other += (doubleTapLook << 8) & 0xF00;
other += showSticks?0x1000:0;
other += enableWeaponWheel?0x2000:0;
other += Settings.hideTouchControls?0x80000000:0;
quakeIf.setTouchSettings_if(
(float)alpha/(float)100,
(strafeSens)/(float)50,
(fwdSens)/(float)50,
(pitchSens)/(float)50,
(yawSens)/(float)50,
other);
}
public static void loadSettings(Context ctx)
{
alpha = Settings.getIntOption(ctx, "alpha", 50);
fwdSens = Settings.getIntOption(ctx, "fwdSens", 50);
strafeSens = Settings.getIntOption(ctx, "strafeSens", 50);
pitchSens = Settings.getIntOption(ctx, "pitchSens", 50);
yawSens = Settings.getIntOption(ctx, "yawSens", 50);
showWeaponCycle = Settings.getBoolOption(ctx, "show_weapon_cycle", true);
mouseMode = Settings.getBoolOption(ctx, "mouse_mode", true);
invertLook = Settings.getBoolOption(ctx, "invert_look", false);
precisionShoot = Settings.getBoolOption(ctx, "precision_shoot", false);
showSticks = Settings.getBoolOption(ctx, "show_sticks", false);
enableWeaponWheel = Settings.getBoolOption(ctx, "enable_ww", true);
doubleTapMove = Settings.getIntOption(ctx, "double_tap_move", 0);
doubleTapLook = Settings.getIntOption(ctx, "double_tap_look", 0);
}
public static void saveSettings(Context ctx)
{
Settings.setIntOption(ctx, "alpha", alpha);
Settings.setIntOption(ctx, "fwdSens", fwdSens);
Settings.setIntOption(ctx, "strafeSens", strafeSens);
Settings.setIntOption(ctx, "pitchSens", pitchSens);
Settings.setIntOption(ctx, "yawSens", yawSens);
Settings.setBoolOption(ctx, "show_weapon_cycle", showWeaponCycle);
Settings.setBoolOption(ctx, "invert_look", invertLook);
Settings.setBoolOption(ctx, "precision_shoot", precisionShoot);
Settings.setBoolOption(ctx, "show_sticks", showSticks);
Settings.setBoolOption(ctx, "enable_ww", enableWeaponWheel);
Settings.setIntOption(ctx, "double_tap_move", doubleTapMove);
Settings.setIntOption(ctx, "double_tap_look", doubleTapLook);
}
}
package com.beloko.touchcontrols;
import in.celest.xash3d.hl.R;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.SeekBar;
import android.widget.Spinner;
public class TouchControlsSettings {
static Activity activity;
static ControlInterface quakeIf;
static int alpha,fwdSens,strafeSens,pitchSens,yawSens;
static boolean mouseMode,showWeaponCycle,showSticks,enableWeaponWheel;
static boolean invertLook,precisionShoot;
static int doubleTapMove,doubleTapLook;
public static void setup(Activity a,ControlInterface qif)
{
activity = a;
quakeIf = qif;
}
public static void showSettings()
{
Log.d("settings","showSettings");
activity.runOnUiThread(new Runnable(){
public void run() {
final Dialog dialog = new Dialog(activity);
dialog.setContentView(R.layout.touch_controls_settings);
dialog.setTitle("Touch Control Sensitivity Settings");
dialog.setCancelable(true);
final SeekBar alphaSeek = (SeekBar)dialog.findViewById(R.id.alpha_seekbar);
final SeekBar fwdSeek = (SeekBar)dialog.findViewById(R.id.fwd_seekbar);
final SeekBar strafeSeek = (SeekBar)dialog.findViewById(R.id.strafe_seekbar);
final SeekBar pitchSeek = (SeekBar)dialog.findViewById(R.id.pitch_seekbar);
final SeekBar yawSeek = (SeekBar)dialog.findViewById(R.id.yaw_seekbar);
final CheckBox mouseModeCheck = (CheckBox)dialog.findViewById(R.id.mouse_turn_checkbox);
final CheckBox showWeaponCycleCheckBox = (CheckBox)dialog.findViewById(R.id.show_next_weapon_checkbox);
final CheckBox invertLookCheckBox = (CheckBox)dialog.findViewById(R.id.invert_loop_checkbox);
final CheckBox precisionShootCheckBox = (CheckBox)dialog.findViewById(R.id.precision_shoot_checkbox);
final CheckBox showSticksCheckBox = (CheckBox)dialog.findViewById(R.id.show_sticks_checkbox);
final CheckBox enableWeaponWheelCheckBox = (CheckBox)dialog.findViewById(R.id.enable_weapon_wheel_checkbox);
/*
//Hide controls for lookup/down
if (Settings.game == IDGame.Doom)
{
//pitchSeek.setVisibility(View.GONE);
invertLookCheckBox.setVisibility(View.GONE);
}
*/
Button add_rem_button = (Button)dialog.findViewById(R.id.add_remove_button);
add_rem_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TouchControlsEditing.show(activity);
}
});
alphaSeek.setProgress(alpha);
fwdSeek.setProgress(fwdSens);
strafeSeek.setProgress(strafeSens);
pitchSeek.setProgress(pitchSens);
yawSeek.setProgress(yawSens);
mouseModeCheck.setChecked(mouseMode);
showWeaponCycleCheckBox.setChecked(showWeaponCycle);
invertLookCheckBox.setChecked(invertLook);
precisionShootCheckBox.setChecked(precisionShoot);
showSticksCheckBox.setChecked(showSticks);
enableWeaponWheelCheckBox.setChecked(enableWeaponWheel);
Spinner move_spinner = (Spinner) dialog.findViewById(R.id.move_dbl_tap_spinner);
ArrayAdapter<CharSequence> adapterm;
adapterm = ArrayAdapter.createFromResource(activity,
R.array.double_tap_actions, android.R.layout.simple_spinner_item);
adapterm.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
move_spinner.setAdapter(adapterm);
move_spinner.setSelection(doubleTapMove);
move_spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
doubleTapMove = pos;
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
Spinner look_spinner = (Spinner) dialog.findViewById(R.id.look_dbl_tap_spinner);
ArrayAdapter<CharSequence> adapterl = ArrayAdapter.createFromResource(activity,
R.array.double_tap_actions, android.R.layout.simple_spinner_item);
adapterl.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
look_spinner.setAdapter(adapterl);
look_spinner.setSelection(doubleTapLook);
look_spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
doubleTapLook = pos;
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
dialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
alpha = alphaSeek.getProgress();
fwdSens = fwdSeek.getProgress();
strafeSens = strafeSeek.getProgress();
pitchSens = pitchSeek.getProgress();
yawSens = yawSeek.getProgress();
mouseMode = mouseModeCheck.isChecked();
showWeaponCycle = showWeaponCycleCheckBox.isChecked();
invertLook = invertLookCheckBox.isChecked();
precisionShoot = precisionShootCheckBox.isChecked();
showSticks = showSticksCheckBox.isChecked();
enableWeaponWheel = enableWeaponWheelCheckBox.isChecked();
saveSettings(activity);
sendToQuake();
}
});
Button save = (Button)dialog.findViewById(R.id.save_button);
save.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
alpha = alphaSeek.getProgress();
fwdSens = fwdSeek.getProgress();
strafeSens = strafeSeek.getProgress();
pitchSens = pitchSeek.getProgress();
yawSens = yawSeek.getProgress();
mouseMode = mouseModeCheck.isChecked();
showWeaponCycle = showWeaponCycleCheckBox.isChecked();
invertLook = invertLookCheckBox.isChecked();
precisionShoot = precisionShootCheckBox.isChecked();
showSticks = showSticksCheckBox.isChecked();
enableWeaponWheel = enableWeaponWheelCheckBox.isChecked();
saveSettings(activity);
sendToQuake();
dialog.dismiss();
}
});
Button cancel = (Button)dialog.findViewById(R.id.cancel_button);
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
}
public static void sendToQuake()
{
int other = 0;
other += showWeaponCycle?0x1:0;
other += mouseMode?0x2:0;
other += invertLook?0x4:0;
other += precisionShoot?0x8:0;
other += (doubleTapMove << 4) & 0xF0;
other += (doubleTapLook << 8) & 0xF00;
other += showSticks?0x1000:0;
other += enableWeaponWheel?0x2000:0;
other += Settings.hideTouchControls?0x80000000:0;
quakeIf.setTouchSettings_if(
(float)alpha/(float)100,
(strafeSens)/(float)50,
(fwdSens)/(float)50,
(pitchSens)/(float)50,
(yawSens)/(float)50,
other);
}
public static void loadSettings(Context ctx)
{
alpha = Settings.getIntOption(ctx, "alpha", 50);
fwdSens = Settings.getIntOption(ctx, "fwdSens", 50);
strafeSens = Settings.getIntOption(ctx, "strafeSens", 50);
pitchSens = Settings.getIntOption(ctx, "pitchSens", 50);
yawSens = Settings.getIntOption(ctx, "yawSens", 50);
showWeaponCycle = Settings.getBoolOption(ctx, "show_weapon_cycle", true);
mouseMode = Settings.getBoolOption(ctx, "mouse_mode", true);
invertLook = Settings.getBoolOption(ctx, "invert_look", false);
precisionShoot = Settings.getBoolOption(ctx, "precision_shoot", false);
showSticks = Settings.getBoolOption(ctx, "show_sticks", false);
enableWeaponWheel = Settings.getBoolOption(ctx, "enable_ww", true);
doubleTapMove = Settings.getIntOption(ctx, "double_tap_move", 0);
doubleTapLook = Settings.getIntOption(ctx, "double_tap_look", 0);
}
public static void saveSettings(Context ctx)
{
Settings.setIntOption(ctx, "alpha", alpha);
Settings.setIntOption(ctx, "fwdSens", fwdSens);
Settings.setIntOption(ctx, "strafeSens", strafeSens);
Settings.setIntOption(ctx, "pitchSens", pitchSens);
Settings.setIntOption(ctx, "yawSens", yawSens);
Settings.setBoolOption(ctx, "show_weapon_cycle", showWeaponCycle);
Settings.setBoolOption(ctx, "invert_look", invertLook);
Settings.setBoolOption(ctx, "precision_shoot", precisionShoot);
Settings.setBoolOption(ctx, "show_sticks", showSticks);
Settings.setBoolOption(ctx, "enable_ww", enableWeaponWheel);
Settings.setIntOption(ctx, "double_tap_move", doubleTapMove);
Settings.setIntOption(ctx, "double_tap_look", doubleTapLook);
}
}

File diff suppressed because it is too large Load Diff