VGamepad PC
The Windows app for the virtual game controller.
Loading...
Searching...
No Matches
Preferences Class Reference

#include <preferences.hpp>

Inheritance diagram for Preferences:
[legend]
Collaboration diagram for Preferences:
[legend]

Public Member Functions

 Preferences (QWidget *parent=nullptr)
 
void load_keys ()
 
 ~Preferences () override
 

Protected Member Functions

bool eventFilter (QObject *sender, QEvent *event) override
 
void keyPressEvent (QKeyEvent *e) override
 

Private Member Functions

void change_mouse_sensitivity (int value)
 
void change_key_inputs ()
 
void get_scan_code (WORD vk, char *a, int size=256)
 
void install_event_filter ()
 

Private Attributes

Ui::Preferences * ui
 
std::map< QString, UINT > temp
 

Constructor & Destructor Documentation

◆ Preferences()

Preferences::Preferences ( QWidget * parent = nullptr)
explicit

◆ ~Preferences()

Preferences::~Preferences ( )
override

Member Function Documentation

◆ change_key_inputs()

void Preferences::change_key_inputs ( )
private

This changes the keyboard maps and saves those changes in the config file. This function is executed if the user presses ok button.

◆ change_mouse_sensitivity()

void Preferences::change_mouse_sensitivity ( int value)
private

Changes the mouse sensitivity or the cursor speed

Parameters
valueThe amount of mouse sensitivity you want to set.

◆ eventFilter()

bool Preferences::eventFilter ( QObject * sender,
QEvent * event )
overrideprotected

The event filter virtual function is redefined to to filter for mouse and keyboard inputs when user tries to change the button-key maps. Checks which object is sending the event and type of event. If event is a keyboard or mouse button press then map and the object is button map then get the virtual key code of the key pressed and store the change in a temporary variable.

Parameters
senderTo get the address of the object that is triggering the event.
eventTo capture the event that was triggered.
Returns
[bool] True if event is handled else False.

◆ get_scan_code()

void Preferences::get_scan_code ( WORD vk,
char * a,
int size = 256 )
private

Copies the name of the of corresponding key or virtual key code to the provided buffer.

Parameters
vkThe virtual key code of the key you want to get.
aThe buffer to store the name of the key.
sizeSize of the buffer(in char) in which the name is stored to ensure memory safety

◆ install_event_filter()

void Preferences::install_event_filter ( )
private

Install the above event filter on all the button maps to capture the key presses when they have the focus.

◆ keyPressEvent()

void Preferences::keyPressEvent ( QKeyEvent * e)
overrideprotected

Make the QWidget box ignore the enter key and escape key presses when the focus is on button map

Parameters
eCapture the key_press event

◆ load_keys()

void Preferences::load_keys ( )

Displays the key to which each button is mapped to. Saves the initial key maps in variables that can be changed later if user wants to.

Member Data Documentation

◆ temp

std::map<QString, UINT> Preferences::temp
private

◆ ui

Ui::Preferences* Preferences::ui
private

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