Seite 1 von 1

[LIB] WIH - Mouse & Keyboard Library [Windows x64]

Verfasst: 15.03.2020 12:41
von Mijikai
WIH (Window Input Handler)
wih.lib ist eine kleine in FASM geschriebene Library um Maus & Keyboard Eingaben abzufragen.

Beispiel:

Code: Alles auswählen

;WIH - WINDOW INPUT HANDLER 
;A SMALL LIBRARY TO HANDLE MOUSE AND KEYBOARD INPUT
;AUTHOR: MIJIKAI
;VERSION: 1.1

EnableExplicit

Import "wih.lib"
  wihCreate.i(hwnd.i)
EndImport

Interface WIH
  Focus.i()                       ;is the window focused / is the input attached to the window thread!
  Key.i(Code.i)                   ;is the key pushed? / use #VK key-codes
  KeySgl.i(Code.i)                ;was the butten pushed? / use #VK key-codes 
  KeyChr.i()                      ;get the chr key code of the pushed key
  MouseCheck.i()                  ;is the mouse inside the client area of the window
  MouseLeft.i()                   ;is the left mouse button pushed?
  MouseRight.i()                  ;is the right mouse button pushed?
  MouseMiddle.i()                 ;is the middle mouse button pushed?
  MouseLeftSgl.i()                ;was the left mouse button pushed?
  MouseRightSgl.i()               ;was the right mouse button pushed?
  MouseMiddleSgl.i()              ;was the middle mouse button pushed?
  MouseLeftDbl.i()                ;was the left mouse button pushed twice in a short time? / doubleclick!
  MouseRightDbl.i()               ;was the right mouse button pushed twice in a short time? / doubleclick!
  MouseMiddleDbl.i()              ;was the middle mouse button pushed twice in a short time? / doubleclick!
  MouseWheel.i(Code.i = #Null)    ;was the mousewheel moved? / optional check if a special key is pressed!
  MouseX.i()                      ;get the mouse horizontal (x) postion / offset from the top left corner of the client area!
  MouseY.i()                      ;get the mouse verical (y) postion / offset from the top left corner of the client area!
  Flush.i()                       ;flush the input buffers / needed for all 'Sgl' and 'Dbl' functions to work properly!
  Release.i()                     ;release the input handler and all associated resources
EndInterface

Procedure.i Demo(Title.s = #Null$,Width.i = 600,Height.i = 400)
  Protected wnd.i
  Protected wnd_flags.i
  Protected wnd_event.i
  Protected wnd_exit.i
  Protected *input.WIH
  wnd_flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  wnd = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,wnd_flags) 
  If wnd
    WindowBounds(wnd,Width,Height,#PB_Ignore,#PB_Ignore)
    *input = wihCreate(WindowID(wnd))
    If *input
      Repeat 
        Select WaitWindowEvent()
          Case #PB_Event_CloseWindow
            wnd_exit = #True
        EndSelect
        ;-------------------------------
        ;check mouse and keyboard input!
        If *input\MouseLeftDbl()
          Debug "DoubleClick!"
        EndIf
        Debug *input\MouseY()
        ;-------------------------------
        *input\Flush();<- when done flush the input buffers!
      Until wnd_exit
      *input\Release();<- release all resources
    EndIf
    CloseWindow(wnd)
  EndIf
  ProcedureReturn #Null
EndProcedure

Demo("WIH")

End
Download Version v.1.1:
https://www.dropbox.com/s/cvzmgtvcchtmi ... 1.zip?dl=0

Re: [LIB] WIH - Mouse & Keyboard Library [Windows x64]

Verfasst: 16.03.2020 08:34
von tft
Hallo,

grundsätzlich cool, aber mir erschliesst sich der sinn nicht. Erkläre doch mal warum du diesen Umweg gegangen bist.
Ich mache auch manchmal Sachen nur um sie mal auszuprobieren. Wie gerade meine MineCraftClone. Es ist keine
Kritik, lediglich Interesse.

Gruss TFT

Re: [LIB] WIH - Mouse & Keyboard Library [Windows x64]

Verfasst: 16.03.2020 19:13
von Mijikai
Hat sich angeboten, da ich gerne in Assembly programmiere und ich nie wirklich zufrieden mit den PB Optionen war.
Die Library bietet mir mehr und einfachere Funktionen ohne Einschränkungen oder DirectX :)

Re: [LIB] WIH - Mouse & Keyboard Library [Windows x64]

Verfasst: 16.03.2020 19:44
von tft
Hallo,

Sie kommt also ohne den Examine Kram aus und berücksichtigt auch die Aktuelle Fenster Position, kommt auch mit Negativen Fenster Offsets klar die entstehen wenn 3 Monitore Verwendung finden? Funktioniert das im Window genauso wie Im Screen?

Gruss TFT

Re: [LIB] WIH - Mouse & Keyboard Library [Windows x64]

Verfasst: 16.03.2020 20:57
von Mijikai
Hab (ungetestet) Multi-Monitor Unterstützung hinzugefügt (ich selbst brauch das nicht hab max. nur 2 Monitore) :)
Wie der Name vermuten lässt wird immer ein Fenster benötigt.

Re: [LIB] WIH - Mouse & Keyboard Library [Windows x64]

Verfasst: 18.09.2020 07:46
von tft
Hallo,

habe das jetzt mal in mein Aktuelles Projekt eingebunden. Läuft super. Würdest du das auch um einige Funktionen erweitern? ich hätte da so einige Bedürftnisse :-)

Für zum Umgang damit, müsste ich noch was wissen. Tasttatur Eingaben werden ja via Interupt an Windows gesendet. Und diese dann als Nachrichten von Windows weitergeleitet. Ich möchte jetzt
die Ereignisse sehr schnell verarbeiten. Holst du die Ereignisse von Windows oder direkt aus dem Interupt ereigniss? Ich möchte in einem Thread der mit 1000 FPS läuft. Die Tasten und Mouse coordinaten
abfragen. Get das so schnell. Oder ist die Abfrage von Windows abhängig?.

Gruss TFT

Re: [LIB] WIH - Mouse & Keyboard Library [Windows x64]

Verfasst: 18.09.2020 09:26
von Mijikai
Die Eingabe Ereignisse werden über das Fenster abgefragt.
Schneller und direkter wäre eine Zugriff über die Direct- oder RawInput-Schnittstelle.
RawInput ist wohl die beste Methode aber auch die Aufwändigste.