KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Karma::WindowsInput Class Reference

Input class for Windows OS. More...

#include <WindowsInput.h>

Inheritance diagram for Karma::WindowsInput:
Karma::Input

Public Member Functions

 WindowsInput ()
 A constructor.
void SetEventCallback (const EventCallbackFn &callback, Window *window) override
 Set the event callback for the Windows Input.
Public Member Functions inherited from Karma::Input
 Input (InputData &inputDatRef)
 A constructor for initializing the Input class.
 ~Input ()
 Destructor.
void SetGamepadMapping ()
 Set the gamepad mapping based on a database (../Resources/Misc/GameControllerDB.txt) The mapping is done by taking XBox controller as a reference. For the need of such mapping please see https://www.glfw.org/docs/3.3/input_guide.html#gamepad_mapping.

Protected Member Functions

virtual bool IsKeyPressedImpl (int keycode) override
 Windows implementation of IsKeyPressed function.
virtual bool IsMouseButtonPressedImpl (int button) override
 Windows implementation of IsMouseButtonPressed function.
virtual bool IsMouseButtonReleasedImpl (int button) override
 Windows implementation of IsMouseButtonReleased function.
virtual bool IsControllerButtonPressedImpl (int button, int cID) override
 Windows implementation of IsControllerButtonPressed function.
virtual float ControllerAxisPivotValImpl (int axis, int cID) override
 Windows implementation of ControllerAxisPivotVal function.
virtual std::pair< float, float > GetMousePositionImpl () override
 Windows implementation of GetMousePosition function.
virtual float GetMouseXImpl () override
 Windows implementation of GetMouseX function.
virtual float GetMouseYImpl () override
 Windows implementation of GetMouseY function.
void OnControllerDeviceConnected (ControllerDeviceConnectedEvent &e)
 Event handler for Controller Device Connected event.
void OnControllerDeviceDisconnected (ControllerDeviceDisconnectedEvent &e)
 Event handler for Controller Device Disconnected event.
Protected Member Functions inherited from Karma::Input
const std::list< std::shared_ptr< ControllerDevice > > & GetControllerDevices () const
 Getter for connected controller devices.
void AddControllerDevice (std::shared_ptr< ControllerDevice > device)
 Add to the cache supplied device.

Protected Attributes

WindowsInputData m_Data

Additional Inherited Members

Public Types inherited from Karma::Input
using EventCallbackFn = std::function<void(Event&)>
Static Public Member Functions inherited from Karma::Input
static bool IsKeyPressed (int keycode)
 Polling function for inquiry of key press.
static bool IsMouseButtonPressed (int button)
 Polling function for inquiry of mouse button press.
static bool IsMouseButtonReleased (int button)
 Polling function for the inquiry of mouse button release.
static bool IsControllerButtonPressed (int button, int cID)
 Polling function for the inquiry of game controller button pressed action.
static float ControllerAxisPivotVal (int axis, int cID)
 Polling function for the inquiry of the Axis pivot value (analog stick deflection for instance).
static std::pair< float, float > GetMousePosition ()
 Polling function for the inquiry of mouse position (abscissa, ordinate).
static float GetMouseX ()
 Polling function for the inquiry of abscissa.
static float GetMouseY ()
 Polling function for the inquiry of ordinate.
static InputRegisteringAPI GetAPI ()
 Getter for API (enum) in use for input.
static void DeInit ()
 Deinitialize the Input system.
static void Init ()
 Initialize the Input system for Karma.
static std::shared_ptr< InputGetInputInstance ()
 Getter for the Input instance.
static void DisplayControllerDevices ()
 For debugging purposes, a function to print out the number of connected devices.
Static Protected Member Functions inherited from Karma::Input
static void SetConnectedJoySticks ()
 Create a list of connected joysticks (gamepads).
Static Protected Attributes inherited from Karma::Input
static std::list< std::shared_ptr< ControllerDevice > > m_ControllerDevices

Detailed Description

Input class for Windows OS.

Constructor & Destructor Documentation

◆ WindowsInput()

Karma::WindowsInput::WindowsInput ( )

A constructor.

Since
Karma 1.0.0

Member Function Documentation

◆ ControllerAxisPivotValImpl()

float Karma::WindowsInput::ControllerAxisPivotValImpl ( int axis,
int cID )
overrideprotectedvirtual

Windows implementation of ControllerAxisPivotVal function.

Parameters
axisThe integer corresponding to gamepad controller axis For instance GLFW_GAMEPAD_AXIS_LEFT_X macro
cIDThe controller device ID, defined in GLFW
Note
GLFW API is used
Since
Karma 1.0.0

Implements Karma::Input.

◆ GetMousePositionImpl()

std::pair< float, float > Karma::WindowsInput::GetMousePositionImpl ( )
overrideprotectedvirtual

Windows implementation of GetMousePosition function.

Returns
std::pair<float, float> The X and Y position of the mouse cursor
Note
GLFW API is used
Since
Karma 1.0.0

Implements Karma::Input.

◆ GetMouseXImpl()

float Karma::WindowsInput::GetMouseXImpl ( )
overrideprotectedvirtual

Windows implementation of GetMouseX function.

Returns
float The X position of the mouse cursor
Note
GLFW API is used
Since
Karma 1.0.0

Implements Karma::Input.

◆ GetMouseYImpl()

float Karma::WindowsInput::GetMouseYImpl ( )
overrideprotectedvirtual

Windows implementation of GetMouseY function.

Returns
float The Y position of the mouse cursor
Note
GLFW API is used
Since
Karma 1.0.0

Implements Karma::Input.

◆ IsControllerButtonPressedImpl()

bool Karma::WindowsInput::IsControllerButtonPressedImpl ( int button,
int cID )
overrideprotectedvirtual

Windows implementation of IsControllerButtonPressed function.

Parameters
buttonThe integer corresponding to gamepad controller button For instance GLFW_GAMEPAD_BUTTON_A macro
cIDThe controller device ID, defined in GLFW
Note
GLFW API is used
Since
Karma 1.0.0

Implements Karma::Input.

◆ IsKeyPressedImpl()

bool Karma::WindowsInput::IsKeyPressedImpl ( int keycode)
overrideprotectedvirtual

Windows implementation of IsKeyPressed function.

Parameters
keycodeGLFW defined code for keys, for instance GLFW_KEY_SPACE macro https://www.glfw.org/docs/3.3/group__keys.html
Note
GLFW API is used
Since
Karma 1.0.0

Implements Karma::Input.

◆ IsMouseButtonPressedImpl()

bool Karma::WindowsInput::IsMouseButtonPressedImpl ( int button)
overrideprotectedvirtual

Windows implementation of IsMouseButtonPressed function.

Parameters
buttonThe integer corresponding to mouse button. For instance GLFW_MOUSE_BUTTON_1 macro
Note
GLFW API is used
Since
Karma 1.0.0

Implements Karma::Input.

◆ IsMouseButtonReleasedImpl()

bool Karma::WindowsInput::IsMouseButtonReleasedImpl ( int button)
overrideprotectedvirtual

Windows implementation of IsMouseButtonReleased function.

Parameters
buttonThe integer corresponding to mouse button. For instance GLFW_MOUSE_BUTTON_1 macro
Note
GLFW API is used
Since
Karma 1.0.0

Implements Karma::Input.

◆ OnControllerDeviceConnected()

void Karma::WindowsInput::OnControllerDeviceConnected ( ControllerDeviceConnectedEvent & e)
protected

Event handler for Controller Device Connected event.

Parameters
eThe reference to ControllerDeviceConnectedEvent event object
Since
Karma 1.0.0

◆ OnControllerDeviceDisconnected()

void Karma::WindowsInput::OnControllerDeviceDisconnected ( ControllerDeviceDisconnectedEvent & e)
protected

Event handler for Controller Device Disconnected event.

Parameters
eThe reference to ControllerDeviceDisconnectedEvent event object
Since
Karma 1.0.0

◆ SetEventCallback()

void Karma::WindowsInput::SetEventCallback ( const EventCallbackFn & callback,
Window * window )
overridevirtual

Set the event callback for the Windows Input.

Parameters
callbackThe function to be called when Input event is receieved from GLFW.
windowThe handle of GLFW window
Since
Karma 1.0.0

Implements Karma::Input.


The documentation for this class was generated from the following files: