MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / get_packet

Method get_packet

linux/lnxcontroller.cpp:491–569  ·  view source on GitHub ↗

all systems need to implement this function. this returns information about the controller

Source from the content-addressed store, hash-verified

489
490// all systems need to implement this function. this returns information about the controller
491bool lnxgameController::get_packet(int id, ct_packet *packet, ct_format alt_format) {
492 float val = (float)0.0;
493 int i;
494
495 ASSERT(id < CT_MAX_ELEMENTS);
496
497 packet->format = (alt_format != ctNoFormat) ? alt_format : m_ElementList[id].format;
498 alt_format = packet->format;
499
500 WinControllerTimer = timer_GetTime();
501 packet->flags = 0;
502
503 if (!m_ElementList[id].enabled) {
504 goto skip_packet_read;
505 }
506
507 // check if the element's controller is valid.
508
509 for (i = 0; i < CTLBINDS_PER_FUNC; i++) {
510 uint8_t value = m_ElementList[id].value[i];
511 int8_t controller = m_ElementList[id].ctl[i];
512
513 if (controller == -1 || m_ControlList[controller].id == CTID_INVALID) {
514 continue;
515 }
516 switch (m_ElementList[id].ctype[i]) {
517 case ctKey:
518 if (value) {
519 val = get_key_value(value, alt_format);
520 if (KEY_STATE(value))
521 packet->flags |= CTPK_ELEMENTACTIVE;
522 }
523 break;
524
525 case ctMouseAxis:
526 packet->flags |= CTPK_MOUSE;
527 case ctAxis:
528 val = get_axis_value(controller, value, alt_format, (m_ElementList[id].flags[i] & CTFNF_INVERT) ? true : false);
529 if (m_ElementList[id].flags[i] & CTFNF_INVERT) {
530 if (alt_format == ctDigital) {
531 val = (val == 0.0f) ? 1.0f : 0.0f;
532 } else if (alt_format == ctAnalog) {
533 val = -val;
534 }
535 }
536 break;
537
538 case ctMouseButton:
539 packet->flags |= CTPK_MOUSE;
540 case ctButton:
541 val = get_button_value(controller, alt_format, value);
542 break;
543
544 case ctPOV:
545 val = get_pov_value(controller, alt_format, 0, value);
546 break;
547 case ctPOV2:
548 case ctPOV3:

Callers 7

DoKeyboardMovementFunction · 0.45
DoControllerMovementFunction · 0.45
DoKeyboardWeaponsFunction · 0.45
DoControllerWeaponsFunction · 0.45
DoKeyboardMiscFunction · 0.45
DoControllerMiscFunction · 0.45
TelComAutoMapFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected