MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / fixjport

Function fixjport

src/inputdevice.cpp:10221–10276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10219}
10220
10221static bool fixjport(struct jport *port, int add, bool always)
10222{
10223 bool wasinvalid = false;
10224 int vv = port->id;
10225 if (vv == JPORT_NONE)
10226 return wasinvalid;
10227 if (vv >= JSEM_JOYS && vv < JSEM_MICE) {
10228 vv -= JSEM_JOYS;
10229 vv += add;
10230 if (vv >= inputdevice_get_device_total (IDTYPE_JOYSTICK))
10231 vv = 0;
10232 vv += JSEM_JOYS;
10233 } else if (vv >= JSEM_MICE && vv < JSEM_END) {
10234 vv -= JSEM_MICE;
10235 vv += add;
10236 if (vv >= inputdevice_get_device_total (IDTYPE_MOUSE))
10237 vv = 0;
10238 vv += JSEM_MICE;
10239 } else if (vv >= JSEM_KBDLAYOUT && vv < JSEM_LASTKBD) {
10240 vv -= JSEM_KBDLAYOUT;
10241 vv += add;
10242 if (vv >= JSEM_LASTKBD)
10243 vv = 0;
10244 vv += JSEM_KBDLAYOUT;
10245 } else if (vv >= JSEM_CUSTOM && vv < JSEM_CUSTOM + MAX_JPORTS_CUSTOM) {
10246 vv -= JSEM_CUSTOM;
10247 vv += add;
10248 if (vv >= MAX_JPORTS_CUSTOM)
10249 vv = 0;
10250 vv += JSEM_CUSTOM;
10251 }
10252 if (port->id != vv || always) {
10253 port->idc.shortid[0] = 0;
10254 port->idc.configname[0] = 0;
10255 port->idc.name[0] = 0;
10256 if (vv >= JSEM_JOYS && vv < JSEM_MICE) {
10257 _tcsncpy(port->idc.name, inputdevice_get_device_name (IDTYPE_JOYSTICK, vv - JSEM_JOYS), MAX_JPORT_NAME - 1);
10258 _tcsncpy(port->idc.configname, inputdevice_get_device_unique_name (IDTYPE_JOYSTICK, vv - JSEM_JOYS), MAX_JPORT_CONFIG - 1);
10259 } else if (vv >= JSEM_MICE && vv < JSEM_END) {
10260 _tcsncpy(port->idc.name, inputdevice_get_device_name (IDTYPE_MOUSE, vv - JSEM_MICE), MAX_JPORT_NAME - 1);
10261 _tcsncpy(port->idc.configname, inputdevice_get_device_unique_name (IDTYPE_MOUSE, vv - JSEM_MICE), MAX_JPORT_CONFIG - 1);
10262 } else if (vv >= JSEM_KBDLAYOUT && vv < JSEM_CUSTOM) {
10263 _sntprintf(port->idc.shortid, sizeof port->idc.shortid, _T("kbd%d"), vv - JSEM_KBDLAYOUT + 1);
10264 } else if (vv >= JSEM_CUSTOM && vv < JSEM_JOYS) {
10265 _sntprintf(port->idc.shortid, sizeof port->idc.shortid, _T("custom%d"), vv - JSEM_CUSTOM);
10266 }
10267 port->idc.name[MAX_JPORT_NAME - 1] = 0;
10268 port->idc.configname[MAX_JPORT_CONFIG - 1] = 0;
10269 wasinvalid = true;
10270#if 0
10271 write_log(_T("fixjport %d %d %d (%s)\n"), port->id, vv, add, port->name);
10272#endif
10273 }
10274 port->id = vv;
10275 return wasinvalid;
10276}
10277
10278static void inputdevice_get_previous_joy(struct uae_prefs *p, int portnum, bool userconfig)

Callers 1

Calls 4

write_logFunction · 0.70

Tested by

no test coverage detected