ewrogers/sgdk-skills

sgdk-input

Implement or debug SGDK input for 3/6-button pads, Mega Mouse, Sega Team Player and EA 4-Way Play.

ソースを見る

使い方

  1. インストールコマンドをコピーし、自分の環境へ導入する前にソースを確認します。
  2. 必要なツール、認証情報、対応環境を原文で確認します。
  3. 入力と成果物を指定し、出力を資料と照合します。
npx skills add https://github.com/ewrogers/sgdk-skills --skill sgdk-input

開始前の確認

  • 導入にはモデル契約、API枠、ファイルへのアクセス許可は含まれません。
  • スター数や導入数は活動の指標であり、独立した品質・安全性試験ではありません。
リポジトリの原文

見出し、例、コード、表、リンク、参照画像を含む原文を表示しています。

SGDK input

Make controls predictable for the player and easy for the game to consume. Use the project's selected SGDK. Verify unfamiliar APIs against its headers and implementation; do not invent a generic controller API or import an engine's restrictions.

Choose the devices and controls

Read existing game decisions first. Keep essential pad controls available on a 3-button controller unless the game explicitly requires six buttons. Ask about player count or required peripherals only when it changes the task.

Distinguish physical PORT_1/PORT_2 from logical JOY_1 through JOY_8. A Team Player supports four devices on one port; two can serve eight players. EA 4-Way Play uses both ports for four pads. Never assign a contiguous group of four SGDK joy IDs to a multitap without checking the mapping.

Read devices and SGDK behavior before configuring mice, multitaps or device changes. It records the exact API, slot tables, button aliases and important SGDK 2.11 limitations.

Sample once, reuse throughout the frame

With the normal SGDK loop, SYS_doVBlankProcess() calls JOY_update(). JOY_readJoypad() reads cached state; repeated calls do not poll the hardware. Do not add a second JOY_update() or raw controller-port reads to that loop.

Take one game snapshot after the refresh and reuse it. Derive held, pressed and released states, then map them to game actions. Keep the device check with the binding: mouse buttons share bits with pad buttons.

Use input patterns for button edges, alternate bindings, opposite directions, mouse movement and slower simulation steps. Keep callbacks short. Do not perform VDP work, reset controllers or run game logic inside the input callback.

Start with the smallest useful example

The standalone Input Lab configures both ports, displays all eight logical slots, shows held/edge masks, and consumes mouse movement. Its small input.c is optional example code, not part of SGDK. Adapt only what the game needs; no heap, string lookup or binding framework is required for a handful of actions.

The example owns SGDK's single joy callback and mouse accumulators. Integrate that ownership with existing input code rather than installing competing handlers. Use ewrogers/sgdk:latest for the toolchain. For a new scratch project, the example documents the tested Docker image and build commands.

Verify the behavior, not just compilation

Compile against the real SGDK 2.11 implementation. Test press/hold/release, alternate bindings, opposite directions, baseline after reset, and each player's independent state. For mouse input, test all supported buttons, both motion axes, capture/mapping in the emulator and direct versus Team Player routing.

Use the device test checklist for both multitaps, mixed devices and hardware-specific checks. Record which configurations were actually exercised. Host tests prove application snapshot logic with mocked SDK calls; compiling a ROM proves API compatibility. Neither proves physical device protocols, hotplug, emulator mapping or 50/60 Hz timing.

Do not promise automatic hotplug from JOY_getPortType() or JOY_getJoypadType(). Use deliberate rediscovery during setup if needed, explain its interruption, and account for the selected SGDK version's startup and stale-state behavior.

Optional remote test input

For a user-requested development-ROM USB controller, the testing skill owns the optional input hook. Feed it this input owner's sampled states and route gameplay through its logical result; do not add a second physical sampler, replace SDK globals or reinterpret mouse bits as pad directions. The two USB slots can independently replace pad/mouse state until a short lease expires. This does not test electrical ports, add multitap support or control the BIOS before application entry. The hook is optional instrumentation, not a requirement for ordinary games.

タスクに関連する項目

同じリポジトリから

関連する Skills

すべての Skills
ewrogers
コミュニティ

sgdk-ai

Implement enemy behavior in SGDK games with patrol/chase/attack states, sight cones, target selection, bounded pathfinding and staggered updates. Use when enemies see through walls, get stuck, switch targets erratically, return stale paths or cause frame spikes while searching.

導入数
1
GitHub Stars
0
更新日
10月20日
ewrogers
コミュニティ

sgdk-assets

Prepare, import and troubleshoot Mega Drive graphics, palettes, spritesheets, tiles, maps, fonts and audio resources with SGDK ResComp in Docker. Use for .res files, palette or tile budgets, broken imports, sprite cutting and asset pipeline changes.

導入数
1
GitHub Stars
0
更新日
10月20日
ewrogers
コミュニティ

sgdk-best-practices

Write or review SGDK C for defined arithmetic, clear module boundaries, resource lifetimes, safe queued transfers and interrupt sharing. Use for implementation quality and project code organization, rather than toolchain setup, game design or performance profiling alone.

導入数
1
GitHub Stars
0
更新日
10月20日
ewrogers
コミュニティ

sgdk-cartridge

Plan and implement large SGDK cartridges with Sega/SSF bank switching, FAR resources, pinned shared code and audio, and safe SRAM access. Use when a ROM exceeds the linear address window, stage assets live in separate banks, a FAR pointer becomes invalid, or saving interferes with banked content.

導入数
1
GitHub Stars
0
更新日
10月20日