diff --git a/.idea/.name b/.idea/.name
index 52e0c37..76a3d8a 100644
--- a/.idea/.name
+++ b/.idea/.name
@@ -1 +1 @@
-UDPtest000
\ No newline at end of file
+GG
diff --git a/android/GG/.idea/.name b/android/GG/.idea/.name
index 76a3d8a..52e0c37 100644
--- a/android/GG/.idea/.name
+++ b/android/GG/.idea/.name
@@ -1 +1 @@
-GG
+UDPtest000
\ No newline at end of file
diff --git a/android/GG/app/build.gradle b/android/GG/app/build.gradle
index af41551..4156383 100644
--- a/android/GG/app/build.gradle
+++ b/android/GG/app/build.gradle
@@ -27,8 +27,8 @@ android {
}
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_15
+ targetCompatibility JavaVersion.VERSION_15
}
buildFeatures {
compose true
diff --git a/android/GG/app/src/main/AndroidManifest.xml b/android/GG/app/src/main/AndroidManifest.xml
index fcfc466..2f63f8d 100644
--- a/android/GG/app/src/main/AndroidManifest.xml
+++ b/android/GG/app/src/main/AndroidManifest.xml
@@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools">
+
+
+ android:label="@string/title_activity_main"/>
+
+
+
-
\ No newline at end of file
diff --git a/android/GG/app/src/main/java/cf/cafelutza/gg/MainActivity.java b/android/GG/app/src/main/java/cf/cafelutza/gg/MainActivity.java
index be55575..200aaaa 100644
--- a/android/GG/app/src/main/java/cf/cafelutza/gg/MainActivity.java
+++ b/android/GG/app/src/main/java/cf/cafelutza/gg/MainActivity.java
@@ -48,6 +48,9 @@ public class MainActivity extends AppCompatActivity {
l2b=findViewById(R.id.l2b);
r2b=findViewById(R.id.r2b);
+
+ UDP_Client client = MainScreen.client;
+
//frameLayout=findViewById(R.id.framelayout);
//frameLayout.addView(new TrackpadView(getBaseContext()));
@@ -55,76 +58,65 @@ public class MainActivity extends AppCompatActivity {
leftb.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|BTTN:4|BUPD:1|;";
- break;
+ client.Send("GG:1|BTTN:4|BUPD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|BTTN:4|BUPD:0|;";
+ client.Send("GG:1|BTTN:4|BUPD:0|;");
+ return true;
+ default:
+ return false;
}
- if(Client.Message!=null) {
- Client.Send();
- return true;
- }
- return false;
+
}
});
rightb.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|BTTN:1|BUPD:1|;";
- break;
+ client.Send("GG:1|BTTN:1|BUPD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|BTTN:1|BUPD:0|;";
+ client.Send("GG:1|BTTN:1|BUPD:0|;");
+ return true;
+ default:
+ return false;
}
- if(Client.Message!=null) {
- Client.Send();
- return true;
- }
- return false;
}
});
upb.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|BTTN:3|BUPD:1|;";
- break;
+ client.Send ("GG:1|BTTN:3|BUPD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|BTTN:3|BUPD:0|;";
- }
- if(Client.Message!=null) {
- Client.Send();
- return true;
+ client.Send ("GG:1|BTTN:3|BUPD:0|;");
+ return true;
+ default:
+ return false;
}
- return false;
}
});
downb.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|BTTN:0|BUPD:1|;";
- break;
+ client.Send ("GG:1|BTTN:0|BUPD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|BTTN:0|BUPD:0|;";
- }
- if(Client.Message!=null) {
- Client.Send();
- return true;
+ client.Send ( "GG:1|BTTN:0|BUPD:0|;");
+ return true;
+ default:
+ return false;
}
- return false;
}
});
@@ -138,83 +130,67 @@ public class MainActivity extends AppCompatActivity {
-
-
-
-
leftb2.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|DBTN:7|DBUD:1|;";
- break;
+ client.Send ( "GG:1|DBTN:7|DBUD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|DBTN:7|DBUD:0|;";
+ client.Send ( "GG:1|DBTN:7|DBUD:0|;");
+ return true;
+ default:
+ return false;
}
- if(Client.Message!=null) {
- Client.Send();
- return true;
- }
- return false;
}
});
rightb2.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|DBTN:3|DBUD:1|;";
- break;
+ client.Send ("GG:1|DBTN:3|DBUD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|DBTN:3|DBUD:0|;";
- }
- if(Client.Message!=null) {
- Client.Send();
- return true;
+ client.Send ("GG:1|DBTN:3|DBUD:0|;");
+ return true;
+ default:
+ return false;
}
- return false;
}
});
upb2.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|DBTN:1|DBUD:1|;";
- break;
+ client.Send ( "GG:1|DBTN:1|DBUD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|DBTN:1|DBUD:0|;";
- }
- if(Client.Message!=null) {
- Client.Send();
- return true;
+ client.Send ( "GG:1|DBTN:1|DBUD:0|;");
+ return true;
+ default:
+ return false;
}
- return false;
}
});
downb2.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
- switch(event.getAction()) {
+ switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|DBTN:5|DBUD:1|;";
- break;
+ client.Send("GG:1|DBTN:5|DBUD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|DBTN:5|DBUD:0|;";
- }
- if(Client.Message!=null) {
- Client.Send();
- return true;
+ client.Send("GG:1|DBTN:5|DBUD:0|;");
+ return true;
+ default:
+ return false;
}
- return false;
}
});
@@ -240,76 +216,67 @@ public class MainActivity extends AppCompatActivity {
l1b.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|BTTN:6|BUPD:1|;";
- break;
+ client.Send ( "GG:1|BTTN:6|BUPD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|BTTN:6|BUPD:0|;";
+ client.Send ( "GG:1|BTTN:6|BUPD:0|;");
+ return true;
+ default:
+ return false;
}
- if(Client.Message!=null) {
- Client.Send();
- return true;
- }
- return false;
}
});
r1b.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
+
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|BTTN:7|BUPD:1|;";
- break;
+ client.Send ("GG:1|BTTN:7|BUPD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|BTTN:7|BUPD:0|;";
+ client.Send ( "GG:1|BTTN:7|BUPD:0|;");
+ return true;
+ default:
+ return false;
}
- if(Client.Message!=null) {
- Client.Send();
- return true;
- }
- return false;
}
});
l2b.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
+
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|BTTN:8|BUPD:1|;";
- break;
+ client.Send ("GG:1|BTTN:8|BUPD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|BTTN:8|BUPD:0|;";
- }
- if(Client.Message!=null) {
- Client.Send();
- return true;
+ client.Send ( "GG:1|BTTN:8|BUPD:0|;");
+ return true;
+ default:
+ return false;
}
- return false;
}
});
r2b.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
+
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|BTTN:9|BUPD:1|;";
- break;
+ client.Send ("GG:1|BTTN:9|BUPD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|BTTN:9|BUPD:0|;";
- }
- if(Client.Message!=null) {
- Client.Send();
- return true;
+ client.Send ( "GG:1|BTTN:9|BUPD:0|;");
+ return true;
+ default:
+ return false;
}
- return false;
}
});
@@ -317,41 +284,36 @@ public class MainActivity extends AppCompatActivity {
select.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
+
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|BTTN:10|BUPD:1|;";
- break;
+ client.Send ( "GG:1|BTTN:10|BUPD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|BTTN:10|BUPD:0|;";
- }
- if(Client.Message!=null) {
- Client.Send();
- return true;
+ client.Send ( "GG:1|BTTN:10|BUPD:0|;");
+ return true;
+ default:
+ return false;
}
- return false;
}
});
start.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- UDP_Client Client = new UDP_Client();
+
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Client.Message = "GG:1|BTTN:11|BUPD:1|;";
- break;
+ client.Send ("GG:1|BTTN:11|BUPD:1|;");
+ return true;
case MotionEvent.ACTION_UP:
- Client.Message = "GG:1|BTTN:11|BUPD:0|;";
- }
- if(Client.Message!=null) {
- Client.Send();
- return true;
+ client.Send ("GG:1|BTTN:11|BUPD:0|;");
+ return true;
+ default:
+ return false;
}
- return false;
}
});
-
}
}
\ No newline at end of file
diff --git a/android/GG/app/src/main/java/cf/cafelutza/gg/MainScreen.java b/android/GG/app/src/main/java/cf/cafelutza/gg/MainScreen.java
index cb9ed2a..3299107 100644
--- a/android/GG/app/src/main/java/cf/cafelutza/gg/MainScreen.java
+++ b/android/GG/app/src/main/java/cf/cafelutza/gg/MainScreen.java
@@ -4,9 +4,10 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
-import android.view.MotionEvent;
import android.view.View;
+import android.widget.AdapterView;
import android.widget.Button;
+import android.widget.Spinner;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager;
@@ -15,16 +16,21 @@ import androidx.preference.PreferenceManager;
import java.util.Random;
public class MainScreen extends AppCompatActivity {
+ public static UDP_Client client = null;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mainscreen);
+ client = new UDP_Client();
Button startbutt = findViewById(R.id.startbutt);
Button settbutt = findViewById(R.id.settbutt);
Button sendbutt = findViewById(R.id.sendbutt);
+ Spinner spinner = findViewById(R.id.spinner);
+
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
+ final String[] sel = {"Default"};
String ip = pref.getString("ip", "192.168.4.1");
String port = pref.getString("port", "9696");
@@ -34,55 +40,77 @@ public class MainScreen extends AppCompatActivity {
int adminToken = Integer.parseInt(pref.getString("admintoken", "1234"));
-
-
- startbutt.setOnTouchListener(new View.OnTouchListener() {
+ spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
- public boolean onTouch(View view, MotionEvent motionEvent) {
- Intent switchActivityIntent = new Intent(MainScreen.this, MainActivity.class);
- startActivity(switchActivityIntent);
- return true;
+ public void onItemSelected(AdapterView> adapterView, View view, int i, long l) {
+ sel[0] = spinner.getSelectedItem().toString();
}
-
+ @Override
+ public void onNothingSelected(AdapterView> adapterView) {
+ sel[0] ="Default";
+ }
});
- settbutt.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View view, MotionEvent motionEvent) {
- Intent switchActivityIntent = new Intent(MainScreen.this, SettingsActivity.class);
- startActivity(switchActivityIntent);
- return true;
+
+ startbutt.setOnTouchListener((view, motionEvent) -> {
+ Intent switchActivityIntent= new Intent(MainScreen.this, MainActivity.class);
+ switch (sel[0]) {
+ case "Presentation":
+ switchActivityIntent = new Intent(MainScreen.this, PresentationActivity.class);
+ break;
+ case "Textbox":
+ switchActivityIntent = new Intent(MainScreen.this, TextboxActivity.class);
+ break;
+ case "Trackpad":
+ switchActivityIntent = new Intent(MainScreen.this, TrackpadActivity.class);
+ break;
+ case "Default":
+ switchActivityIntent = new Intent(MainScreen.this, MainActivity.class);
+ break;
+ default:
+ switchActivityIntent = new Intent(MainScreen.this, MainActivity.class);
+ break;
}
+ startActivity(switchActivityIntent);
+ return true;
});
- sendbutt.setOnTouchListener(new View.OnTouchListener() {
+ settbutt.setOnTouchListener((view, motionEvent) -> {
+ Intent switchActivityIntent = new Intent(MainScreen.this, SettingsActivity.class);
+ startActivity(switchActivityIntent);
+ return true;
+ });
- @Override
- public boolean onTouch(View view, MotionEvent motionEvent) {
- UDP_Client client = new UDP_Client();
- client.Message = "GG:1|PREF:" + String.valueOf(adminToken) + "|LCIP:" + ip + "|;";
- client.Send();
- client.Message = "GG:1|PREF:" + String.valueOf(adminToken) + "|PORT:" + port + "|;";
- client.Send();
- client.Message = "GG:1|PREF:" + String.valueOf(adminToken) + "|HIDD:" + (isHidden?"1":"0") + "|;";
- client.Send();
- client.Message = "GG:1|PREF:" + String.valueOf(adminToken) + "|SSID:" + ssid + "|;";
- client.Send();
- client.Message = "GG:1|PREF:" + String.valueOf(adminToken) + "|PASS:" + pass + "|;";
- client.Send();
-
- Random rnd = new Random(System.currentTimeMillis());
- int newtok = rnd.nextInt(100000);
- client.Message = "GG:1|PREF:" + String.valueOf(adminToken) + "|ATOK:" + String.valueOf(newtok) + "|;";
- client.Send();
- pref.edit().putString("admintoken", String.valueOf(newtok)).apply();
- Log.d("TEST ", String.valueOf(newtok));
-
-
- return true;
- }
+ sendbutt.setOnTouchListener((view, motionEvent) -> {
+ client.Send("GG:1|PREF:" + String.valueOf(adminToken) + "|LCIP:" + ip + "|;");
+
+ client.Send("GG:1|PREF:" + String.valueOf(adminToken) + "|PORT:" + port + "|;");
+
+ client.Send("GG:1|PREF:" + String.valueOf(adminToken) + "|HIDD:" + (isHidden?"1":"0") + "|;");
+
+ client.Send("GG:1|PREF:" + String.valueOf(adminToken) + "|SSID:" + ssid + "|;");
+
+ client.Send("GG:1|PREF:" + String.valueOf(adminToken) + "|PASS:" + pass + "|;");
+
+
+ Random rnd = new Random(System.currentTimeMillis());
+ int newtok = rnd.nextInt(100000);
+ client.Send("GG:1|PREF:" + String.valueOf(adminToken) + "|ATOK:" + String.valueOf(newtok) + "|;");
+
+ pref.edit().putString("admintoken", String.valueOf(newtok)).apply();
+ Log.d("TEST ", String.valueOf(newtok));
+
+
+ return true;
});
}
+
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ client.Close();
+ }
}
diff --git a/android/GG/app/src/main/java/cf/cafelutza/gg/PresentationActivity.java b/android/GG/app/src/main/java/cf/cafelutza/gg/PresentationActivity.java
new file mode 100644
index 0000000..cc0dc85
--- /dev/null
+++ b/android/GG/app/src/main/java/cf/cafelutza/gg/PresentationActivity.java
@@ -0,0 +1,73 @@
+package cf.cafelutza.gg;
+
+import static java.lang.Math.abs;
+
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.Button;
+import android.widget.ToggleButton;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
+public class PresentationActivity extends AppCompatActivity {
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_presentetion);
+
+ SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
+ Sensor gyroscope=sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
+ sensorManager.registerListener(new SensorEventListener() {
+ @Override
+ public void onSensorChanged(SensorEvent sensorEvent) {
+ if(sensorEvent.sensor.getType()==Sensor.TYPE_GYROSCOPE)
+ {
+
+ ToggleButton toggleGyro=findViewById(R.id.toggleGyro);
+ int gyroscopeX= (int) (sensorEvent.values[2]*-10);
+ int gyroscopeY= (int) (sensorEvent.values[0]*-10);
+
+ if (toggleGyro.isChecked()) {
+ if(abs(gyroscopeX)>0||abs(gyroscopeY)>0) {
+ MainScreen.client.Send("GG:1|MOUS:0|XYMS:"+gyroscopeX+"|"+gyroscopeY+"|;");
+ Log.d("GYROX:", String.valueOf(gyroscopeX));
+ }
+
+ }
+ }
+ }
+
+ @Override
+ public void onAccuracyChanged(Sensor sensor, int i) {
+
+ }
+ }, gyroscope, SensorManager.SENSOR_DELAY_FASTEST);
+
+ Button bpen=findViewById(R.id.bpen);
+ Button berase=findViewById(R.id.berase);
+ Button binapoi=findViewById(R.id.binapoi);
+ Button binainte=findViewById(R.id.binainte);
+
+ ToggleButton toggleGyro=findViewById(R.id.toggleGyro);
+
+ UDP_Client client = MainScreen.client;
+
+ bpen.setOnClickListener(view -> {
+ client.Send("GG:1|KYBD:0|KBKY:b|;");
+ });
+ berase.setOnClickListener(view -> {
+ client.Send("GG:1|KYBD:0|KBKY:e|;");
+ });
+ binapoi.setOnClickListener(view -> {
+ client.Send("GG:1|HTKY:0|HBKS:1|;");
+ });
+ binainte.setOnClickListener(view -> {
+ client.Send("GG:1|HTKY:0|HNTR:1|;");
+ });
+ }
+}
diff --git a/android/GG/app/src/main/java/cf/cafelutza/gg/TextboxActivity.java b/android/GG/app/src/main/java/cf/cafelutza/gg/TextboxActivity.java
new file mode 100644
index 0000000..968a5f7
--- /dev/null
+++ b/android/GG/app/src/main/java/cf/cafelutza/gg/TextboxActivity.java
@@ -0,0 +1,101 @@
+package cf.cafelutza.gg;
+
+import android.os.Bundle;
+import android.text.InputFilter;
+import android.text.SpannableStringBuilder;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ToggleButton;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+public class TextboxActivity extends AppCompatActivity {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.textbox_activity);
+ EditText text=findViewById(R.id.editTextText);
+ ToggleButton lctrl=findViewById(R.id.lctrl);
+ ToggleButton lshift=findViewById(R.id.lshift);
+ ToggleButton lalt=findViewById(R.id.lalt);
+ ToggleButton lgui=findViewById(R.id.lgui);
+ ToggleButton rctrl=findViewById(R.id.rctrl);
+ ToggleButton rshift=findViewById(R.id.rshift);
+ ToggleButton ralt=findViewById(R.id.ralt);
+ ToggleButton rgui=findViewById(R.id.rgui);
+ Button send=findViewById(R.id.send);
+
+ UDP_Client client = MainScreen.client;
+ text.setSingleLine(true);
+ text.setFilters(new InputFilter[]{
+ (source, start, end, spanned, i2, i3) -> {
+ if (source instanceof SpannableStringBuilder) {
+ SpannableStringBuilder sourceAsSpannableBuilder = (SpannableStringBuilder)source;
+ for (int i = end - 1; i >= start; i--) {
+ char currentChar = source.charAt(i);
+ if (!(currentChar>='!'&¤tChar<='~')) {
+ sourceAsSpannableBuilder.delete(i, i+1);
+ }
+ }
+ return source;
+ } else {
+ StringBuilder filteredStringBuilder = new StringBuilder();
+ for (int i = start; i < end; i++) {
+ char currentChar = source.charAt(i);
+ if (!(currentChar>='!'&¤tChar<='~')) {
+ filteredStringBuilder.append(currentChar);
+ }
+ }
+ return filteredStringBuilder.toString();
+ }
+ }
+ });
+/*
+ lctrl.setOnClickListener(view -> lctrl.toggle() );
+ lshift.setOnClickListener(view-> lshift.toggle());
+ lalt.setOnClickListener(view -> lalt.toggle() );
+ lgui.setOnClickListener(view -> lgui.toggle() );
+
+ rctrl.setOnClickListener(view -> rctrl.toggle() );
+ rshift.setOnClickListener(view-> rshift.toggle());
+ ralt.setOnClickListener(view -> ralt.toggle() );
+ rgui.setOnClickListener(view -> rgui.toggle() );*/
+
+ send.setOnClickListener(view -> {
+ boolean holdlctrl=lctrl.isChecked();
+ boolean holdlshift=lshift.isChecked();
+ boolean holdlalt=lalt.isChecked();
+ boolean holdlgui=lgui.isChecked();
+ boolean holdrctrl=rctrl.isChecked();
+ boolean holdrshift=rshift.isChecked();
+ boolean holdralt=ralt.isChecked();
+ boolean holdrgui=rgui.isChecked();
+ int mods=0;
+ int bits=1;
+
+ if(holdlctrl) { mods|=bits; } bits<<=1;
+ if(holdlshift) { mods|=bits; } bits<<=1;
+ if(holdlalt) { mods|=bits; } bits<<=1;
+ if(holdlgui) { mods|=bits; } bits<<=1;
+ if(holdrctrl) { mods|=bits; } bits<<=1;
+ if(holdrshift) { mods|=bits; } bits<<=1;
+ if(holdralt) { mods|=bits; } bits<<=1;
+ if(holdrgui) { mods|=bits; } bits<<=1;
+
+ client.Send("GG:1|KYBD:0|KBMD:"+mods+"|;");
+
+
+ String tosend=text.getText().toString();
+ client.Send( "GG:1|KYBD:"+tosend.length()+"|KBKS:"+tosend+"|;");
+
+// for (int i=0;i {
+ client.Send("GG:1|MBTN:4|MBUD:1|;");
+
+ client.Send("GG:1|MBTN:4|MBUD:0|;");
+
+ });
+
+ b10.setOnClickListener(view -> {
+ client.Send("GG:1|MBTN:5|MBUD:1|;");
+
+ client.Send("GG:1|MBTN:5|MBUD:0|;");
+
+ });
+
+
+ b01.setOnClickListener(view -> {
+ client.Send("GG:1|MBTN:2|MBUD:1|;");
+
+ client.Send("GG:1|MBTN:2|MBUD:0|;");
+
+ });
+
+ b02.setOnClickListener(view -> {
+ client.Send("GG:1|HTKY:0|HNTR:1|;");
+
+ });
+
+ b03.setOnClickListener(view -> {
+ client.Send("GG:1|HTKY:0|HSTB:1|;");
+
+ });
+
+ b13.setOnClickListener(view -> {
+ client.Send("GG:1|HTKY:0|HTAB:1|;");
+
+ });
+
+ b11.setOnClickListener(view -> {
+ client.Send("GG:1|MBTN:6|MBUD:1|;");
+
+ client.Send("GG:1|MBTN:6|MBUD:0|;");
+
+ });
+
+ b12.setOnClickListener(view -> {
+ client.Send("GG:1|MBTN:7|MBUD:1|;");
+
+ client.Send("GG:1|MBTN:7|MBUD:0|;");
+
+ });
+
+ b20.setOnClickListener(view -> {
+ client.Send("GG:1|HTKY:0|HCMI:1|;");
+
+ });
+
+ b21.setOnClickListener(view -> {
+ client.Send("GG:1|HTKY:0|HCPL:1|;");
+
+ });
+
+ b22.setOnClickListener(view -> {
+ client.Send("GG:1|HTKY:0|HCTW:1|;");
+
+ });
+
+ b23.setOnClickListener(view -> {
+ client.Send("GG:1|HTKY:0|HCTT:1|;");
+
+ });
+ }
+}
diff --git a/android/GG/app/src/main/java/cf/cafelutza/gg/TrackpadView.java b/android/GG/app/src/main/java/cf/cafelutza/gg/TrackpadView.java
index 506f8ea..07912de 100644
--- a/android/GG/app/src/main/java/cf/cafelutza/gg/TrackpadView.java
+++ b/android/GG/app/src/main/java/cf/cafelutza/gg/TrackpadView.java
@@ -7,6 +7,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
+import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -27,8 +28,8 @@ public class TrackpadView extends View {
private float reY = 0;
- public TrackpadView(Context c) {
- super(c);
+ public TrackpadView(Context c, AttributeSet attrs) {
+ super(c,attrs);
mPaint = new Paint();
mPaint.setAntiAlias(true);
@@ -102,11 +103,14 @@ public class TrackpadView extends View {
mY = y;
- UDP_Client Client = new UDP_Client();
int frx= (int) rx;
int fry= (int) ry;
- Client.Message = "MRX"+frx+"Y"+fry;
- Client.Send();
+
+// MainScreen.client.Send("GG:1|MOUS:0|XMUS:"+frx+"|;");
+//
+// MainScreen.client.Send("GG:1|MOUS:0|YMUS:"+fry+"|;");
+ MainScreen.client.Send("GG:1|MOUS:0|XYMS:"+frx+"|"+fry+"|;");
+
}
@@ -155,10 +159,10 @@ public class TrackpadView extends View {
int yDiff = (int) Math.abs(curr.y - start.y);
if (xDiff < CLICK && yDiff < CLICK) {
- UDP_Client Client = new UDP_Client();
- Client.Message = "CL";
- Client.Send();
+ MainScreen.client.Send("GG:1|MBTN:1|MBUD:1|;");
+ MainScreen.client.Send("GG:1|MBTN:1|MBUD:0|;");
+
}
touch_up();
diff --git a/android/GG/app/src/main/java/cf/cafelutza/gg/UDP_Client.java b/android/GG/app/src/main/java/cf/cafelutza/gg/UDP_Client.java
index bddeec1..aec481e 100644
--- a/android/GG/app/src/main/java/cf/cafelutza/gg/UDP_Client.java
+++ b/android/GG/app/src/main/java/cf/cafelutza/gg/UDP_Client.java
@@ -2,6 +2,7 @@ package cf.cafelutza.gg;
import android.annotation.SuppressLint;
import android.os.AsyncTask;
+import android.util.Log;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
@@ -13,35 +14,49 @@ public class UDP_Client {
private AsyncTask async_cient;
public String Message;
+ DatagramSocket ds = null;
+ public UDP_Client() {
+ try
+ {
+ ds = new DatagramSocket(9696);
+
+ Log.d("Port: ", String.valueOf(9696));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void Close() {
+ if (ds != null)
+ {
+ Log.d("Close: ", "ds");
+ ds.close();
+ }
+ }
+
@SuppressLint("NewApi")
- public void Send()
+ public void Send(String message)
{
new Thread(() -> {
- DatagramSocket ds = null;
- try
- {
- byte[] ipAddr = new byte[]{ (byte) 192, (byte) 168,(byte)4, (byte) 1};
- InetAddress addr = InetAddress.getByAddress(ipAddr);
- ds = new DatagramSocket(9696);
- DatagramPacket dp;
- dp = new DatagramPacket(Message.getBytes(), Message.getBytes().length, addr, 9696);
- ds.setBroadcast(true);
- ds.send(dp);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- finally
- {
- if (ds != null)
- {
- ds.close();
- }
- }
- }).start();
+ Log.d("Send: ", message);
+ try {
+ byte[] ipAddr = new byte[]{ (byte) 192, (byte) 168,(byte)4, (byte) 1};
+ InetAddress addr = InetAddress.getByAddress(ipAddr);
+ DatagramPacket dp;
+ dp = new DatagramPacket(message.getBytes(), message.getBytes().length, addr, 9696);
+ ds.setBroadcast(true);
+ ds.send(dp);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }).start();
+
/*
async_cient = new AsyncTask()
diff --git a/android/GG/app/src/main/res/layout/activity_mainscreen.xml b/android/GG/app/src/main/res/layout/activity_mainscreen.xml
index d549ffa..52cd419 100644
--- a/android/GG/app/src/main/res/layout/activity_mainscreen.xml
+++ b/android/GG/app/src/main/res/layout/activity_mainscreen.xml
@@ -12,54 +12,45 @@
android:layout_height="wrap_content"
android:text="Start"
app:layout_constraintBottom_toTopOf="@+id/guideline19"
- app:layout_constraintEnd_toStartOf="@+id/guideline18"
- app:layout_constraintStart_toStartOf="@+id/guideline15" />
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
-
-
-
-
-
-
+ app:layout_constraintGuide_percent=".5" />
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/settbutt" />
+
+
+
\ No newline at end of file
diff --git a/android/GG/app/src/main/res/layout/activity_presentetion.xml b/android/GG/app/src/main/res/layout/activity_presentetion.xml
new file mode 100644
index 0000000..daa8494
--- /dev/null
+++ b/android/GG/app/src/main/res/layout/activity_presentetion.xml
@@ -0,0 +1,109 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/GG/app/src/main/res/layout/textbox_activity.xml b/android/GG/app/src/main/res/layout/textbox_activity.xml
new file mode 100644
index 0000000..ed6be6b
--- /dev/null
+++ b/android/GG/app/src/main/res/layout/textbox_activity.xml
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/GG/app/src/main/res/layout/trackpad_activity.xml b/android/GG/app/src/main/res/layout/trackpad_activity.xml
new file mode 100644
index 0000000..bb11741
--- /dev/null
+++ b/android/GG/app/src/main/res/layout/trackpad_activity.xml
@@ -0,0 +1,184 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/GG/app/src/main/res/values/arrays.xml b/android/GG/app/src/main/res/values/arrays.xml
index 6cf9ed4..5e4ccb6 100644
--- a/android/GG/app/src/main/res/values/arrays.xml
+++ b/android/GG/app/src/main/res/values/arrays.xml
@@ -9,4 +9,11 @@
- reply
- reply_all
+
+
+ - Default
+ - Trackpad
+ - Textbox
+ - Presentation
+
\ No newline at end of file
diff --git a/android/GG/app/src/main/res/values/refs.xml b/android/GG/app/src/main/res/values/refs.xml
new file mode 100644
index 0000000..a6b3dae
--- /dev/null
+++ b/android/GG/app/src/main/res/values/refs.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/android/GG/app/src/main/res/values/strings.xml b/android/GG/app/src/main/res/values/strings.xml
index 0343d32..9c1f64e 100644
--- a/android/GG/app/src/main/res/values/strings.xml
+++ b/android/GG/app/src/main/res/values/strings.xml
@@ -3,5 +3,7 @@
SettingsActivity
MainActivity
GG
- MainActivity2
+ TextboxActivity
+ TrackpadActivity
+ Presentation
\ No newline at end of file
diff --git a/arduino/esp32-s3/gg/gg.ino b/arduino/esp32-s3/gg/gg.ino
index f5ce221..8c1025e 100644
--- a/arduino/esp32-s3/gg/gg.ino
+++ b/arduino/esp32-s3/gg/gg.ino
@@ -33,6 +33,8 @@ const uint32_t DBTN = 3;
const uint32_t MOUS = 4;
const uint32_t MBTN = 5;
const uint32_t PREF = 6;
+const uint32_t HTKY = 7;
+const uint32_t KYBD = 8;
std::map inputTypes{
{"BTTN",BTTN},
@@ -40,7 +42,9 @@ std::map inputTypes{
{"DBTN",DBTN},
{"MOUS",MOUS},
{"MBTN",MBTN},
- {"PREF",PREF}
+ {"PREF",PREF},
+ {"HTKY",HTKY},
+ {"KYBD",KYBD}
};
const uint32_t BUPD = 1;
@@ -60,6 +64,20 @@ const uint32_t CHNL = 14;
const uint32_t CONN = 15;
const uint32_t PORT = 16;
const uint32_t ATOK = 17;
+const uint32_t HNTR = 18;
+const uint32_t HTAB = 19;
+const uint32_t HSTB = 20;
+const uint32_t HCPL = 21;
+const uint32_t HCMI = 22;
+const uint32_t HCTW = 23;
+const uint32_t HCTT = 24;
+const uint32_t KBMD = 25;
+const uint32_t KBKY = 26;
+const uint32_t KBRA = 27;
+const uint32_t XYMS = 28;
+const uint32_t XYJY = 29;
+const uint32_t KBKS = 30;
+const uint32_t HBKS = 31;
std::map inputKeys{
@@ -79,7 +97,21 @@ std::map inputKeys{
{"CHNL",CHNL},
{"CONN",CONN},
{"PORT",PORT},
- {"ATOK",ATOK}
+ {"ATOK",ATOK},
+ {"HNTR",HNTR},
+ {"HTAB",HTAB},
+ {"HSTB",HSTB},
+ {"HCPL",HCPL},
+ {"HCMI",HCMI},
+ {"HCTW",HCTW},
+ {"HCTT",HCTT},
+ {"KBMD",KBMD},
+ {"KBKY",KBKY},
+ {"KBRA",KBRA},
+ {"XYMS",XYMS},
+ {"XYJY",XYJY},
+ {"KBKS",KBKS},
+ {"HBKS",HBKS}
};
std::map inputIDType{
@@ -99,7 +131,21 @@ std::map inputIDType{
{CHNL,PREF},
{CONN,PREF},
{PORT,PREF},
- {ATOK,PREF}
+ {ATOK,PREF},
+ {HNTR,HTKY},
+ {HTAB,HTKY},
+ {HSTB,HTKY},
+ {HCMI,HTKY},
+ {HCPL,HTKY},
+ {HCTW,HTKY},
+ {HCTT,HTKY},
+ {KBMD,KYBD},
+ {KBKY,KYBD},
+ {KBRA,KYBD},
+ {XYMS,MOUS},
+ {XYJY,JSTK},
+ {KBKS,KYBD},
+ {HBKS,HTKY}
};
@@ -216,6 +262,22 @@ bool handleYJOY(uint8_t &yvalue, uint8_t &playerID, uint32_t &inputID) {
return true; //no err
}
+bool handleXYJY(uint8_t &yvalue, uint8_t &xvalue, uint8_t &playerID, uint32_t &inputID) {
+ switch (inputID) {
+ case 1: //left
+ Gamepad.leftStick(xvalue, yvalue);
+ oldxvaluel=xvalue;
+ oldyvaluel=yvalue;
+ break;
+ case 2: //right
+ Gamepad.rightStick(xvalue, yvalue);
+ oldxvaluer=xvalue;
+ oldyvaluer=yvalue;
+ break;
+ }
+ return true; //no err
+}
+
bool parseJSTK(String &cmd, uint8_t &playerID) {
if(cmd.length()<=9) {
Serial.print("inputID not detected");
@@ -275,6 +337,24 @@ bool parseJSTK(String &cmd, uint8_t &playerID) {
uint8_t yvalue = uint8_t(cmd.substring(inputID_end+1+4+1,yvalue_end).toInt());
return handleYJOY(yvalue, playerID, inputID);
} break;
+ case XYJY:
+ {
+ int xvalue_end=cmd.indexOf('|',inputID_end+1+4);
+ if(xvalue_end==-1) {
+ Serial.print("Error getting xvalue");
+ Serial.println();
+ return false;
+ }
+ uint8_t xvalue = uint8_t(cmd.substring(inputID_end+1+4+1,xvalue_end).toInt());
+ int yvalue_end=cmd.indexOf('|',xvalue_end+1);
+ if(yvalue_end==-1) {
+ Serial.print("Error getting yvalue");
+ Serial.println();
+ return false;
+ }
+ uint8_t yvalue = uint8_t(cmd.substring(xvalue_end+1,yvalue_end).toInt());
+ return handleXYJY(xvalue, yvalue, playerID, inputID);
+ } break;
default:
Serial.print("Invalid key for input type ");
Serial.print("JSTK");
@@ -448,6 +528,13 @@ bool handleYMUS(uint8_t &yvalue, uint8_t &playerID, uint32_t &inputID) {
return true; //no err
}
+bool handleXYMS(uint8_t &xvalue, uint8_t &yvalue, uint8_t &playerID, uint32_t &inputID) {
+ Mouse.move(xvalue, yvalue);
+ Serial.println(xvalue);
+ Serial.println(yvalue);
+ return true; //no err
+}
+
bool parseMOUS(String &cmd, uint8_t &playerID) {
if(cmd.length()<=9) {
Serial.print("inputID not detected");
@@ -507,6 +594,24 @@ bool parseMOUS(String &cmd, uint8_t &playerID) {
uint8_t yvalue = uint8_t(cmd.substring(inputID_end+1+4+1,yvalue_end).toInt());
return handleYMUS(yvalue, playerID, inputID);
} break;
+ case XYMS:
+ {
+ int xvalue_end=cmd.indexOf('|',inputID_end+1+4);
+ if(xvalue_end==-1) {
+ Serial.print("Error getting xvalue");
+ Serial.println();
+ return false;
+ }
+ uint8_t xvalue = uint8_t(cmd.substring(inputID_end+1+4+1,xvalue_end).toInt());
+ int yvalue_end=cmd.indexOf('|',xvalue_end+1);
+ if(yvalue_end==-1) {
+ Serial.print("Error getting yvalue");
+ Serial.println();
+ return false;
+ }
+ uint8_t yvalue = uint8_t(cmd.substring(xvalue_end+1,yvalue_end).toInt());
+ return handleXYMS(xvalue, yvalue, playerID, inputID);
+ } break;
default:
Serial.print("Invalid key for input type ");
Serial.print("MOUS");
@@ -855,6 +960,264 @@ bool parsePREF(String &cmd, uint8_t &playerID) {
return true; //no err
}
+
+
+
+
+bool parseHTKY(String &cmd, uint8_t &playerID) {
+ if(cmd.length()<=9) {
+ Serial.print("inputID not detected");
+ Serial.println();
+ return false;
+ }
+ int inputID_end=cmd.indexOf('|',9);
+ if(inputID_end==-1) {
+ Serial.print("Error getting inputID");
+ Serial.println();
+ return false;
+ }
+ uint32_t inputID=uint32_t(cmd.substring(10,inputID_end).toInt());
+ if(!cansubstring(cmd, inputID_end+1, inputID_end+1+4)) {
+ Serial.print("key not detected");
+ Serial.println();
+ return false;
+ }
+ String key = cmd.substring(inputID_end+1,inputID_end+1+4);
+ auto key_it = inputKeys.find(key);
+ if(key_it == inputKeys.end()) {
+ Serial.print("Invalid key for input type ");
+ Serial.print("HTKY");
+ Serial.println(": ");
+ Serial.println(key);
+ Serial.print("Valid keys for input type ");
+ Serial.print("HTKY");
+ Serial.println(": ");
+ for(auto &el:inputKeys) {
+ if(inputIDType[el.second]==inputTypes["HTKY"]) {
+ Serial.println(el.first);
+ }
+ }
+ Serial.println();
+ return false;
+ }
+ switch(key_it->second) {
+ case HNTR:
+ {
+ Keyboard.write(KEY_RETURN);
+ return true;
+ } break;
+ case HTAB:
+ {
+ Keyboard.write(KEY_TAB);
+ return true;
+ } break;
+ case HSTB:
+ {
+ Keyboard.press(KEY_LEFT_SHIFT);
+ Keyboard.press(KEY_TAB);
+ Keyboard.releaseAll();
+ return true;
+ } break;
+ case HCMI:
+ {
+ Keyboard.press(KEY_LEFT_CTRL);
+ Keyboard.press('-');
+ Keyboard.releaseAll();
+ return true;
+ } break;
+ case HCPL:
+ {
+ Keyboard.press(KEY_LEFT_CTRL);
+ Keyboard.press('+');
+ Keyboard.releaseAll();
+ return true;
+ } break;
+ case HCTT:
+ {
+ Keyboard.press(KEY_LEFT_CTRL);
+ Keyboard.press('t');
+ Keyboard.releaseAll();
+ return true;
+ } break;
+ case HCTW:
+ {
+ Keyboard.press(KEY_LEFT_CTRL);
+ Keyboard.press('w');
+ Keyboard.releaseAll();
+ return true;
+ } break;
+ case HBKS:
+ {
+ Keyboard.write(KEY_BACKSPACE);
+ return true;
+ } break;
+ default:
+ {
+ Serial.print("Invalid key for input type ");
+ Serial.print("HTKY");
+ Serial.println(": ");
+ Serial.println(key);
+ Serial.print("Valid keys for input type ");
+ Serial.print("HTKY");
+ Serial.println(": ");
+ for(auto &el:inputKeys) {
+ if(inputIDType[el.second]==inputTypes["HTKY"]) {
+ Serial.println(el.first);
+ }
+ }
+ Serial.println();
+ return false;
+ } break;
+ }
+ return true; //no err
+}
+
+
+
+void uint8_t_to_bools(uint8_t x, bool &_0, bool &_1, bool &_2, bool &_3, bool &_4, bool &_5, bool &_6, bool &_7) {
+ _0=x&1; x>>=1;
+ _1=x&1; x>>=1;
+ _2=x&1; x>>=1;
+ _3=x&1; x>>=1;
+ _4=x&1; x>>=1;
+ _5=x&1; x>>=1;
+ _6=x&1; x>>=1;
+ _7=x&1; x>>=1;
+}
+
+bool handleKBMD(uint8_t &mods, uint8_t &playerID, uint32_t &inputID) {
+ bool lctrl=false;
+ bool lshift=false;
+ bool lalt=false;
+ bool lgui=false;
+ bool rctrl=false;
+ bool rshift=false;
+ bool ralt=false;
+ bool rgui=false;
+ uint8_t_to_bools(mods, lctrl, lshift, lalt, lgui, rctrl, rshift, ralt, rgui);
+ if(lctrl) { Keyboard.press(KEY_LEFT_CTRL); }
+ if(lshift) { Keyboard.press(KEY_LEFT_SHIFT); }
+ if(lalt) { Keyboard.press(KEY_LEFT_ALT); }
+ if(lgui) { Keyboard.press(KEY_LEFT_GUI); }
+ if(rctrl) { Keyboard.press(KEY_RIGHT_CTRL); }
+ if(rshift) { Keyboard.press(KEY_RIGHT_SHIFT); }
+ if(ralt) { Keyboard.press(KEY_RIGHT_ALT); }
+ if(rgui) { Keyboard.press(KEY_RIGHT_GUI); }
+ return true; //no err
+}
+
+bool handleKBKY(char &key, uint8_t &playerID, uint32_t &inputID) {
+ Keyboard.write(key);
+ return true; //no err
+}
+
+bool handleKBKS(String &keys, uint8_t &playerID, uint32_t &inputID) {
+ if(keys.length()!=inputID) {
+ Serial.println("\""+keys+"\".length()!="+inputID);
+ return false;
+ }
+ Keyboard.print(keys);
+ return true; //no err
+}
+
+bool parseKYBD(String &cmd, uint8_t &playerID) {
+ if(cmd.length()<=9) {
+ Serial.print("inputID not detected");
+ Serial.println();
+ return false;
+ }
+ int inputID_end=cmd.indexOf('|',9);
+ if(inputID_end==-1) {
+ Serial.print("Error getting inputID");
+ Serial.println();
+ return false;
+ }
+ uint32_t inputID=uint32_t(cmd.substring(10,inputID_end).toInt());
+ if(!cansubstring(cmd, inputID_end+1, inputID_end+1+4)) {
+ Serial.print("key not detected");
+ Serial.println();
+ return false;
+ }
+ String key = cmd.substring(inputID_end+1,inputID_end+1+4);
+ auto key_it = inputKeys.find(key);
+ if(key_it == inputKeys.end()) {
+ Serial.print("Invalid key for input type ");
+ Serial.print("KYBD");
+ Serial.println(": ");
+ Serial.println(key);
+ Serial.print("Valid keys for input type ");
+ Serial.print("KYBD");
+ Serial.println(": ");
+ for(auto &el:inputKeys) {
+ if(inputIDType[el.second]==inputTypes["KYBD"]) {
+ Serial.println(el.first);
+ }
+ }
+ Serial.println();
+ return false;
+ }
+ switch(key_it->second) {
+ case KBMD:
+ {
+ int mods_end=cmd.indexOf('|',inputID_end+1+4);
+ if(mods_end==-1) {
+ Serial.print("Error getting mods");
+ Serial.println();
+ return false;
+ }
+ uint8_t mods = uint8_t(cmd.substring(inputID_end+1+4+1,mods_end).toInt());
+ return handleKBMD(mods, playerID, inputID);
+ } break;
+ case KBKY:
+ {
+ if(cmd.length()<=inputID_end+1+4+1) {
+ Serial.print("key not detected");
+ Serial.println();
+ return false;
+ }
+ char key=cmd[inputID_end+1+4+1];
+ return handleKBKY(key, playerID, inputID);
+ } break;
+ case KBRA:
+ {
+ Keyboard.releaseAll();
+ } break;
+ case KBKS:
+ {
+ int keys_end=cmd.lastIndexOf('|');
+ if(keys_end==-1) {
+ Serial.print("Error getting keys");
+ Serial.println();
+ return false;
+ }
+ String keys = cmd.substring(inputID_end+1+4+1,keys_end);
+ return handleKBKS(keys, playerID, inputID);
+ } break;
+ default:
+ {
+ Serial.print("Invalid key for input type ");
+ Serial.print("KYBD");
+ Serial.println(": ");
+ Serial.println(key);
+ Serial.print("Valid keys for input type ");
+ Serial.print("KYBD");
+ Serial.println(": ");
+ for(auto &el:inputKeys) {
+ if(inputIDType[el.second]==inputTypes["KYBD"]) {
+ Serial.println(el.first);
+ }
+ }
+ Serial.println();
+ return false;
+ } break;
+ }
+ return true; //no err
+}
+
+
+
+
+
void parseinit(String &cmd) {
if(cmd.length()<20) {
Serial.print("Invalid command length: ");
@@ -916,6 +1279,12 @@ void parseinit(String &cmd) {
ESP.restart();
}
break;
+ case HTKY:
+ parseHTKY(cmd, playerID);
+ break;
+ case KYBD:
+ parseKYBD(cmd, playerID);
+ break;
}
return;
}