0

HELP with Android controller project
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

HELP with Android controller project

by joaoha on Tue Dec 08, 2020 8:46 pm

Hi,

I'm trying to build code to control an Android APP with a set of buttons.

I want to use 5 physical buttons to send 8 commands to the APP.

The app takes the following codes:

KEYCODE_DPAD_UP
KEYCODE_DPAD_DOWN

KEYCODE_ENTER
KEYCODE_A
KEYCODE_D
KEYCODE_E. --> Long press
KEYCODE_Q --> Long press
KEYCODE_ESCAPE --> Long press


I have some code that works to send BleHidControlKey commands like "VOLUME+" "VOLUME-" but I cannot seem to find a way to produce the correct command for the APP like KEYCODE_DPAD_UP or KEYCODE_DPAD_DOWN or any of the other commands I want to send.

Any help is much appreciated.

joaoha
 
Posts: 3
Joined: Tue Dec 08, 2020 8:37 pm

Re: HELP with Android controller project

by blnkjns on Wed Dec 09, 2020 1:41 am

What hardware do you use? You know there are like 15$ programmable BT gamepad/keyboard interfaces just for this?

blnkjns
 
Posts: 194
Joined: Fri Oct 02, 2020 3:33 am

Re: HELP with Android controller project

by joaoha on Wed Dec 09, 2020 2:20 am

No I don't know about those BT programable interfaces can you recommend one?

I'm using the Adafruit Feather 32u4

Thanks for helping

joaoha
 
Posts: 3
Joined: Tue Dec 08, 2020 8:37 pm

Re: HELP with Android controller project

by blnkjns on Thu Dec 10, 2020 5:36 am

Adafruit used to sell this:
https://www.adafruit.com/product/1535

blnkjns
 
Posts: 194
Joined: Fri Oct 02, 2020 3:33 am

Re: HELP with Android controller project

by blnkjns on Thu Dec 10, 2020 5:39 am


blnkjns
 
Posts: 194
Joined: Fri Oct 02, 2020 3:33 am

Re: HELP with Android controller project

by joaoha on Thu Dec 31, 2020 8:58 pm

Thanks guys, but what I really need help with is with the code.

I want to send these codes but I don't seem to be sending the right ones...
KEYCODE_DPAD_UP
KEYCODE_DPAD_DOWN

KEYCODE_ENTER
KEYCODE_A
KEYCODE_D
KEYCODE_E. --> Long press
KEYCODE_Q --> Long press
KEYCODE_ESCAPE --> Long press



Here is what I have tried:

#include <Arduino.h>
#include <SPI.h>
#if not defined (_VARIANT_ARDUINO_DUE_X_) && not defined(ARDUINO_ARCH_SAMD)
#include <SoftwareSerial.h>
#endif

#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "Adafruit_BluefruitLE_UART.h"

#include "BluefruitConfig.h"

// GPIO corresponding to HID keycode
int inputPins[6] = { 5 , 6 , 9 , 10 , 11 , 12 };
char const *commands[6] = { "04", "41", "81", "82", "e", "f" };

void loop(void)
{
/* scan all GPIO listed in definition
*/
if ( ble.isConnected() )
{
int activePinIndex = 0;
for(int i=0; i<6; i++)
{
// GPIO / Button is a press on ground signal
if ( digitalRead(inputPins[i]) == LOW )
// {
// keyReport.keycode[i] = inputKeycodes[i];
// activePinIndex = i;
// }else
// {
// keyReport.keycode[i] = 0;
// }

{
// Send keyboard report through BLE
ble.print("AT+BLEKEYBOARDCODE=");
ble.println(commands[i]);

}
}
}

// scaning period is 175 ms
delay(175);
}

joaoha
 
Posts: 3
Joined: Tue Dec 08, 2020 8:37 pm

Please be positive and constructive with your questions and comments.