Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Joystick with View/Pro on win98

From: deadzaphod::flyingparty::com at: 4-Sep-2001 17:22

I just got /Pro and decided to try accessing the joystick under windows. It works great and I thought maybe I should share the code, so here's my joystick demo: REBOL [ title: "Joystick Demo 2" ] winmm: load/library %winmm.dll joyinfostruct: make struct! [ xpos [integer!] ypos [integer!] zpos [integer!] buttons [integer!] ] none joyGetPos: make routine! [ joyid [integer!] joyinfo [ struct! [ xpos [integer!] ypos [integer!] zpos [integer!] buttons [integer!] ] ] return: [integer!] ] winmm "joyGetPos" joystick: func [ number /local a ] [ joygetpos number joyinfostruct a: context [ x: y: z: b: none ] set bind [x y z b] in a 'self second joyinfostruct a ] old: j: context [ x: y: z: b: 0 ] view/new layout/size [ b: box 15x15 green ] 272x272 while [j/b <> 15] [ wait 0 j: joystick 0 b/offset: to-pair reduce [ (to-integer j/x / 256) (to-integer j/y / 256) ] either j/b = 0 [ b/color: green ] [ b/color: red ] show b old: j ] halt