bobbydilley / lindbergh-loader

A SEGA Lindbergh Emulator for Linux.
50 stars 6 forks source link

Add keymap configuration & init.bash #13

Closed Caviar-X closed 10 months ago

Caviar-X commented 10 months ago

button configurations aren't available now,weird because the Trigger and reload button are changed to some unexpected value after first MyAppGarbageCollection happened.I've ensured that all the keymaps were only from config's references and pointers.

Sorry for my bad coding level and garbage English(been writing Rust for two years), if I broke anything please tell me, I'll try my best to fix it.

Also,can I ask why all the cursor apis were blocked?

Caviar-X commented 10 months ago

Also I formatted everything with clang-format,I'm sorry if it breaks anything.

bobbydilley commented 10 months ago

This is awesome dude, thanks very much!

I'll reformat back to the normal, and then do a review!

Also, can I ask why all the cursor apis were blocked? Do you mean it blocking hiding the mouse? It's just so that the mouse doesn't get hidden for developing!

Caviar-X commented 10 months ago

This is awesome dude, thanks very much!

I'll reformat back to the normal, and then do a review!

Also, can I ask why all the cursor apis were blocked? Do you mean it blocking hiding the mouse? It's just so that the mouse doesn't get hidden for developing!

I set that to the editor as a default behavior. Will change that next time.

Caviar-X commented 10 months ago

...

Do you mean it blocking hiding the mouse? It's just so that the mouse doesn't get hidden for developing!

I did receive some requests like changing mouse icon and hiding mouse while gameplay from some tp players who don't want to pay for tp raver,and I tried to implement the feature but failed.

If so, I noticed that glutSetCursor and XdefineCursor are actually not working even if I use dlsym to link the "XDefineCursor" on WSL (and XDefineCursor returns 1 wtf) (glutSetCursor in fact relies on XDefineCursor)

dkeruza-neo commented 10 months ago

...

Do you mean it blocking hiding the mouse? It's just so that the mouse doesn't get hidden for developing!

I did receive some requests like changing mouse icon and hiding mouse while gameplay from some tp players who don't want to pay for tp raver,and I tried to implement the feature but failed.

If so, I noticed that glutSetCursor and XdefineCursor are actually not working even if I use dlsym to link the "XDefineCursor" on WSL (and XDefineCursor returns 1 wtf) (glutSetCursor in fact relies on XDefineCursor)

Did you check that the hooks are working? I can look at the elf to see what function is used by the game. What game are you trying to hide the cursor?

Caviar-X commented 10 months ago

... Did you check that the hooks are working? I can look at the elf to see what function is used by the game. What game are you trying to hide the cursor?

The game is HOTD4. I didn't check the hooks,how can I check it?

dkeruza-neo commented 10 months ago

Where you added the function you want to hoot to like for instance glutSetCursor just call a printf to see if the hook is reached.

On Fri, Jan 26, 2024, 7:23 PM AutoBank @.***> wrote:

... Did you check that the hooks are working? I can look at the elf to see what function is used by the game. What game are you trying to hide the cursor?

The game is HOTD4. I didn't check the hooks,how can I check it?

— Reply to this email directly, view it on GitHub https://github.com/bobbydilley/lindbergh-loader/pull/13#issuecomment-1912863565, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7TJXSF7GPO6NXZRFPFOFDYQRCHHAVCNFSM6AAAAABCKME6DGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJSHA3DGNJWGU . You are receiving this because you commented.Message ID: @.***>

Caviar-X commented 10 months ago

... Where you added the function you want to hoot to like for instance glutSetCursor just call a printf to see if the hook is reached. Oh you mean this,I did this,but I call the XdefineCursor instead. I tried to set the cursor by modify the property arg in XCreateWindow.And XdefineCursor was called and returns 1. But the cursor still exist.

bobbydilley commented 10 months ago

Worth noting here that we need to consider scope of the project.

The first goal is to create a replacement system for physical machines, not to create an emulator for people who don't want to pay for the TP project.

I agree that hiding the mouse cursor seems resonable as you'd want that on the real machine, and updating keyboard controls is super useful for when we're trying to play it on our computers for testing - but I don't think we should support custom crosshairs at this stage.

Happy for this to happen at a later date, but want to make sure all the games work nicely and the code is well refactored before we add in things like crosshair image pulling etc.

bobbydilley commented 10 months ago

Hey, so I've had a look and I really like the work you've done, just finding it hard to format it back to how it was as your formatter has made some changes that my formatter won't undo, and I don't really want to ruin the git history.

If you're happy I'll manually pick your code in, only issue is that you won't have contributed it - so maybe you can make the edit to the readme in a seperate MR afterwards so your name is on the project + in the git history?

Main things I'd like to add:

typedef struct
{
  unsigned int service;
  unsigned int start;
  unsigned int coin;
  unsigned int up;
  unsigned int down;
  unsigned int left;
  unsigned int right;
  unsigned int button1;
  unsigned int button2;
  unsigned int button3;
  unsigned int button4;
} PlayerKeyMapping;

// All keycode can be found using `xev` binary's debug output
typedef struct
{
  unsigned int test;
  PlayerKeyMapping player1;
  PlayerKeyMapping player2;
} KeyMapping;

Updating your struct to properly have 2 players.

# Configure the keymap using `xev`
TEST_KEY                28
PLAYER_1_START_KEY      10
PLAYER_1_SERVICE_KEY    39
PLAYER_1_COIN_KEY       14
PLAYER_1_UP_KEY         111
PLAYER_1_DOWN_KEY       116
PLAYER_1_LEFT_KEY       113
PLAYER_1_RIGHT_KEY      114
PLAYER_1_BUTTON_1_KEY   24
PLAYER_1_BUTTON_2_KEY   25
PLAYER_1_BUTTON_3_KEY   26
PLAYER_1_BUTTON_4_KEY   27

Simplying the config values a bit - I think instead of having the seperate values here, when we do a driving game we just use UP, DOWN, LEFT, RIGHT for steering input and change the view change to use buttons 1, 2, 3, 4.

It's likely that we'll want to add another input subsystem later on so you can use lightguns and steering wheel type controllers which this won't support well, so I think leaving this as a simple debug controller interface would be good enough!

Let me know what you think.

Caviar-X commented 10 months ago

That's great! thx for your fixing ( didn't think about dividing players tho)

Caviar-X commented 10 months ago

Worth noting here that we need to consider scope of the project.

The first goal is to create a replacement system for physical machines, not to create an emulator for people who don't want to pay for the TP project.

I agree that hiding the mouse cursor seems resonable as you'd want that on the real machine, and updating keyboard controls is super useful for when we're trying to play it on our computers for testing - but I don't think we should support custom crosshairs at this stage.

Happy for this to happen at a later date, but want to make sure all the games work nicely and the code is well refactored before we add in things like crosshair image pulling etc.

Well I agree this,but I'll still try to implement this on my own fork. Feel free to contact me if you think that it is time to add crosshair and etc.

Caviar-X commented 10 months ago

Also what do you think about init.bash? I think it is a great tool ( still untested on an physical ubuntu machine )