Closed fetzerch closed 7 years ago
I've rethought our approach. Let's create mice controller profiles that can be mapped in the controller dialog.
Then we add OpenMouse()
callback to the Game API similar to OpenPort()
. That way, DOS can capture both the mouse and 2 controller ports. We can add #defines for GAME_PORT_MOUSE
and GAME_PORT_KEYBOARD
to identify if it is mouse, joystick or keyboard input.
Don't add OpenMouse() to the game API, i realized that mouse support is only specified in addon.xml so we should open the mouse in CGameClient like we're doing now. But add the port #defines to detect mouse or joystick. Then you can use the port as a key in CLibretroInputDevice.
It's a little weird having a mouse in controller configuration, we should probably modify the controller dialog to be able to show only controllers or only the mouse
Mouse movement is working again (with https://github.com/fetzerch/game.libretro.scummvm/tree/mouse, and https://github.com/fetzerch/game.libretro/tree/mouse). Couldn't yet get the buttons to work. They seem to be registered in game.libretro LibretroDeviceInput and also buttons are queried by the core but they don't trigger any action it seems.
I'll do the refactoring of xbmc/input/InputManager.cpp once it's working again.
One thing I noticed also is that only the first matching controller mapping is taken into account, hence I think that the joypad is no longer functioning. Not sure if there's a quick workaround.
Btw: In case you also want to try this, just load scummvm in standalone mode. It has the ingame menu where you can use the mouse already without any games registered.
@fetzerch I sent you a fix that refactors some stuff out of CInputManager
Can you link your PR description to all the other open PRs that have to do with mouse support? xbmc, game.libretro, game.libretro.scummvm, kodi-game-controllers... I think we're up to 4 repos now.
sure, Updated PR description
Mouse button mapping doen't work (clicks are ignored in mapping dialog)
We can map mouse buttons the same way we map keyboard buttons. We need a layer similar to CJoystickEmulation
in xbmc/input/mouse/generic
. Then we have the mouse emulate a joystick, which will allow it to be mapped via peripheral.joystick.
We can add support for mapping mouse buttons by having CGUIConfigurationWizard::InstallHooks()
register itself as a mouse handler. We could even add support for inverting the x and y axis or rotating the coordinate system.
Guess this can also be copied to or used by the Trackball in the (Xgaming) X-Arcade Tankstick.
https://shop.xgaming.com/products/x-arcade-tankstick-trackball-usb-included
Trackball inside the X-Arcade Tankstick should really work like any PS2 or USB HID mouse.
https://github.com/kodi-game/peripheral.xarcade
Know that @garbear have a X-Arcade Tankstic but not sure if he tested the Trackball?
https://en.wikipedia.org/wiki/List_of_trackball_arcade_games
Tip is above link which lists classic trackball games, most of which works in MAME emulator.
Thanks for the links, the trackball works like a mouse so it's usable with Kodi, but the resolution is really high so it goes really slow. for it to be useful in games we might need a setting for speed gain
@garbear is it the same for mouse speed at different resolutions in all emulators or?
So on a 2160p (4K) display it might even be slower then.
Would then be nice if could set different default speed for mouse on different resolutions.
If detect a 240p display then it runs mouse at 1x speed by default. If detect a 320p display then it runs mouse at 1,5x speed by default. If detect a 480p/576p display then it runs mouse at 2x speed by default. If detect a 720p display then it runs mouse at 3x speed by default. If detect a 1080p display then it runs mouse at 4x speed by default. If detect a 2160p display then it runs mouse at 8x speed by default.
@fetzerch what's left before we merge? do you want to add support for mapping the mouse and emulating the mouse with a joystick, or merge this first and add that later?
Wanted to ask you ;) For this PR, just the MOUSE_CONTROLLER_ID. Haven't yet found a nice way of doing it. If we pass in the controller when creating creating the gameclientmouse, we could access it from there. But we need to access it also when loading the addon and have to get it from buttonmap (which is created in inputmanager).
Mouse mapping, I'd say we do separately. (Is there an option to disable it in the dialog for the moment?)
For game.libretro, we have open the thing with the port number and the logging of the libretro key.
Then for the addons it's just removing the game.controller.default. I think we don't need that explicitly now that we load the mouse controller explicitly.
For this PR, just the MOUSE_CONTROLLER_ID
I guess for now we should just copy the default controller thing, define the mouse ID in MouseWindowingButtonMap.h, add this line to GameClient.cpp:
#include "input/mouse/MouseWindowingButtonMap.h" // for MOUSE_CONTROLLER_ID
then pass the ID to CGameClientMouse.
Is there an option to disable it in the dialog for the moment?
For now we can simply not ship game.controller.mouse. Then it won't show up in the GUI, but it'll still be usable because the Kodi -> mouse translations are hardcoded in MouseWindowingButtonMap.cpp.
Updated. If we don't ship the addon, it'll not work because in OpenMouse we need to call UpdatePort so that game.libretro gets informed.
Let me know if you want me to squash the changes
Yes, squash the changes and i'll do a review of the full patch
The changes here look good. I sent you a PR for build system fixes for xcode and autotools.
Is that it? What's left for this PR?
I'll test why buttons are not working anymore, then i'll squash both PRs and push another version.
PRs updated. dosbox and scummvm work with mouse and joystick.
Still haven't fully figured out how game.controller.kodi is supposed to come into play. but maybe we can do this independently.
you mean game.controller.mouse? it's needed for button mapping, but it's ok that it's missing now because the feature names are hardcoded in MouseWindowingButtonMap.cpp
Ready for merge across the PRs?
from my side, yes. everything tested and pushed
Adds mouse support for Emulators like ScummVM or Dosbox. Fixes #6
Related changes:
Known issues:
GAME_INPUT_PORT_MOUSE
)) (fixed by https://github.com/kodi-game/game.libretro/pull/7/commits/c62477c34cd005cdc00c275e81888f06a03eeead)