/* PokeMini - Pokémon-Mini Emulator Copyright (C) 2009-2015 JustBurn This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include "SDL.h" #include "PokeMini.h" #include "PokeMini_Debug.h" #include "Hardware_Debug.h" #include "InputWindow.h" #include "PokeMiniIcon_96x128.h" #include "InstructionProc.h" #include "InstructionInfo.h" #include #include "GtkXDialogs.h" #include "SGtkXDrawingView.h" #include "Joystick.h" #include "Keyboard.h" #include "KeybMapSDL.h" int InputWindow_InConfigs = 0; GtkWindow *InputWindow; static GtkScrolledWindow *InputSW; static GtkBox *VBox1; static GtkNotebook *NBook; static GtkTable *KTable; static GtkLabel *KLabelK[10]; static GtkComboBox *KComboA[10]; static GtkComboBox *KComboB[10]; static GtkBox *JVBox; static GtkTable *JTable; static GtkToggleButton *JEnabled; static GtkComboBox *JJoyID; static GtkToggleButton *JAxisAsDPad; static GtkToggleButton *JHatsAsDPad; static GtkLabel *JLabelJ[10]; static GtkComboBox *JCombo[10]; static GtkButtonBox *HButtonBox; static GtkButton *ButtonApply; static GtkButton *ButtonRestore; static GtkButton *ButtonDefaults; static GtkButton *ButtonClose; // ----------------- // Widgets callbacks // ----------------- static gint InputWindow_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) { gtk_widget_hide(GTK_WIDGET(InputWindow)); return TRUE; } static void InputWindow_ButtonApply_clicked(GtkWidget *widget, gpointer data) { int i, newdevice = 0; if (CommandLine.joyid != gtk_combo_box_get_active(JJoyID)) newdevice = 1; // Joystick configs CommandLine.joyenabled = gtk_toggle_button_get_active(JEnabled) ? 1 : 0; CommandLine.joyid = gtk_combo_box_get_active(JJoyID); CommandLine.joyaxis_dpad = gtk_toggle_button_get_active(JAxisAsDPad) ? 1 : 0; CommandLine.joyhats_dpad = gtk_toggle_button_get_active(JHatsAsDPad) ? 1 : 0; // Keyboard / Joystick buttons mapping for (i=0; i<10; i++) { CommandLine.keyb_a[i] = gtk_combo_box_get_active(KComboA[i]); CommandLine.keyb_b[i] = gtk_combo_box_get_active(KComboB[i]); CommandLine.joybutton[i] = gtk_combo_box_get_active(JCombo[i]); } if (newdevice) reopenjoystick(); KeyboardRemap(&KeybMapSDL); } static void InputWindow_ButtonRestore_clicked(GtkWidget *widget, gpointer data) { InputWindow_UpdateConfigs(); } static void InputWindow_ButtonDefaults_clicked(GtkWidget *widget, gpointer data) { // This definitions were taken from "CommandLine.c": CommandLine.joyaxis_dpad = 1; // Joystick Axis as DPad CommandLine.joyhats_dpad = 1; // Joystick Hats as DPad // Joystick mapping CommandLine.joybutton[0] = 8; // Menu: Button 8 CommandLine.joybutton[1] = 1; // A: Button 1 CommandLine.joybutton[2] = 2; // B: Button 2 CommandLine.joybutton[3] = 7; // C: Button 7 CommandLine.joybutton[4] = 10; // Up: Button 10 CommandLine.joybutton[5] = 11; // Down: Button 11 CommandLine.joybutton[6] = 4; // Left: Button 4 CommandLine.joybutton[7] = 5; // Right: Button 5 CommandLine.joybutton[8] = 9; // Power: Button 9 CommandLine.joybutton[9] = 6; // Shake: Button 6 // Keyboard mapping (Magic numbers!) CommandLine.keyb_a[0] = PMKEYB_ESCAPE; // Menu: ESCAPE CommandLine.keyb_a[1] = PMKEYB_X; // A: X CommandLine.keyb_a[2] = PMKEYB_Z; // B: Z CommandLine.keyb_a[3] = PMKEYB_C; // C: C CommandLine.keyb_a[4] = PMKEYB_UP; // Up: UP CommandLine.keyb_a[5] = PMKEYB_DOWN; // Down: DOWN CommandLine.keyb_a[6] = PMKEYB_LEFT; // Left: LEFT CommandLine.keyb_a[7] = PMKEYB_RIGHT; // Right: RIGHT CommandLine.keyb_a[8] = PMKEYB_E; // Power: E CommandLine.keyb_a[9] = PMKEYB_A; // Shake: A // Keyboard alternative mapping (Magic numbers!) CommandLine.keyb_b[0] = PMKEYB_Q; // Menu: Q CommandLine.keyb_b[1] = PMKEYB_NONE; // A: NONE CommandLine.keyb_b[2] = PMKEYB_NONE; // B: NONE CommandLine.keyb_b[3] = PMKEYB_D; // C: D CommandLine.keyb_b[4] = PMKEYB_KP_8; // Up: KP_8 CommandLine.keyb_b[5] = PMKEYB_KP_2; // Down: KP_2 CommandLine.keyb_b[6] = PMKEYB_KP_4; // Left: KP_4 CommandLine.keyb_b[7] = PMKEYB_KP_6; // Right: KP_6 CommandLine.keyb_b[8] = PMKEYB_P; // Power: P CommandLine.keyb_b[9] = PMKEYB_S; // Shake: S InputWindow_UpdateConfigs(); } static void InputWindow_ButtonClose_clicked(GtkWidget *widget, gpointer data) { gtk_widget_hide(GTK_WIDGET(InputWindow)); } // ------------ // Input Window // ------------ static void LoadKeybsymOnCombo(GtkComboBox *combo) { int i; for (i=0; i