]> git.sesse.net Git - pistorm/commitdiff
Add keyboard event source file setting to config-file
authorbeeanyew <beeanyew@gmail.com>
Sun, 11 Apr 2021 23:32:32 +0000 (01:32 +0200)
committerbeeanyew <beeanyew@gmail.com>
Sun, 11 Apr 2021 23:32:32 +0000 (01:32 +0200)
config_file/config_file.c
config_file/config_file.h
default.cfg
emulator.c

index 7dbd238afbdb4122566deaf2e66e801eb2db2c15..1c8ef09acc72ab1814baf7255140aba043ee200f 100644 (file)
@@ -34,6 +34,7 @@ const char *config_item_names[CONFITEM_NUM] = {
   "keyboard",
   "platform",
   "setvar",
+  "kbfile",
 };
 
 const char *mapcmd_names[MAPCMD_NUM] = {
@@ -354,9 +355,16 @@ struct emulator_config *load_config_file(char *filename) {
         break;
       case CONFITEM_KEYBOARD:
         get_next_string(parse_line, cur_cmd, &str_pos, ' ');
+        cfg->keyboard_file = (char *)calloc(1, strlen(cur_cmd) + 1);
         cfg->keyboard_toggle_key = cur_cmd[0];
         printf("Enabled keyboard event forwarding, toggle key %c.\n", cfg->keyboard_toggle_key);
         break;
+      case CONFITEM_KBFILE:
+        get_next_string(parse_line, cur_cmd, &str_pos, ' ');
+        cfg->keyboard_file = (char *)calloc(1, strlen(cur_cmd) + 1);
+        strcpy(cfg->keyboard_file, cur_cmd);
+        printf("Set keyboard event source file to %s.\n", cfg->keyboard_file);
+        break;
       case CONFITEM_PLATFORM: {
         char platform_name[128], platform_sub[128];
         memset(platform_name, 0x00, 128);
index 6880f0fcada497f7912ca1f9c3b62ee06dc2013a..37cb0ce80242149d69557491051d9f75f9c7ea0e 100644 (file)
@@ -39,6 +39,7 @@ typedef enum {
   CONFITEM_KEYBOARD,
   CONFITEM_PLATFORM,
   CONFITEM_SETVAR,
+  CONFITEM_KBFILE,
   CONFITEM_NUM,
 } config_items;
 
@@ -64,7 +65,7 @@ struct emulator_config {
 
   struct platform_config *platform;
 
-  char *mouse_file;
+  char *mouse_file, *keyboard_file;
 
   char mouse_toggle_key, keyboard_toggle_key;
   unsigned char mouse_enabled, keyboard_enabled;
index 56b55a91231b6cc5007807dc8322b5ce593aea3a..73b036391340e7c110e1683f403fcea4c7a1a736 100644 (file)
@@ -47,3 +47,7 @@ platform amiga
 #mouse /dev/input/mouse0 m
 # Forward keyboard events to host system, defaults to off unless toggle key is pressed, toggled off using F12.
 #keyboard k
+# Select a specific filename for the keyboard event source.
+# This is typically /dev/input/event1 or event0, but it may be event3 with for instance a wireless keyboard.
+# Use ls /dev/input/event* to check which event files are available and try until you find the one that works.
+#kbfile /dev/input/event1
index 214d310e7c728e1bb260624249f9fa0536d4a458..167e0141cfc56d8fda426489c6d7b36b3765a8d7 100644 (file)
@@ -458,7 +458,11 @@ int main(int argc, char *argv[]) {
     }
   }
 
-  keyboard_fd = open(keyboard_file, O_RDONLY | O_NONBLOCK);
+  if (cfg->keyboard_file)
+    keyboard_fd = open(cfg->keyboard_file, O_RDONLY | O_NONBLOCK);
+  else
+    keyboard_fd = open(keyboard_file, O_RDONLY | O_NONBLOCK);
+
   if (keyboard_fd == -1) {
     printf("Failed to open keyboard event source.\n");
   }