Difference between revisions of "GE"

From GIMX
Jump to: navigation, search
(The GIMX Event Library)
 

(3 intermediate revisions by the same user not shown)

Line 1: Line 1:
 +
'''Warning: this page is outdated. The GIMX Event Library is superseded by the [[gasync]] library.'''
 +
 
=The GIMX Event Library=
 
=The GIMX Event Library=
  
Line 50: Line 52:
 
==Build the static library==
 
==Build the static library==
 
  cd ~
 
  cd ~
  git clone -b dev --single-branch --depth 1 <nowiki>https://github.com/matlo/GIMX.git</nowiki>
+
  git clone -b master --single-branch --depth 1 <nowiki>https://github.com/matlo/GIMX.git</nowiki>
 
  cd GIMX/shared/event
 
  cd GIMX/shared/event
 
  make
 
  make
  
 
==Build the test==
 
==Build the test==
  cd ~/GIMX/event/test
+
  cd ~/GIMX/shared/event/test
 
  make
 
  make
  
 
==Run the test==
 
==Run the test==
  cd ~/GIMX/event/test
+
  cd ~/GIMX/shared/event/test
 
  ./GE_test
 
  ./GE_test
  
 
The test displays all keyboards, mice and joysticks, and it then displays all input events.
 
The test displays all keyboards, mice and joysticks, and it then displays all input events.
 
Press Escape or Ctrl+c to exit.
 
Press Escape or Ctrl+c to exit.

Latest revision as of 16:38, 10 June 2016

Warning: this page is outdated. The GIMX Event Library is superseded by the gasync library.

The GIMX Event Library

GE is a cross-platform event library for handling input from keyboards, mice, and joysticks.
It can be used in Windows or Linux.
It is released under the GPLv3 license and is available in the GIMX git repository.
GE supports multiple mice, keyboards and joysticks, which means the source of each event can be identified.
In Linux, it interfaces with evdev or X, and allows to write "interrupt-based" event processing.
In Windows, it interfaces with the RawInput API or the SDL library to get keyboard and mouse events. To get joystick events it uses the SDL 2.0 library, which handles standard joysticks and Xinput gamepads. RawInput event processing is "interrupt-based", whereas SDL 2.0 event processing is "polling-based".

This page only gives a pseudo-code example. Check the test directory for a complete example.

To use GE in Linux, make sure to have read access to the input devices.

Example

 #include <GE.h>
 
 int process_event(GE_Event* event)
 {
   //handle the event
 }
 
 int main(int argc, char* argv[])
 {
   if (!GE_initialize(GE_MKB_SOURCE_PHYSICAL)) //or GE_MKB_SOURCE_WINDOW_SYSTEM
   {
     //handle the error
   }
 
   GE_TimerStart(10000); //microseconds
 
   GE_SetCallback(process_event);
 
   GE_grab(); //grab the mouse pointer
 
   while(!done)
   {
     GE_PumpEvents();//returns when timer fires
 
     //do something periodically
   }
 
   GE_quit();
   
   return 0;
 }

Build and test

Build the static library

cd ~
git clone -b master --single-branch --depth 1 https://github.com/matlo/GIMX.git
cd GIMX/shared/event
make

Build the test

cd ~/GIMX/shared/event/test
make

Run the test

cd ~/GIMX/shared/event/test
./GE_test

The test displays all keyboards, mice and joysticks, and it then displays all input events. Press Escape or Ctrl+c to exit.