$input->items = WinZik::ACTIONS; $this->$input->selected = (int)($this->wz->controls[$input] ?? 0); } $pad = (int)($this->wz->options['pad'] ?? 0); $this->pad1->checked = $pad === 0; $this->pad2->checked = $pad === 1; $this->enabled->checked = (bool)($this->wz->options['joystick'] ?? false); } protected function tick(float $dt): void { parent::tick($dt); $pad = $this->pad2->checked ? 1 : 0; $gamepad = $this->engine->input->getGamepad(); $this->padName->text = $gamepad->isConnected($pad) ? (string)$gamepad->name($pad) : 'aucune manette branchée'; $lx = $gamepad->axis($pad, 'lx'); $ly = $gamepad->axis($pad, 'ly'); $held = [ 'xp' => $lx > 0.5, 'xm' => $lx < -0.5, 'yp' => $ly < -0.5, 'ym' => $ly > 0.5, 'b1' => $gamepad->isButtonHeld($pad, 'a'), 'b2' => $gamepad->isButtonHeld($pad, 'b'), 'b3' => $gamepad->isButtonHeld($pad, 'x'), 'b4' => $gamepad->isButtonHeld($pad, 'y'), ]; foreach ($held as $input => $on) { $label = 'l' . $input; $this->$label->color = $on ? '#ff4040' : ''; // QBColor(12) while it is held } } public function onOkClick(Button $sender): void { foreach (self::INPUTS as $input) { $this->wz->controls[$input] = max(0, (int)$this->$input->selected); } $this->wz->options['pad'] = $this->pad2->checked ? 1 : 0; $this->wz->options['joystick'] = (bool)$this->enabled->checked; $this->wz->save(); $this->close(); } }