Closed garbear closed 7 years ago
Thanks for this great guide. Started work in https://github.com/fetzerch/xbmc/tree/retroplayer-17beta4 and https://github.com/fetzerch/game.libretro.scummvm/tree/mouse.
closed by https://github.com/garbear/xbmc/pull/67
I'll outline mouse support for anyone who would like to work on this, I know @fetzerch was interested.
Mouse support is fully implemented in game.libretro. The libretro API requests mouse input via
RETRO_DEVICE_ID_MOUSE_X/Y
here. This reads mouse data; the data is written by the Game API eventGAME_INPUT_EVENT_RELATIVE_POINTER
here. The challenge is to implement this mouse event in Kodi.Fortunately, a solution exists in the form of keyboard input. 99% of mouse implementation will be copying keyboard code. I'll start at the
GAME_INPUT_EVENT_KEY
event here and work backwards to see what we need for mouse input.The
GAME_INPUT_EVENT_KEY
is generated byCGameClientKeyboard
here. This means we need aCGameClientMouse
class.CGameClientKeyboard implements the
KEYBOARD::IKeyboardHandler
interface atxbmc/input/keyboard/IKeyboardHandler.h
interface. Similarly, we'll need to create aMOUSE::IMouseHandler
interface atxbmc/input/mouse/IMouseHandler.h
. Count yourself lucky - not everyone gets to create a new source code folder in Kodi :wink:When a game is opened, if
<supports_keyboard>
is true, thenCGameClient::OpenKeyboard()
is called. We need a<supports_mouse>
parameter and a correspondingCGameClient::OpenMouse()
function.When
OpenKeyboard()
is called, the keyboard handler is created and registers itself viaCInputManager::RegisterKeyboardHandler()
here. We need aCInputManager::RegisterMouseHandler()
function and a vector to store mouse handlers.100% of key presses pass through
CInputManager::OnKey()
here. We need to find a location where all mouse events pass (hint:CInputManager::ProcessMouse()
). Then, similar to key presses, if a registered mouse handler returns true, we prevent the input from reaching Kodi.And that's basically it. Keyboard input required some refactoring (#6779), so expect CInputManager to need some refactoring for mouse hooking as well. This will probably be the most difficult part, as everything else is very straight-forward.