Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added topology.xml and buttonmap.xml #5

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

Heckie75
Copy link
Contributor

Added topogogy.xml and buttonmap.xml especially in order to make special keys like start, select and option work. See also #4

@garbear

@garbear
Copy link
Member

garbear commented Jul 13, 2023

Nice!

The XML is meant to represent the "source of truth" of the cpp. This is because libretro doesn't have as extensive or consistent of an input API, so we have to extract a lot of the data by hand.

In this case, the source is:

First, lets find the device map in the source. It is:

https://github.com/libretro/libretro-atari800/blob/master/libretro/libretro-core.c#L26-L27

#define RETRO_DEVICE_ATARI_KEYBOARD RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_KEYBOARD, 0)
#define RETRO_DEVICE_ATARI_JOYSTICK RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)

This uses libretro's fundamental device abstraction. See https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h#L86-L102.

So the buttonmap should be:

<controller id="game.controller.atari.2600" type="RETRO_DEVICE_JOYPAD" subclass="1">
<controller id="game.controller.keyboard" type="RETRO_DEVICE_KEYBOARD" subclass="0">

Then the topology. There are four ports:

https://github.com/libretro/libretro-atari800/blob/master/libretro/libretro-core.c#L104-L110

    static const struct retro_controller_info ports[] = {
      { p1_controllers, 2  }, // port 1
      { p2_controllers, 2  }, // port 2
      { p3_controllers, 2  }, // port 3
      { p4_controllers, 2  }, // port 4
      { NULL, 0 }
    };

so topology.xml should have ports "3" and "4".

The rest of the buttonmap is a little harder. The mapping is here:

https://github.com/libretro/libretro-atari800/blob/master/libretro/core-mapper.c#L407

for (i = 0; i < (RETRO_DEVICE_ID_JOYPAD_R3+1); i++)

It scans for every button on the retropad. So the buttonmap should have entries for all 16 buttons:

https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h#L188-L203

#define RETRO_DEVICE_ID_JOYPAD_B        0
#define RETRO_DEVICE_ID_JOYPAD_Y        1
#define RETRO_DEVICE_ID_JOYPAD_SELECT   2
#define RETRO_DEVICE_ID_JOYPAD_START    3
#define RETRO_DEVICE_ID_JOYPAD_UP       4
#define RETRO_DEVICE_ID_JOYPAD_DOWN     5
#define RETRO_DEVICE_ID_JOYPAD_LEFT     6
#define RETRO_DEVICE_ID_JOYPAD_RIGHT    7
#define RETRO_DEVICE_ID_JOYPAD_A        8
#define RETRO_DEVICE_ID_JOYPAD_X        9
#define RETRO_DEVICE_ID_JOYPAD_L       10
#define RETRO_DEVICE_ID_JOYPAD_R       11
#define RETRO_DEVICE_ID_JOYPAD_L2      12
#define RETRO_DEVICE_ID_JOYPAD_R2      13
#define RETRO_DEVICE_ID_JOYPAD_L3      14
#define RETRO_DEVICE_ID_JOYPAD_R3      15

The lower-case part of the buttonmap is the "feature name" found in the controller topology project:

https://github.com/kodi-game/controller-topology-project/blob/master/addons/game.controller.atari.2600/resources/layout.xml

Those entries should be matched up in buttonmap.xml. If not everything fits, then game.controller.atari.2600 should be extended, or a new controller add-on introduced.

Note that the emulator uses the analog sticks too, so those could be mapped as well:

https://github.com/libretro/libretro-atari800/blob/master/libretro/core-mapper.c#L437-L439

//emulate Joy1 with joy analog right 
ar[0][0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X));
ar[0][1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y));

Also, you could add mouse support:

https://github.com/libretro/libretro-atari800/blob/master/libretro/core-mapper.c#L514C5-L521C5

mouse_wu   = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELUP);
mouse_wd   = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELDOWN);
mouse_x    = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
mouse_y    = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
mouse_l    = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
mouse_r    = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT);

@garbear garbear self-requested a review July 13, 2023 02:34
@garbear garbear self-assigned this Jul 13, 2023
@Heckie75
Copy link
Contributor Author

@garbear I have made some changes. I changed to game.controller.default in order to be able to map all buttons. Now it is possible to use start , select buttons, option button and also others in order to open a menu, a virtual keyboard etc.

However, I haven't figured out how to map the analog stick.

In addition I', not sure about the mouse, especially RETRO_DEVICE_ID_MOUSE_X, RETRO_DEVICE_ID_MOUSE_Y and the missing pointer. I have no idea how to test it.

@garbear
Copy link
Member

garbear commented Jan 29, 2024

@Heckie75 I found another user trying to get Atari 800 working: https://forum.kodi.tv/showthread.php?tid=376031

We need controller profiles for atari 800 and atari 5200 controllers. Can you link my any pictures or documentation of these? I've never actually used either.

@Heckie75
Copy link
Contributor Author

@garbear I pushed this merge request with bottonmap and topoloy months ago. Both work for me. Why hasn't it been merged yet?

@garbear garbear merged commit 1fb79f0 into kodi-game:master Jan 29, 2024
@garbear
Copy link
Member

garbear commented Jan 29, 2024

It would be nice if we had atari 800/5200 controllers instead of using game.default, but this fixes input, so I'll merge and we can improve later.

@Heckie75 Heckie75 deleted the buttonmap branch January 29, 2024 19:54
@garbear
Copy link
Member

garbear commented Jan 30, 2024

Sorry it took so long to merge, totally forgot about this one until the forum atari800 user popped up and I rediscovered this.

For future reference, I made the following changes (be0c949):

  • Added newlines to files (this makes IDEs happy)
  • Moved keyboard and mouse to beginning of topology for coniistency with other cores
  • Added controller IDs to <requires> tag in addon.xml.in

I'll do a release of atari800 so this change will go out on the mirrors.

EDIT: Version 3.1.0.33 has the buttonmaps.

@garbear
Copy link
Member

garbear commented Jan 30, 2024

@Heckie75 The forum user and I are working on Atari 800 controller profiles so the user can see the historic controller in the GUI attached to the Atari 800 instead of an anachronistic xbox controller: https://forum.kodi.tv/showthread.php?tid=376031&pid=3182024#pid3182024

Once we create the profiles would you be able to update the XML here to use the atari controllers?

@garbear
Copy link
Member

garbear commented May 5, 2024

I got swamped with work and travel the last 3 months, but I'm now pushing out the best of our work so far to production servers. Testing will be possible on all platforms.

New tracking issue here: kodi-game/controller-topology-project#303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants