comp.lang.ada
 help / color / mirror / Atom feed
* Another Win32 joystick problem.
@ 1999-08-16  0:00 Josh Highley
  1999-08-17  0:00 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 2+ messages in thread
From: Josh Highley @ 1999-08-16  0:00 UTC (permalink / raw)


I've been trying to read the position of the joystick using the Win32
bindings included with Gnat 3.11 and AdaGIDE 6.21.  I'm running this under
Win 95.  Since I haven't done any Win32 programming, I created a quick and
simple test program.  Since my last post, I've added "pragma
Linker_Options("-lwinmm");"
It now compiles and builds (thanks Mr. Hoos) but when I run the program, the
call to joyGetPos returns an error code of 11 (Invalid Program Format
Attempted to Load).  Then,
"put(joystick_info.wxpos);" raises a constraint_error.  As a check, I tried
calling "joyGetNumDevs" but it returned 16.  I have a single joystick and
I'm 99.9% sure that it is set up properly.  So now my obvious question is
why is the program returning an error code about loading an invalid program
format in the middle of the program?

Once again, here's my test program:
----------------------------------------------------------

with ada.text_io;
with win32.mmsystem;

use ada.text_io;
use win32.mmsystem;

procedure joytest is

pragma Linker_Options("-lwinmm");

joystick_info : lpjoyinfo;
joyID         : win32.UINT := 0;
result        : mmresult;

package mmresult_io is new ada.text_io.modular_io(mmresult);
package UINT_io is new ada.text_io.modular_io(Win32.UINT);
use mmresult_io;
use UINT_io;

begin
     --   function joyGetPos(
     --                uJoyID: Win32.UINT;
     --                lpji  : LPJOYINFO)
     --               return MMRESULT;
    result := joyGetPos(joyID , joystick_info); -- returning error 11
    put("Result: ");
    put(result);
    new_line;
    put("Joystick X-axis: ");
    put(joystick_info.wxpos);   -- this line raises a constraint_error
    new_line;
    put("Joystick Y-axis: ");
    put(joystick_info.wypos);
    new_line;
end joytest;
--------------------------------------------------------

Thanks,

Josh
joshhighley@hotmail.com








^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Another Win32 joystick problem.
  1999-08-16  0:00 Another Win32 joystick problem Josh Highley
@ 1999-08-17  0:00 ` Dmitry A. Kazakov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry A. Kazakov @ 1999-08-17  0:00 UTC (permalink / raw)


Josh Highley wrote:

> with ada.text_io;
> with win32.mmsystem;
>
> use ada.text_io;
> use win32.mmsystem;
>
> procedure joytest is
>
> pragma Linker_Options("-lwinmm");
>
> joystick_info : lpjoyinfo;

                      ^^^^^^^^^^^^
This is a pointer to nothing (uninitialized) that you are passing to joyGetPos!
(should be aliased JoyInfo).

>
> joyID         : win32.UINT := 0;
> result        : mmresult;
>
> package mmresult_io is new ada.text_io.modular_io(mmresult);
> package UINT_io is new ada.text_io.modular_io(Win32.UINT);
> use mmresult_io;
> use UINT_io;
>
> begin
>      --   function joyGetPos(
>      --                uJoyID: Win32.UINT;
>      --                lpji  : LPJOYINFO)
>      --               return MMRESULT;
>     result := joyGetPos(joyID , joystick_info); -- returning error 11

                                                ^^^^^^^^^^^
joystick_info'unchecked_access

Regards,
Dmitry





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-08-17  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-16  0:00 Another Win32 joystick problem Josh Highley
1999-08-17  0:00 ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox