EnableDirectInput enable
Parameters
|
enable - whether to read input through DirectInput 0: use ordinary Windows input 1: use DirectInput |
Description
|
Switches input reading between DirectInput and ordinary Windows messages. In classic Blitz3D this was a real choice. DirectInput gave raw, low-latency key and mouse state - what a fast action game wants - while ordinary Windows input behaved itself around dialogs, text fields and the desktop. Games commonly turned DirectInput on for play and off again for menus or a chat box. On the modern runtime the call is accepted and ignored. Keyboard and mouse state comes from the window message queue and gamepads come from XInput; there is no second input path to switch to, so nothing changes and DirectInputEnabled keeps reporting 0 whatever you pass. It never raises an error, so classic sources that toggle it during play keep working untouched. Practically, that means you can delete it from new code. Input keeps flowing the whole time, so nothing in your game breaks if you leave it in either - a port that calls it around its menus is still correct, just no longer doing anything. KeyDown, KeyHit, GetKey, the mouse commands and the joystick commands are unaffected by the flag. See also: DirectInputEnabled, KeyDown, KeyHit, MouseX, JoyType. |
Example
; EnableDirectInput Example ; ------------------------- Graphics 640,480,0,2 SetBuffer BackBuffer() ; Classic Blitz3D turned DirectInput on when a game wanted raw key and ; mouse reads, and off again when it wanted friendly Windows input. enabled=0 EnableDirectInput enabled ; A little turret the arrow keys aim, to prove input keeps working angle#=0 While Not KeyDown(1) Cls ; Space flips the request If KeyHit(57) Then enabled=1-enabled EnableDirectInput enabled End If ; Left and right steer the turret whichever way the flag is set If KeyDown(203) Then angle=angle-2 If KeyDown(205) Then angle=angle+2 ; The turret keeps sweeping on its own so there is always motion angle=angle+0.4 Color 120,200,120 Oval 300,220,40,40,1 Color 255,255,255 Line 320,240,320+Cos(angle)*70,240+Sin(angle)*70 Text 0,0,"Space: toggle the request Left/Right: aim Esc: exit" Text 0,20,"EnableDirectInput "+enabled Text 0,40,"DirectInputEnabled() reports "+DirectInputEnabled() Text 0,420,"On the modern runtime this call is accepted and ignored: key" Text 0,440,"and mouse state comes from the window message queue and" Text 0,460,"gamepads from XInput, so there is no DirectInput to switch." Flip Wend End
Index