/* * xemu Input Management * * This is the main input abstraction layer for xemu, which is basically just a * wrapper around SDL2 GameController/Keyboard API to map specifically to an * Xbox gamepad and support automatic binding, hotplugging, and removal at * runtime. * * Copyright (C) 2020-2021 Matt Borgerson * * 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 2 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 . */ #ifndef XEMU_INPUT_H #define XEMU_INPUT_H #include #include #include "qemu/queue.h" #define DRIVER_DUKE "usb-xbox-gamepad" #define DRIVER_S "usb-xbox-gamepad-s" #define DRIVER_DUKE_DISPLAY_NAME "Xbox Controller" #define DRIVER_S_DISPLAY_NAME "Xbox Controller S" enum controller_state_buttons_mask { CONTROLLER_BUTTON_A = (1 << 0), CONTROLLER_BUTTON_B = (1 << 1), CONTROLLER_BUTTON_X = (1 << 2), CONTROLLER_BUTTON_Y = (1 << 3), CONTROLLER_BUTTON_DPAD_LEFT = (1 << 4), CONTROLLER_BUTTON_DPAD_UP = (1 << 5), CONTROLLER_BUTTON_DPAD_RIGHT = (1 << 6), CONTROLLER_BUTTON_DPAD_DOWN = (1 << 7), CONTROLLER_BUTTON_BACK = (1 << 8), CONTROLLER_BUTTON_START = (1 << 9), CONTROLLER_BUTTON_WHITE = (1 << 10), CONTROLLER_BUTTON_BLACK = (1 << 11), CONTROLLER_BUTTON_LSTICK = (1 << 12), CONTROLLER_BUTTON_RSTICK = (1 << 13), CONTROLLER_BUTTON_GUIDE = (1 << 14), // Extension }; #define CONTROLLER_STATE_BUTTON_ID_TO_MASK(x) (1<