Files
Quadrapassel/tests/input_test.c
T
Brian Holman d412e35c4e Implement CoCo 3 Quadrapassel and deliver build 01
Add gameplay, keyboard/joystick controls, disk-backed high scores and settings,
standard CMOC effects, and the approved C graphics renderer. Include the clearer
attributed font, title/credits updates, source-verified Modern and Classic (40.2)
scoring, meaningful regression fixtures, and recorded guest validation.

Deliver QUADPSL01.DSK with fresh high scores. Retain source, licenses and selected
guest evidence; exclude personal disks, private connections and build scratch.

Host rules/input/persistence/video checks and memory guards pass. Official
512 KB playtests pass the recorded checks; actual 128 KB/physical joystick
qualification and the normal-window buzzing retest remain pending.
2026-11-11 03:14:14 -07:00

30 lines
1.7 KiB
C

/* SPDX-License-Identifier: GPL-3.0-or-later */
#include <assert.h>
#include <stdio.h>
#include "input.h"
static QInput s;
static QActions step(Q16 keys,Q8 button,Q8 x,Q8 y,Q16 ms,Q8 playing){return q_input_step(&s,keys,button,x,y,31,31,1,ms,playing,0);}
static void reset(void){q_input_reset(&s);step(0,0,31,31,0,1);}
int main(void){QActions a;
reset();a=step(Q_LEFT,0,31,31,0,1);assert(a.move==-1&&a.repeats==1);
a=step(Q_LEFT,0,31,31,199,1);assert(!a.repeats);
a=step(Q_LEFT,0,31,31,1,1);assert(a.move==-1&&a.repeats==1);
a=step(Q_LEFT,0,31,31,39,1);assert(!a.repeats);
a=step(Q_LEFT|Q_RIGHT,0,31,31,1,1);assert(a.move==-1&&a.repeats==1);
a=step(Q_RIGHT,0,31,31,1,1);assert(a.move==1&&a.repeats==1);
reset();a=step(Q_CCW,0,31,31,1,1);assert(a.pressed&Q_CCW);
a=step(Q_CCW,0,31,31,500,1);assert(!(a.pressed&Q_CCW));
reset();step(0,1,31,31,100,1);a=step(0,0,31,31,1,1);assert(a.pressed&Q_CCW);
reset();step(0,1,31,31,399,1);a=step(0,1,31,31,1,1);assert(a.pressed&Q_PAUSE);
a=step(0,0,31,31,1,1);assert(!(a.pressed&Q_CCW));
reset();a=step(0,0,31,10,1,1);assert(a.pressed&Q_HARD);
a=step(0,0,31,10,500,1);assert(!(a.pressed&Q_HARD));
step(0,0,31,31,1,1);a=step(0,0,31,10,1,1);assert(a.pressed&Q_HARD);
reset();a=step(0,0,0,10,1,1);assert(!(a.pressed&Q_HARD));
q_input_reset(&s);step(0,0,0,0,1,1);a=step(Q_LEFT,0,0,0,1,1);assert(a.move==-1);
reset();a=step(0,0,20,31,1,1);assert(a.move==-1);
a=step(0,0,24,31,1,1);assert(a.held&Q_LEFT);
a=step(0,0,25,31,1,1);assert(!(a.held&Q_LEFT));
reset();step(0,1,31,31,100,0);a=step(0,0,31,31,1,0);assert(a.pressed&Q_CONFIRM);
puts("PASS: input repeat, conflicting directions, edges, one-button timing, hysteresis, diagonal guard, disconnected-stick keyboard");return 0;}