Is there a reason KOS only has one controller callback?

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
ThePerfectK
Insane DCEmu
Insane DCEmu
Posts: 147
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Thu Apr 27, 2006 10:15 am
Has thanked: 27 times
Been thanked: 35 times

Is there a reason KOS only has one controller callback?

Post by ThePerfectK »

It's a relatively simple fix to add multiple callbacks for multiple controllers in KOS. I use the controller callback as an easy way to define the reboot macro and change what it does depending on screen (i.e. in-game it reboots to title screen, but at titlescreen, it reboots the entire system). Only problem is that there is only one single callback caller defined in controller.c. in retail dreamcast games, usually all 4 controllers can access the reboot macro. I changed controller.c to include 4 callbacks, which can be assigned to each controller, but the problem is making said code portable and expecting others to modify their KOS source the same way.

Is there a reason why there is only one callback defined that I don't see? If not, would it be possible to suggest my changes be rolled into a future revision?
Still Thinking!~~
User avatar
Protofall
DCEmu Freak
DCEmu Freak
Posts: 78
Joined: Sun Jan 14, 2018 8:03 pm
Location: Emu land
Has thanked: 21 times
Been thanked: 18 times
Contact:

Re: Is there a reason KOS only has one controller callback?

Post by Protofall »

I came across this callback function when I started learning about the input. I remember BC saying its only really for rebooting/terminating a program early. I don't think its for going from in-game to title-screen like you do there, I didn't even think that kind of action was possible with the callback.
Moving Day: A clone of Dr Mario with 8-player support <https://dcemulation.org/phpBB/viewtopic ... 4&t=105389>
A recreation of Minesweeper for the Dreamcast <viewtopic.php?f=34&t=104820>

Twitter <https://twitter.com/ProfessorToffal>
YouTube (Not much there, but there are a few things) <https://www.youtube.com/user/TrueMenfa>
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Is there a reason KOS only has one controller callback?

Post by BlueCrab »

If you're looking to set up a exit to menu callback for all controllers like commercial games do, just set the addr parameter to 0.
User avatar
ThePerfectK
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Apr 27, 2006 10:15 am
Has thanked: 27 times
Been thanked: 35 times

Re: Is there a reason KOS only has one controller callback?

Post by ThePerfectK »

BlueCrab wrote: Fri Nov 15, 2019 12:57 pm If you're looking to set up a exit to menu callback for all controllers like commercial games do, just set the addr parameter to 0.
I'd like to be able to set unique chords for each controller, though. Example, I have made some changes to controller.h so that each controller has its own unique callback, for instances e.g. Where one controller is a dreamcast pad and the other is a Sega saturn controller or arcade stick or twin stick. Right now, with my small change, the DC reboot sequence is a+b+x+y+start, while an arcade stick or saturn controller is a+b+c+start. The only way I found I could pull that off is if each controller has its own independent callback chord. Is there an alternative way to accomplish that?
Still Thinking!~~
User avatar
ThePerfectK
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Apr 27, 2006 10:15 am
Has thanked: 27 times
Been thanked: 35 times

Re: Is there a reason KOS only has one controller callback?

Post by ThePerfectK »

Protofall wrote: Thu Nov 14, 2019 11:42 pm I came across this callback function when I started learning about the input. I remember BC saying its only really for rebooting/terminating a program early. I don't think its for going from in-game to title-screen like you do there, I didn't even think that kind of action was possible with the callback.
You can make your own controller callback function pointer and pass it to the callback mechanism actually. That's why I like using this method for certain actions, with multiple callbacks for each controller I can easily define behavior for multiple different button chords just by changing the behavior of a single function pointer. So if I want the chord to return to title screen when pressed in game but reboot when pressed at the title screen (like how games like sonic adventure or soul caliber work) it's just a matter of changing one function behavior.
Still Thinking!~~
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Is there a reason KOS only has one controller callback?

Post by BlueCrab »

ThePerfectK wrote: Fri Nov 15, 2019 4:33 pm
BlueCrab wrote: Fri Nov 15, 2019 12:57 pm If you're looking to set up a exit to menu callback for all controllers like commercial games do, just set the addr parameter to 0.
I'd like to be able to set unique chords for each controller, though. Example, I have made some changes to controller.h so that each controller has its own unique callback, for instances e.g. Where one controller is a dreamcast pad and the other is a Sega saturn controller or arcade stick or twin stick. Right now, with my small change, the DC reboot sequence is a+b+x+y+start, while an arcade stick or saturn controller is a+b+c+start. The only way I found I could pull that off is if each controller has its own independent callback chord. Is there an alternative way to accomplish that?
Other than just checking for the set of buttons in your normal input handling, no, there's nothing in KOS natively to do it.

As was said earlier in the thread, it's meant to be a very simple/stupid way of generally exiting to the BIOS menu that matches what commercial games do (where it's pretty much always ABXY+Start).
Post Reply