Using PureBasic's keyboard library without opening a screen

Share your advanced PureBasic knowledge/code with the community.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Using PureBasic's keyboard library without opening a screen

Post by Mistrel »

I've seen a several threads about this lately so I thought I would share a work-around for this. I'm not aware of what issues this may cause depending on your configuration; that would be something for Fred to explain. This solution works with both the debugger on and off.

Here you go:

Code: Select all

Procedure _ExamineKeyboard()
  Protected Result
  
  DisableDebugger
  Result=ExamineKeyboard()
  EnableDebugger
  
  ProcedureReturn Result
EndProcedure

Procedure _InitKeyboard()
  Protected Result
  
  DisableDebugger
  Result=InitKeyboard()
  EnableDebugger
  
  ProcedureReturn Result
EndProcedure

Procedure.s _KeyboardInkey()
  Protected Result.s
  
  DisableDebugger
  Result.s=KeyboardInkey()
  EnableDebugger
  
  ProcedureReturn Result
EndProcedure

Procedure _KeyboardPushed(KeyID)
  Protected Result
  
  DisableDebugger
  Result=KeyboardPushed(KeyID)
  EnableDebugger
  
  ProcedureReturn Result
EndProcedure

Procedure _KeyboardReleased(KeyID)
  Protected Result
  
  DisableDebugger
  Result=KeyboardReleased(KeyID)
  EnableDebugger
  
  ProcedureReturn Result
EndProcedure

Procedure _KeyboardMode(Flags)
  DisableDebugger
  KeyboardMode(Flags)
  EnableDebugger
EndProcedure

Macro ExamineKeyboard()
  _ExamineKeyboard()
EndMacro

Macro InitKeyboard()
  _InitKeyboard()
EndMacro

Macro KeyboardInkey()
  _KeyboardInkey()
EndMacro

Macro KeyboardMode(Flags)
  _KeyboardMode(Flags)
EndMacro

Macro KeyboardPushed(KeyID)
  _KeyboardPushed(KeyID)
EndMacro

Macro KeyboardReleased(KeyID)
  _KeyboardReleased(KeyID)
EndMacro