예제 #1
0
        static float KeyState(kbutton_t key)
        {
            float val;
            long  msec;

            key.state &= 1;
            msec       = key.msec;
            key.msec   = 0;
            if (key.state != 0)
            {
                msec        += Globals.sys_frame_time - key.downtime;
                key.downtime = Globals.sys_frame_time;
            }

            val = (float)msec / frame_msec;
            if (val < 0)
            {
                val = 0;
            }
            if (val > 1)
            {
                val = 1;
            }
            return(val);
        }
예제 #2
0
        static void KeyUp(kbutton_t b)
        {
            int    k;
            string c;
            int    uptime;

            c = Cmd.Argv(1);
            if (c.Length > 0)
            {
                k = Lib.Atoi(c);
            }
            else
            {
                b.down[0] = b.down[1] = 0;
                b.state   = 4;
                return;
            }

            if (b.down[0] == k)
            {
                b.down[0] = 0;
            }
            else if (b.down[1] == k)
            {
                b.down[1] = 0;
            }
            else
            {
                return;
            }
            if (b.down[0] != 0 || b.down[1] != 0)
            {
                return;
            }
            if ((b.state & 1) == 0)
            {
                return;
            }
            c      = Cmd.Argv(2);
            uptime = Lib.Atoi(c);
            if (uptime != 0)
            {
                b.msec += uptime - b.downtime;
            }
            else
            {
                b.msec += 10;
            }
            b.state &= ~1;
            b.state |= 4;
        }
예제 #3
0
        static void KeyDown(kbutton_t b)
        {
            int    k;
            string c;

            c = Cmd.Argv(1);
            if (c.Length > 0)
            {
                k = Lib.Atoi(c);
            }
            else
            {
                k = -1;
            }
            if (k == b.down[0] || k == b.down[1])
            {
                return;
            }
            if (b.down[0] == 0)
            {
                b.down[0] = k;
            }
            else if (b.down[1] == 0)
            {
                b.down[1] = k;
            }
            else
            {
                Com.Printf("Three keys down for a button!\\n");
                return;
            }

            if ((b.state & 1) != 0)
            {
                return;
            }
            c          = Cmd.Argv(2);
            b.downtime = Lib.Atoi(c);
            if (b.downtime == 0)
            {
                b.downtime = Globals.sys_frame_time - 100;
            }
            b.state |= 3;
        }