android-keyboard-gadget icon indicating copy to clipboard operation
android-keyboard-gadget copied to clipboard

Clone USB Keyboard App to Android Studio

Open luke-par opened this issue 6 years ago • 9 comments

Hello, I would like to load the source code of the USB Keyboard app into Android Studio(Windows). I have cloned the git repository (https://github.com/pelya/commandergenius.git), but the app cannot be compiled. (Compilation button greyed out). Unfortunately I haven't used Git yet and I'm not familiar with it.

Can you help me?

Thanks for your help in advance.

luke-par avatar Apr 15 '18 17:04 luke-par

That would be very complicated. The app itself is written in C++ and won't compile on Windows.

On Sun, 15 Apr 2018 20:19 peter-k1997 [email protected] wrote:

Hello, I would like to load the source code of the USB Keyboard app into Android Studio(Windows). I have cloned the git repository ( https://github.com/pelya/commandergenius.git), but the app cannot be compiled. (Compilation button greyed out). Unfortunately I haven't used Git yet and I'm not familiar with it.

Can you help me?

Thanks for your help in advance.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pelya/android-keyboard-gadget/issues/134, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJewL5Ea47UQc-EDvbm7fFa7M6OlHcrks5to4EygaJpZM4TVj9r .

pelya avatar Apr 15 '18 17:04 pelya

Thanks for your quick answer.

Is it possible to send the commands directly to the shell (with the help of the hid-gadget-test)? I tried the following code, but unfortunately it doesn't work. But if I insert the commands in a terminal under Android it works without problems.

`import android.support.v7.app.AppCompatActivity; import android.os.Bundle;

import android.view.View; import android.widget.Button;

import java.io.IOException;

public class MainActivity extends AppCompatActivity {

Button button;

Process shellprocess;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    button = findViewById(R.id.button);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {

                shellprocess = Runtime.getRuntime().exec("su");
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                shellprocess = Runtime.getRuntime().exec("echo a | /data/local/tmp/hid-gadget-test /dev/hidg0 keyboard");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });

}

} ` Permissions: Write read/write internal and external storage

Thanks for your help.

luke-par avatar Apr 16 '18 17:04 luke-par

That would work, but you need to do 'su -c hid-gadget-test ...' because your code is creating two independent shell processes like that.

On Mon, 16 Apr 2018 20:16 peter-k1997 [email protected] wrote:

Thanks for your quick answer.

Is it possible to send the commands directly to the shell (with the help of the hid-gadget-test)? I tried the following code, but unfortunately it doesn't work. But if I insert the commands in a terminal under Android it works without problems.

`import android.support.v7.app.AppCompatActivity; import android.os.Bundle;

import android.view.View; import android.widget.Button;

import java.io.IOException;

public class MainActivity extends AppCompatActivity {

Button button;

Process shellprocess;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

button = findViewById(R.id.button);

button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        try {

            shellprocess = Runtime.getRuntime().exec("su");
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            shellprocess = Runtime.getRuntime().exec("echo a | /data/local/tmp/hid-gadget-test /dev/hidg0 keyboard");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
});

}

} `

Thanks for your help.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pelya/android-keyboard-gadget/issues/134#issuecomment-381680352, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJewFXv-gXULdrU6qfFbG9NXkU1mHCNks5tpNHvgaJpZM4TVj9r .

pelya avatar Apr 16 '18 17:04 pelya

Can you paste the full command please? Thanks

luke-par avatar Apr 16 '18 19:04 luke-par

This one should work:

echo left-shift b | su /data/local/tmp/hid-gadget-test /dev/hidg0 keyboard

On Mon, Apr 16, 2018 at 10:17 PM, peter-k1997 [email protected] wrote:

Can you paste the full command please? Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pelya/android-keyboard-gadget/issues/134#issuecomment-381717972, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJewAHOip5k_KW_jYVFFv_RPpF4k9QYks5tpO40gaJpZM4TVj9r .

pelya avatar Apr 16 '18 19:04 pelya

I got the error: Unknown id: /data/local/tmp/hid-gadget-test

luke-par avatar Apr 16 '18 19:04 luke-par

I got it. The right command is: su -c "echo left-shift b | ./data/local/tmp/hid-gadget-test /dev/hidg0 keyboard"

Thanks

luke-par avatar Apr 16 '18 19:04 luke-par

Note: on emulator the 'su' command does not accept -c argument, but I think most rooted devices have more advanced version of 'su' so your code should work okay.

On Mon, 16 Apr 2018 22:57 peter-k1997 [email protected] wrote:

I got it. The right command is: su -c "echo left-shift b | ./data/local/tmp/hid-gadget-test /dev/hidg0 keyboard"

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pelya/android-keyboard-gadget/issues/134#issuecomment-381729499, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJewGGOvmrNKAMXKr4g5bkALfV7SXsRks5tpPe5gaJpZM4TVj9r .

pelya avatar Apr 16 '18 20:04 pelya

Also check out https://github.com/draguve/droidducky-app

thehappydinoa avatar Feb 03 '19 06:02 thehappydinoa