From 7ca11677b3826e4f169dafb86b07439537060ffb Mon Sep 17 00:00:00 2001
From: vulonkaaz <7442677+vulonkaaz@users.noreply.github.com>
Date: Fri, 23 Aug 2024 03:16:48 +0200
Subject: initial commit
---
.gitignore | 1 +
LICENSE | 24 ++++++++++++++++++++++++
README.md | 25 +++++++++++++++++++++++++
main.c | 32 ++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+)
create mode 100644 .gitignore
create mode 100644 LICENSE
create mode 100644 README.md
create mode 100644 main.c
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9d22d8c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e073bad
--- /dev/null
+++ b/README.md
@@ -0,0 +1,25 @@
+# Hexiano to ALSA
+
+This very simple C program makes a virtual ALSA midi device from the
+Hexiano android app
+
+## How it works
+
+It listens for Hexiano logs on the android debug bridge, before using
+this program you'll have to set up the android debug bridge, once
+done you should be able to run `adb logcat` and see everything that's
+happening on your mobile device including the Hexiano events, this
+software basically launches the same command to see what's going on,
+if your command to access the logs is something else than
+`adb logcat` on your system please change the source code accordingly
+
+## How to compile
+
+`cc -o hexmidi main.c -lasound`
+
+Replace hexmidi with whatever executable name you'd like
+
+Get Hexiano here
+https://f-droid.org/en/packages/org.gitorious.jamesjrh.isokeys/
+
+(you will require an older android device to run the App)
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..cce28a1
--- /dev/null
+++ b/main.c
@@ -0,0 +1,32 @@
+#include
+#include
+#include
+#include
+
+int main() {
+ snd_rawmidi_t* midiout = NULL;
+ snd_rawmidi_open(NULL, &midiout, "virtual", 0);
+
+ char line[100];
+ int nbr = 0;
+ FILE *fp;
+ fp = popen("adb logcat", "r");
+ while (1) {
+ fgets(line, sizeof(line), fp);
+ if (memcmp(line, "D/HexKey::p",11) == 0) {
+ snd_rawmidi_write(midiout, (char[]){0x90, atoi(line+23), 100}, 3);
+ printf("play :");
+ printf(line+23);
+ }
+ if (memcmp(line, "D/HexKey::s",11) == 0) {
+ snd_rawmidi_write(midiout, (char[]){0x90, atoi(line+23), 0}, 3);
+ printf("stop :");
+ printf(line+23);
+ }
+ }
+
+ snd_rawmidi_close(midiout);
+ midiout = NULL;
+ return 0;
+}
+
--
cgit v1.2.3