diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidAccessoryHost.c b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidAccessoryHost.c index b7ae775289..d103b5d336 100644 --- a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidAccessoryHost.c +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidAccessoryHost.c @@ -53,7 +53,7 @@ USB_ClassInfo_AOA_Host_t AndroidDevice_AOA_Interface = { .Address = (PIPE_DIR_OUT | 2), .Banks = 1, - }, + }, .PropertyStrings = { [AOA_STRING_Manufacturer] = "Dean Camera", @@ -73,7 +73,7 @@ USB_ClassInfo_AOA_Host_t AndroidDevice_AOA_Interface = int main(void) { SetupHardware(); - + puts_P(PSTR(ESC_FG_CYAN "Android Accessory Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); @@ -120,7 +120,12 @@ void AOAHost_Task(void) /* Echo received bytes from the attached device through the USART */ int16_t ReceivedByte = AOA_Host_ReceiveByte(&AndroidDevice_AOA_Interface); if (!(ReceivedByte < 0)) - putchar(ReceivedByte); + { + /* Turn on and off LED1 based on the bytes received */ + LEDs_ChangeLEDs(LEDS_LED1, ReceivedByte ? LEDS_LED1 : LEDS_NO_LEDS); + + putchar(ReceivedByte); + } } } @@ -155,7 +160,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void) { puts_P(PSTR("Error Retrieving Device Descriptor.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - return; + return; } bool NeedModeSwitch; @@ -165,7 +170,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void) LEDs_SetAllLEDs(LEDMASK_USB_ERROR); return; } - + if (NeedModeSwitch) { puts_P(PSTR("Not in Accessory mode, switching...\r\n")); diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/.classpath b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/.classpath new file mode 100644 index 0000000000..3f9691c5dd --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/.project b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/.project new file mode 100644 index 0000000000..09388ba603 --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/.project @@ -0,0 +1,33 @@ + + + LUFA_AOA_Test + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/.settings/org.eclipse.jdt.core.prefs b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..b080d2ddc8 --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/AndroidManifest.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/AndroidManifest.xml new file mode 100644 index 0000000000..ab57674513 --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/AndroidManifest.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/AndroidManifest.xml new file mode 100644 index 0000000000..ab57674513 --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/BuildConfig.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/BuildConfig.class new file mode 100644 index 0000000000..ae1212efbc Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/BuildConfig.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/MainActivity.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/MainActivity.class new file mode 100644 index 0000000000..c1cb18fc7f Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/MainActivity.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$attr.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$attr.class new file mode 100644 index 0000000000..1f85cf87e7 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$attr.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$dimen.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$dimen.class new file mode 100644 index 0000000000..17323ef315 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$dimen.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$drawable.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$drawable.class new file mode 100644 index 0000000000..fd22775788 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$drawable.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$id.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$id.class new file mode 100644 index 0000000000..2ec18315ba Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$id.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$layout.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$layout.class new file mode 100644 index 0000000000..77835f24ce Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$layout.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$menu.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$menu.class new file mode 100644 index 0000000000..695d0a809e Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$menu.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$string.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$string.class new file mode 100644 index 0000000000..73a2d25dbb Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$string.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$style.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$style.class new file mode 100644 index 0000000000..ca51233b57 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$style.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$xml.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$xml.class new file mode 100644 index 0000000000..3671c14497 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R$xml.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R.class b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R.class new file mode 100644 index 0000000000..8febfbe299 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/classes/com/example/lufa_aoa_test/R.class differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/jarlist.cache b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/jarlist.cache new file mode 100644 index 0000000000..1b5ec3f9c5 --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/bin/jarlist.cache @@ -0,0 +1,3 @@ +# cache for current jar dependecy. DO NOT EDIT. +# format is +# Encoding is UTF-8 diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/gen/com/example/lufa_aoa_test/BuildConfig.java b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/gen/com/example/lufa_aoa_test/BuildConfig.java new file mode 100644 index 0000000000..80f18ec2db --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/gen/com/example/lufa_aoa_test/BuildConfig.java @@ -0,0 +1,6 @@ +/** Automatically generated file. DO NOT MODIFY */ +package com.example.lufa_aoa_test; + +public final class BuildConfig { + public final static boolean DEBUG = true; +} \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/gen/com/example/lufa_aoa_test/R.java b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/gen/com/example/lufa_aoa_test/R.java new file mode 100644 index 0000000000..367b897282 --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/gen/com/example/lufa_aoa_test/R.java @@ -0,0 +1,71 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package com.example.lufa_aoa_test; + +public final class R { + public static final class attr { + } + public static final class dimen { + /** Default screen margins, per the Android Design guidelines. + + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. + + */ + public static final int activity_horizontal_margin=0x7f050000; + public static final int activity_vertical_margin=0x7f050001; + } + public static final class drawable { + public static final int ic_launcher=0x7f020000; + } + public static final class id { + public static final int action_settings=0x7f090001; + public static final int toggleButton1=0x7f090000; + } + public static final class layout { + public static final int activity_main=0x7f030000; + } + public static final class menu { + public static final int main=0x7f080000; + } + public static final class string { + public static final int action_settings=0x7f060001; + public static final int app_name=0x7f060000; + } + public static final class style { + /** + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + + + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + + + Base application theme for API 11+. This theme completely replaces + AppBaseTheme from res/values/styles.xml on API 11+ devices. + + API 11 theme customizations can go here. + + Base application theme for API 14+. This theme completely replaces + AppBaseTheme from BOTH res/values/styles.xml and + res/values-v11/styles.xml on API 14+ devices. + + API 14 theme customizations can go here. + */ + public static final int AppBaseTheme=0x7f070000; + /** Application theme. + All customizations that are NOT specific to a particular API-level can go here. + */ + public static final int AppTheme=0x7f070001; + } + public static final class xml { + public static final int accessory_filter=0x7f040000; + } +} diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/ic_launcher-web.png b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/ic_launcher-web.png new file mode 100644 index 0000000000..a5852ba575 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/ic_launcher-web.png differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/libs/android-support-v4.jar b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/libs/android-support-v4.jar new file mode 100644 index 0000000000..65ebaf8dc3 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/libs/android-support-v4.jar differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/project.properties b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/project.properties new file mode 100644 index 0000000000..0c9830a3b0 --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/project.properties @@ -0,0 +1,14 @@ +# 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 edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=Google Inc.:Google APIs:17 diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-hdpi/ic_launcher.png b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000000..004688dfb0 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-hdpi/ic_launcher.png differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-mdpi/ic_launcher.png b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000000..207afa8bcf Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-mdpi/ic_launcher.png differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-xhdpi/ic_launcher.png b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..8d8d79c9a8 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-xhdpi/ic_launcher.png differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-xxhdpi/ic_launcher.png b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..82e2242028 Binary files /dev/null and b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/layout/activity_main.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/layout/activity_main.xml new file mode 100644 index 0000000000..f24e9986e8 --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/layout/activity_main.xml @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/menu/main.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/menu/main.xml new file mode 100644 index 0000000000..d227c4927c --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/menu/main.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-sw600dp/dimens.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-sw600dp/dimens.xml new file mode 100644 index 0000000000..1ba777d65d --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-sw600dp/dimens.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-sw720dp-land/dimens.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-sw720dp-land/dimens.xml new file mode 100644 index 0000000000..eee741a510 --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,9 @@ + + + + 128dp + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-v11/styles.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-v11/styles.xml new file mode 100644 index 0000000000..541752f6ed --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-v14/styles.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-v14/styles.xml new file mode 100644 index 0000000000..f20e01501d --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values-v14/styles.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values/dimens.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values/dimens.xml new file mode 100644 index 0000000000..a6dd14032e --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + + 16dp + 16dp + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values/strings.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values/strings.xml new file mode 100644 index 0000000000..2593f602f2 --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values/strings.xml @@ -0,0 +1,7 @@ + + + + LUFA AOA Example + Settings + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values/styles.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values/styles.xml new file mode 100644 index 0000000000..4a10ca492d --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/xml/accessory_filter.xml b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/xml/accessory_filter.xml new file mode 100644 index 0000000000..acf6c6192f --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/res/xml/accessory_filter.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/src/com/example/lufa_aoa_test/MainActivity.java b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/src/com/example/lufa_aoa_test/MainActivity.java new file mode 100644 index 0000000000..e5587632ad --- /dev/null +++ b/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/src/com/example/lufa_aoa_test/MainActivity.java @@ -0,0 +1,68 @@ +package com.example.lufa_aoa_test; + +import java.io.FileDescriptor; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +import android.os.Bundle; +import android.os.ParcelFileDescriptor; +import android.app.Activity; +import android.content.Intent; +import android.view.Menu; +import android.view.View; +import android.widget.*; +import com.android.future.usb.*; + +public class MainActivity extends Activity { + private UsbManager mUSBManager; + private UsbAccessory mAccessoryDevice; + private ParcelFileDescriptor mFileDescriptor; + private FileInputStream mInputStream; + private FileOutputStream mOutputStream; + + public void changeLEDState(View v) { + boolean newButtonState = ((ToggleButton)v).isChecked(); + + if (mOutputStream != null) { + try { + mOutputStream.write(newButtonState ? 0x01 : 0x00); + } + catch (IOException e) + { + + } + } + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Intent intent = getIntent(); + + if ((intent != null) && (intent.getAction() == com.android.future.usb.UsbManager.ACTION_USB_ACCESSORY_ATTACHED)) + { + mUSBManager = UsbManager.getInstance(this); + if (mUSBManager != null) + { + mAccessoryDevice = UsbManager.getAccessory(intent); + mFileDescriptor = mUSBManager.openAccessory(mAccessoryDevice); + + FileDescriptor fd = mFileDescriptor.getFileDescriptor(); + mInputStream = new FileInputStream(fd); + mOutputStream = new FileOutputStream(fd); + } + } + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.main, menu); + return true; + } + +}