cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/18/13:56:01

Message-ID: <36A37E89.62CBEA83@net4you.co.at>
Date: Mon, 18 Jan 1999 19:33:46 +0100
From: Seawolf <seawolf AT net4you DOT co DOT at>
X-Mailer: Mozilla 4.07 [de] (Win98; I)
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Joystick with throtle
References: <01be4308$26bef240$33009696 AT lut001>
NNTP-Posting-Host: 194.177.154.99
X-Trace: 18 Jan 1999 19:32:54 +0100, 194.177.154.99
Lines: 98
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> Does anyone of you who know how can I know the position of the throtle on
> my joystick ?
>
> Must I use some position of joystick 2 ?  Is there a solution with allegro
> ?

Sure! Just set 'joy_type'.
Here's some stooopid code I've written some time ago.
(Hope it works for you ;)

#include <aLLegro.h>

char *_ver_str = "thrtsr01.c $v1 $(c)seawolf 1998";
char *_date_str = "$05/14/98 $21:56";

#define joypressed() ( joy_b1 || joy_b2 || joy_b3 || joy_b4 )

/* stooopid */
void wait_joystick_press( void)
{
 while( !joypressed()) poll_joystick();
 while( joypressed()) {
  poll_joystick();
  delay( 50);
 }
}

void main( void)
{
 BITMAP *dbuf;

 allegro_init();
 install_keyboard();
 initialise_joystick();

 printf( "%s\n", _ver_str);
 printf( "%s\n\n", _date_str);

 /************************/
 joy_type = JOY_TYPE_FSPRO;
 /************************/

 printf( "Joy -> upper left -> button...\n");
 wait_joystick_press();
 calibrate_joystick_tl();

 printf( "Joy -> lower right -> button...\n");
 wait_joystick_press();
 calibrate_joystick_br();

 printf( "Joy -> min throttle -> button...\n");
 wait_joystick_press();
 calibrate_joystick_throttle_min();

 printf( "Joy -> max throttle -> button...\n");
 wait_joystick_press();
 calibrate_joystick_throttle_max();

 set_gfx_mode( 0, 320, 200, 0, 0);
 dbuf = create_bitmap( SCREEN_W, SCREEN_H);

 while( !keypressed())
 {
  clear( dbuf);
  poll_joystick();

  textout( dbuf, font, _ver_str, SCREEN_W-text_length( font,
    _ver_str), SCREEN_H-text_height( font)*2, 12);

  textout( dbuf, font, _date_str, SCREEN_W-text_length( font,
    _date_str), SCREEN_H-text_height( font), 12);

  textprintf( dbuf, font, 0,  0, 14, "Joystick A");
  textprintf( dbuf, font, 0,  8, 15, "Axis      : %3d %3d",   joy_x, joy_y);
  textprintf( dbuf, font, 0, 16, 15, "Direction : %d %d %d %d",   joy_left,
joy_right, joy_up, joy_down);
  textprintf( dbuf, font, 0, 24, 15, "Buttons   : %d %d %d %d %d %d %d %d",
joy_b1, joy_b2, joy_b3, joy_b4, joy_b5, joy_b6, joy_b7, joy_b8);
  /************************/
  textprintf( dbuf, font, 0, 32, 15, "Throttle  : %3d",    joy_throttle);
  /************************/

  textprintf( dbuf, font, 0, 48, 14, "Joystick B");
  textprintf( dbuf, font, 0, 56, 15, "Axis      : %3d %3d",   joy2_x, joy2_y);

  textprintf( dbuf, font, 0, 64, 15, "Direction : %d %d %d %d",   joy2_left,
joy2_right, joy2_up, joy2_down);
  textprintf( dbuf, font, 0, 72, 15, "Buttons   : %d %d",    joy2_b1,
joy2_b2);

  blit( dbuf, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
   //write double buffer to screen
 }
 allegro_exit();
 printf( "Done.\n");
}


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019