From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to interface in ADA with Microsoft joystick?
Date: Tue, 12 Oct 2010 22:10:59 +0200
Date: 2010-10-12T22:10:57+02:00 [thread overview]
Message-ID: <1q1aw3y1t1pkf$.1udh6qaaggpjs$.dlg@40tude.net> (raw)
In-Reply-To: 9fff073e-2a2e-469e-8d0d-57da9cb00423@d17g2000yqm.googlegroups.com
On Tue, 12 Oct 2010 10:41:17 -0700 (PDT), tolkamp wrote:
> Building of project gives the result:
>
> gnatmake -d -PC:\GNAT\2010\bin\joystick.gpr -XLIBRARY_TYPE=static
> joystick_main.adb
> gnatbind -I- -x C:\GNAT\2010\bin\joystick_main.ali
> error: "win32-mmsystem.adb" must be recompiled ("win32-mmsystem.ads"
> has been modified)
> gnatmake: *** bind failed.
Sorry, but it still is broken.
Here is a complete working example of using joystick under GNAT Ada and
Win32Ada:
---------- joystick.gpr --------------------------------------
with "win32ada.gpr";
project Joystick is
for Source_Dirs use (".");
for Main use ("joystick_main.adb");
package Linker is
for Default_Switches ("ada") use ("-lwinmm", "-mwindows");
end Linker;
end Joystick;
---------- joystick_main.adb ------------------------------
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Interfaces.C; use Interfaces.C;
with Win32; use Win32;
with Win32.MMSystem; use Win32.MMSystem;
with Win32.WinUser; use Win32.Winuser;
with System; use System;
procedure Joystick_Main is
State : aliased JOYINFO;
Result : MMRESULT;
Text : Unbounded_String;
begin
loop
Text := Null_Unbounded_String;
Result := joyGetPos (JOYSTICKID1, State'Unchecked_Access);
if Result = JOYERR_NOERROR then
Append (Text, "X =" & UINT'Image (State.wXpos));
Append (Text, "Y =" & UINT'Image (State.wYpos));
else
Append (Text, "Error reading joystick state");
end if;
Append (Text, Character'Val (0));
case MessageBox
( Null_Address,
Addr (To_String (Text)),
Addr ("Joystick position" & Character'Val (0)),
MB_OKCANCEL
) is
when IDOK => null;
when others => exit;
end case;
end loop;
end Joystick_Main;
-------------------------------------------------------------------
The example uses joyGetPos because joyGetPosEx would not work with most of
joysticks.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
prev parent reply other threads:[~2010-10-12 20:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-03 15:07 How to interface in ADA with Microsoft joystick? tolkamp
2010-10-03 15:21 ` Dmitry A. Kazakov
2010-10-04 15:16 ` tolkamp
2010-10-04 16:18 ` Dmitry A. Kazakov
2010-10-04 17:54 ` tolkamp
2010-10-04 18:58 ` Dmitry A. Kazakov
2010-10-04 19:30 ` tolkamp
2010-10-04 19:46 ` tolkamp
2010-10-05 7:30 ` Dmitry A. Kazakov
2010-10-05 10:19 ` tolkamp
2010-10-05 10:55 ` AdaMagica
2010-10-05 12:21 ` Dmitry A. Kazakov
2010-10-05 15:32 ` tolkamp
2010-10-05 16:11 ` Andre
2010-10-05 17:03 ` Dmitry A. Kazakov
2010-10-08 8:48 ` tolkamp
2010-10-08 20:00 ` Dmitry A. Kazakov
2010-10-10 11:05 ` tolkamp
2010-10-10 11:11 ` Dmitry A. Kazakov
2010-10-11 20:24 ` tolkamp
2010-10-12 7:25 ` Dmitry A. Kazakov
2010-10-12 9:52 ` tolkamp
2010-10-12 11:25 ` tolkamp
2010-10-12 12:07 ` Dmitry A. Kazakov
2010-10-12 17:41 ` tolkamp
2010-10-12 20:10 ` Dmitry A. Kazakov [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox