Esempio n. 1
0
void fire()
{
	//warn the user
	move(4, halfCols - 12);
	attron(A_STANDOUT);
	printw("LAUNCH SEQUENCE INITIATED");
	curs_set(0);
	refresh();
	
	//need to wait 6.5ish seconds
	struct timespec toWait;
	toWait.tv_sec = 6;
	toWait.tv_nsec = 770000000;

	const struct timespec* waiting = &toWait;

	//will hald the time remaining
	struct timespec* whoCares;

	movement_handler(16);

	nanosleep(waiting, whoCares);

	movement_handler(0);

	move(4, halfCols - 12);
	attroff(A_STANDOUT);
	printw("                            ");
	curs_set(0);
}
Esempio n. 2
0
bool HardwareThunder::targetRelative(Pantilt pantilt, qreal dx, qreal dy)
{
    if (pantilt == Body)
    {
        if (qAbs(dy) > qAbs(dx) && dy != 0)
        {
            movement_handler(2, dy < 0 ? 1 : 2);
        }
        else if (qAbs(dy) < qAbs(dx) && dx != 0)
        {
            movement_handler(2, dx < 0 ? 4 : 8);
        }
        else
        {
            movement_handler(2, 0);
        }
    }

    return true;
}
Esempio n. 3
0
bool HardwareThunder::hw_startFiring(Trigger trigger)
{
    switch (trigger)
    {
    case EyeLaser:
        movement_handler(3, 1);
        break;
    case LeftGun:
    case RightGun:
        movement_handler(2, 0x10);
        break;
    case LeftLaser:
    case RightLaser:
        break;
    default:
        break;
    }

    return true;
}
Esempio n. 4
0
int main()
{
    	struct usb_bus *busses;
    
    	usb_init();
    	usb_find_busses();
    	usb_find_devices();
    
    	busses = usb_get_busses();
        


   	struct usb_bus *bus;
    	int c, i, a;
    
    	/* ... */
    
    	for (bus = busses; bus; bus = bus->next) 
	{
    		struct usb_device *dev;
    
    		for (dev = bus->devices; dev; dev = dev->next) 
		{
    			/* Check if this device is a printer */
    			if (dev->descriptor.idVendor == 6465)
			{
				launcher = usb_open(dev);

				//do stuff
				int claimed = usb_claim_interface(launcher, 0); //the device is put into the associated state, these commands are not one shots. As such, you have to send a message triple where all 3 messages are all zeroes in order to stop whatever is happening (in my case, pressing a key sends the move/fire m
				if (claimed == 0)
				{
					int c;
					int redrawNeeded = 0;
					//movement_handler(0x10);

					//c = getchar();

					//movement_handler(0x0);
					//set up curses
					initscr();
					noecho();
					keypad(stdscr, TRUE);
					cbreak();
					nodelay(stdscr, TRUE);

					//draw the interface
					drawScreen();

					//main program loop
					while ( c = getch() )
					{
						//up
						if (c == '8')
						{
							movement_handler(1);

							move(halfLines - 2, halfCols);
							addch('8' | A_BOLD);
							redrawNeeded = 1;

							pauseForMove();
						}
						//down
						else if (c == '5')
						{
							movement_handler(2);

							move(halfLines + 2, halfCols);
							addch('5' | A_BOLD);
							redrawNeeded = 1;

							pauseForMove();
						}
						//left
						else if (c == '4')
						{
							movement_handler(4);

							move(halfLines, halfCols - 3);
							addch('4' | A_BOLD);
							redrawNeeded = 1;

							pauseForMove();
						}
						//right
						else if (c == '6')
						{
							movement_handler(8);
							
							move(halfLines, halfCols + 3);
							addch('6' | A_BOLD);
							redrawNeeded = 1;

							pauseForMove();
						}
						//fire
						else if (c == '0')
						{
							fire();
						}
						else if (c == 'q')
						{
							break;
						}
						else
						{
							movement_handler(0);
							if (redrawNeeded)
							{
								fixHighlights();
								redrawNeeded = 0;
							}
						}
					}


					//stop curses
					endwin();

					usb_release_interface(launcher, 0);
				}

				usb_close(launcher);
    			}
		}
    
    	}
}