Closed ronaldlw closed 1 year ago
The case
statements select between various event types. The if
statements check other properties of the events.
Hrm.. So, the case is switched on ev.type and the if statements are all if ev.type == something, so wouldn't you just add case statements for those?
Sorry, brushing up on my c skills, it's been awhile :) making sure I understand.
also totally lost trying to figure out what these are doing?
It looks like a function definition prototype and also an array definition.. and seems to be accessed both ways as well?
Ok, I think I figured this out. device_in and device_out are arrays of 256 pointers to functions to handle each port, right? Very tricky :)
also totally lost trying to figure out what these are doing?
It looks like a function definition prototype and also an array definition.. and seems to be accessed both ways as well?
So, the case is switched on ev.type and the if statements are all if ev.type == something, so wouldn't you just add case statements for those?
Oh, in the default case? Yes, maybe so!
Ok, I think I figured this out. device_in and device_out are arrays of 256 pointers to functions to handle each port, right?
Yes, that's right. I don't think it's overly tricky. It's mostly that C syntax make the definitions look strange.
I'm just poking around the code and am wondering why there's a mix of case and if / else if structures here? https://github.com/larsbrinkhoff/terminal-simulator/blob/85854592cbca9c2e24c7473f82c102c76af8e0e7/common/sdl.c#L326-L354