Advertisement
Guest User

Untitled

a guest
Nov 5th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 0.83 KB | None | 0 0
  1. // This file is part of GNOME Games. License: GPL-3.0+.
  2.  
  3. [GtkTemplate (ui = "/org/gnome/Games/ui/input-mode-switcher.ui")]
  4. private class Games.InputModeSwitcher : Gtk.Box {
  5.     private enum InputModes {
  6.         KEYBOARD_MODE,
  7.         JOYPAD_MODE
  8.     }
  9.  
  10.     private InputModes current_input_mode;
  11.  
  12.     [GtkCallback]
  13.     private void on_joypad_button_clicked () {
  14.         if (current_input_mode != InputModes.JOYPAD_MODE) {
  15.             core.set_keyboard (null);
  16.             core.set_default_controller(Retro.ControllerType.JOYPAD, core_view_joypad);
  17.         }
  18.  
  19.         current_input_mode = InputModes.JOYPAD_MODE;
  20.     }
  21.  
  22.     [GtkCallback]
  23.     private void on_keyboard_button_clicked () {
  24.         if (current_input_mode != InputModes.KEYBOARD_MODE) {
  25.             core.set_keyboard (view);
  26.             core.set_default_controller(Retro.ControllerType.JOYPAD, null);
  27.         }
  28.  
  29.         current_input_mode = InputModes.KEYBOARD_MODE;
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement