From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4d1b41004c1d217c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: How to interface in ADA with Microsoft joystick? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <2edbcdab-8ff5-40e6-9ac0-44be6cb93621@m15g2000yqm.googlegroups.com> <3a82f59a-129f-46b1-bd0c-eae124136590@26g2000yqv.googlegroups.com> <0402e3f7-151c-4a51-bd61-44f4fc32a9d1@l20g2000yqm.googlegroups.com> <1thnsl7r3l217.1g1mvpwzjokvr.dlg@40tude.net> <1ntdrf2b9blvx.1qzgqdxqb9jvn$.dlg@40tude.net> <1lj7ed5rhng0p.5cwwj78z71lz.dlg@40tude.net> <1whjqkty3xbqg$.c1wt6f7w4l2r$.dlg@40tude.net> <9fff073e-2a2e-469e-8d0d-57da9cb00423@d17g2000yqm.googlegroups.com> Date: Tue, 12 Oct 2010 22:10:59 +0200 Message-ID: <1q1aw3y1t1pkf$.1udh6qaaggpjs$.dlg@40tude.net> NNTP-Posting-Date: 12 Oct 2010 22:10:57 CEST NNTP-Posting-Host: 23a08845.newsspool3.arcor-online.net X-Trace: DXC=cI7:OAllSjLgj[ZPFj7ehOMcF=Q^Z^V3H4Fo<]lROoRA8kF9M X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:14497 Date: 2010-10-12T22:10:57+02:00 List-Id: 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