Skip to content

Commit 73a84a5

Browse files
author
Emil "AngryAnt" Johansen
committed
The presentation now runs on the Google TV devkit because why not.
1 parent 397e008 commit 73a84a5

File tree

12 files changed

+279
-10
lines changed

12 files changed

+279
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
Library
33
*.sln
44
*.userprefs
5+
Temp

Assets/Logic/Presentation/Control.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using UnityEngine;
22
using System.Collections;
3+
using UnityAssets;
34

45

56
public class Control : MonoBehaviour
@@ -25,12 +26,14 @@ public int BuildIndex
2526

2627
void Awake ()
2728
{
29+
#if !UNITY_ANDROID
2830
int targetLevel = PlayerPrefs.GetInt (kLastLevelPref, -1);
2931
if (targetLevel != -1 && targetLevel != Application.loadedLevel)
3032
{
3133
LoadLevel (targetLevel);
3234
return;
3335
}
36+
#endif
3437

3538
foreach (GameObject item in build)
3639
{
@@ -109,8 +112,44 @@ void OnGesture (Gesture gesture)
109112
}
110113

111114

115+
#if UNITY_ANDROID
116+
const float kControllerPressDelay = 1.0f;
117+
float m_LastControllerPress = 0;
118+
#endif
119+
120+
112121
void Update ()
113122
{
123+
#if UNITY_ANDROID
124+
if (Time.time - m_LastControllerPress > kControllerPressDelay)
125+
{
126+
if (
127+
Input.GetAxis ("Joystick Axis 5") < -0.5f ||
128+
Input.GetAxis ("Joystick Axis X") < -0.5f ||
129+
Input.GetAxis ("Joystick Axis 3") < -0.5f ||
130+
Input.GetKey (KeyCode.JoystickButton4)
131+
)
132+
{
133+
m_LastControllerPress = Time.time;
134+
Previous ();
135+
}
136+
else if (
137+
Input.GetAxis ("Joystick Axis 5") > 0.5f ||
138+
Input.GetAxis ("Joystick Axis X") > 0.5f ||
139+
Input.GetAxis ("Joystick Axis 3") > 0.5f ||
140+
Input.GetKey (KeyCode.JoystickButton0)
141+
)
142+
{
143+
m_LastControllerPress = Time.time;
144+
Next ();
145+
}
146+
else if (Input.GetKey (KeyCode.JoystickButton5))
147+
{
148+
m_LastControllerPress = Time.time;
149+
Skip ();
150+
}
151+
}
152+
#else
114153
if (Input.GetButtonDown (kPreviousButtonName))
115154
{
116155
Previous ();
@@ -126,5 +165,6 @@ void Update ()
126165
Next ();
127166
}
128167
}
168+
#endif
129169
}
130170
}

Assets/Plugins.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/Android.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.AngryAnt.PracticalAI" android:theme="@android:style/Theme.NoTitleBar" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
3+
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
4+
<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">
5+
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="reverseLandscape">
6+
<intent-filter>
7+
<action android:name="android.intent.action.MAIN" />
8+
<category android:name="android.intent.category.LAUNCHER" />
9+
</intent-filter>
10+
<intent-filter>
11+
<action android:name="android.intent.action.MAIN" />
12+
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
13+
</intent-filter>
14+
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
15+
</activity>
16+
</application>
17+
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17" />
18+
<uses-feature android:glEsVersion="0x00020000" />
19+
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
20+
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
21+
<uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
22+
<uses-feature android:name="android.hardware.gamepad.compatible" />
23+
</manifest>

Assets/Plugins/Android/AndroidManifest.xml.meta

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/Android/JoystickMap.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
4+
5+
public class JoystickMap : MonoBehaviour
6+
{
7+
void OnGUI ()
8+
{
9+
LabelLabel ("Frame", Time.frameCount.ToString ());
10+
11+
GUILayout.Label ("General buttons");
12+
ButtonMap ("A: Joystick Button 0", Input.GetKey (KeyCode.JoystickButton0));
13+
ButtonMap ("B: Joystick Button 1", Input.GetKey (KeyCode.JoystickButton1));
14+
ButtonMap ("X: Joystick Button 2", Input.GetKey (KeyCode.JoystickButton2));
15+
ButtonMap ("Y: Joystick Button 3", Input.GetKey (KeyCode.JoystickButton3));
16+
ButtonMap ("L1: Joystick Button 4", Input.GetKey (KeyCode.JoystickButton4));
17+
ButtonMap ("R1: Joystick Button 5", Input.GetKey (KeyCode.JoystickButton5));
18+
ButtonMap ("L3: Joystick Button 8", Input.GetKey (KeyCode.JoystickButton8));
19+
ButtonMap ("R3: Joystick Button 9", Input.GetKey (KeyCode.JoystickButton9));
20+
21+
GUILayout.Label ("Control buttons");
22+
ButtonMap ("Back", Input.GetKey (KeyCode.Escape));
23+
ButtonMap ("Menu", Input.GetKey (KeyCode.Menu));
24+
25+
GUILayout.Label ("Axes");
26+
AxisMap ("L X: Joystick Axis X", Input.GetAxis ("Joystick Axis X"));
27+
AxisMap ("L Y: Joystick Axis Y", Input.GetAxis ("Joystick Axis Y"));
28+
AxisMap ("R X: Joystick Axis 3", Input.GetAxis ("Joystick Axis 3"));
29+
AxisMap ("R Y: Joystick Axis 4", Input.GetAxis ("Joystick Axis 4"));
30+
AxisMap ("DPAD H: Joystick Axis 5", Input.GetAxis ("Joystick Axis 5"));
31+
AxisMap ("DPAD V: Joystick Axis 6", Input.GetAxis ("Joystick Axis 6"));
32+
AxisMap ("L2: Joystick Axis 7", Input.GetAxis ("Joystick Axis 7"));
33+
AxisMap ("R2: Joystick Axis 8", Input.GetAxis ("Joystick Axis 8"));
34+
}
35+
36+
37+
void ButtonMap (string label, bool value)
38+
{
39+
LabelLabel (label, value ? "Down" : "Up");
40+
}
41+
42+
43+
void AxisMap (string label, float value)
44+
{
45+
LabelLabel (label, value.ToString ("F3"));
46+
}
47+
48+
49+
void LabelLabel (string label, string otherLabel)
50+
{
51+
GUILayout.BeginHorizontal (GUI.skin.box, GUILayout.Width (400.0f));
52+
GUILayout.Label (label);
53+
GUILayout.FlexibleSpace ();
54+
GUILayout.Label (otherLabel);
55+
GUILayout.EndHorizontal ();
56+
}
57+
}

Assets/Plugins/Android/JoystickMap.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Standard Assets/Input/TouchGestures.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
using System.Linq;
55

66

7-
// TODO: Revert workaround when namespaces + default params work again
8-
using UnityAssets;
9-
//namespace UnityAssets
10-
//{
7+
namespace UnityAssets
8+
{
119
public enum GestureType
1210
{
1311
Swipe = 1,
@@ -332,4 +330,4 @@ void Record ()
332330
}
333331
}
334332
}
335-
//}
333+
}

ProjectSettings/EditorBuildSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ EditorBuildSettings:
55
m_ObjectHideFlags: 0
66
serializedVersion: 2
77
m_Scenes:
8-
- enabled: 1
8+
- enabled: 0
99
path: Assets/Scenes/0 - Reset.unity
1010
- enabled: 1
1111
path: Assets/Scenes/1 - Intro/1 - Title.unity

0 commit comments

Comments
 (0)