Use camelCase for function names

master
PixlOne 5 years ago
parent 9272666ffe
commit 38dcc65d4b
  1. 10
      src/logid/Actions.cpp
  2. 8
      src/logid/Configuration.cpp
  3. 34
      src/logid/Device.cpp
  4. 16
      src/logid/Device.h
  5. 4
      src/logid/DeviceFinder.cpp
  6. 4
      src/logid/EvdevDevice.cpp
  7. 4
      src/logid/EvdevDevice.h
  8. 2
      src/logid/logid.cpp
  9. 10
      src/logid/util.cpp
  10. 10
      src/logid/util.h

@ -62,14 +62,14 @@ void KeyAction::press()
{
//KeyPress event for each in keys
for(unsigned int i : keys)
global_evdev->send_event(EV_KEY, i, 1);
global_evdev->sendEvent(EV_KEY, i, 1);
}
void KeyAction::release()
{
//KeyRelease event for each in keys
for(unsigned int i : keys)
global_evdev->send_event(EV_KEY, i, 0);
global_evdev->sendEvent(EV_KEY, i, 0);
}
void GestureAction::press()
@ -89,7 +89,7 @@ void GestureAction::move(HIDPP20::IReprogControlsV4::Move m)
if(g != gestures.end())
{
if (g->second->mode == GestureMode::Axis)
global_evdev->move_axis(g->second->axis, abs(m.y) * g->second->axis_multiplier);
global_evdev->moveAxis(g->second->axis, abs(m.y) * g->second->axis_multiplier);
if (g->second->mode == GestureMode::OnFewPixels)
{
g->second->per_pixel_mod += abs(m.y);
@ -108,7 +108,7 @@ void GestureAction::move(HIDPP20::IReprogControlsV4::Move m)
if(g != gestures.end())
{
if (g->second->mode == GestureMode::Axis)
global_evdev->move_axis(g->second->axis, abs(m.x) * g->second->axis_multiplier);
global_evdev->moveAxis(g->second->axis, abs(m.x) * g->second->axis_multiplier);
if (g->second->mode == GestureMode::OnFewPixels)
{
g->second->per_pixel_mod += abs(m.x);
@ -128,7 +128,7 @@ void GestureAction::release()
held = false;
Direction direction;
if(abs(x) < 50 && abs(y) < 50) direction = Direction::None;
else direction = get_direction(x, y);
else direction = getDirection(x, y);
x = 0;
y = 0;

@ -213,7 +213,7 @@ DeviceConfig::DeviceConfig(const libconfig::Setting &root)
{
std::string action_type_str;
action_config->lookupValue("type", action_type_str);
action_type = string_to_action(action_type_str);
action_type = stringToAction(action_type_str);
}
catch(SettingNotFoundException &e)
{
@ -285,7 +285,7 @@ ButtonAction* logid::parse_action(Action type, const Setting* action_config, boo
try
{
gesture_config.lookupValue("direction", direction_str);
direction = string_to_direction(direction_str);
direction = stringToDirection(direction_str);
}
catch(SettingNotFoundException &e)
{
@ -309,7 +309,7 @@ ButtonAction* logid::parse_action(Action type, const Setting* action_config, boo
{
std::string mode_str;
gesture_config.lookupValue("mode", mode_str);
mode = string_to_gesturemode(mode_str);
mode = stringToGestureMode(mode_str);
}
catch (SettingNotFoundException &e)
{
@ -381,7 +381,7 @@ ButtonAction* logid::parse_action(Action type, const Setting* action_config, boo
{
std::string type_str;
g_action->lookupValue("type", type_str);
g_type = string_to_action(type_str);
g_type = stringToAction(type_str);
}
catch(SettingNotFoundException &e)
{

@ -45,7 +45,7 @@ bool Device::init()
catch(HIDPP20::Error &e) { return false; }
name = hidpp_dev->name();
features = get_features();
features = getFeatures();
// Set config, if none is found for this device then use default
if(global_config->devices.find(name) == global_config->devices.end())
log_printf(INFO, "Device %s not configured, using default config.", hidpp_dev->name().c_str());
@ -91,19 +91,19 @@ void Device::configure()
goto ret;
// Set DPI if it is configured
if(config->dpi != nullptr)
set_dpi(*config->dpi);
setDPI(*config->dpi);
if(disconnected)
goto ret;
// Set Smartshift if it is configured
if(config->smartshift != nullptr)
set_smartshift(*config->smartshift);
setSmartShift(*config->smartshift);
if(disconnected)
goto ret;
// Set Hires Scroll if it is configured
if(config->hiresscroll != nullptr)
set_hiresscroll(*config->hiresscroll);
setHiresScroll(*config->hiresscroll);
}
catch(HIDPP10::Error &e)
{
@ -168,7 +168,7 @@ void Device::divert_buttons()
}
}
void Device::set_smartshift(HIDPP20::ISmartShift::SmartshiftStatus ops)
void Device::setSmartShift(HIDPP20::ISmartShift::SmartshiftStatus ops)
{
try
{
@ -187,7 +187,7 @@ void Device::set_smartshift(HIDPP20::ISmartShift::SmartshiftStatus ops)
}
}
void Device::set_hiresscroll(uint8_t ops)
void Device::setHiresScroll(uint8_t ops)
{
try
{
@ -206,7 +206,7 @@ void Device::set_hiresscroll(uint8_t ops)
}
}
void Device::set_dpi(int dpi)
void Device::setDPI(int dpi)
{
if(disconnected) return;
HIDPP20::IAdjustableDPI iad(hidpp_dev);
@ -215,7 +215,7 @@ void Device::set_dpi(int dpi)
catch (HIDPP20::Error &e) { log_printf(ERROR, "Error while setting DPI: %s", e.what()); }
}
void Device::wait_for_receiver()
void Device::waitForReceiver()
{
while(true)
{
@ -275,6 +275,8 @@ bool Device::testConnection()
}
i++;
} while(i < MAX_CONNECTION_TRIES);
return false;
}
void ButtonHandler::handleEvent (const HIDPP::Report &event)
@ -287,7 +289,7 @@ void ButtonHandler::handleEvent (const HIDPP::Report &event)
if (states.empty())
{
for (uint16_t i : new_states)
std::thread{[=]() { dev->press_button(i); }}.detach();
std::thread{[=]() { dev->pressButton(i); }}.detach();
states = new_states;
break;
}
@ -300,9 +302,9 @@ void ButtonHandler::handleEvent (const HIDPP::Report &event)
if (std::find(new_states.begin(), new_states.end(), i) != new_states.end())
{
if (std::find(states.begin(), states.end(), i) == states.end())
std::thread{[=]() { dev->press_button(i); }}.detach();
std::thread{[=]() { dev->pressButton(i); }}.detach();
} else
std::thread{[=]() { dev->release_button(i); }}.detach();
std::thread{[=]() { dev->releaseButton(i); }}.detach();
}
states = new_states;
break;
@ -312,7 +314,7 @@ void ButtonHandler::handleEvent (const HIDPP::Report &event)
auto raw_xy = HIDPP20::IReprogControlsV4::divertedRawXYEvent(event);
for(uint16_t i : states)
std::thread{[=]() { dev->move_diverted(i, raw_xy); }}.detach();
std::thread{[=]() { dev->moveDiverted(i, raw_xy); }}.detach();
break;
}
default:
@ -458,7 +460,7 @@ void Device::stop()
listener->stop();
}
void Device::press_button(uint16_t cid)
void Device::pressButton(uint16_t cid)
{
if(config->actions.find(cid) == config->actions.end())
{
@ -468,7 +470,7 @@ void Device::press_button(uint16_t cid)
config->actions.find(cid)->second->press();
}
void Device::release_button(uint16_t cid)
void Device::releaseButton(uint16_t cid)
{
if(config->actions.find(cid) == config->actions.end())
{
@ -478,7 +480,7 @@ void Device::release_button(uint16_t cid)
config->actions.find(cid)->second->release();
}
void Device::move_diverted(uint16_t cid, HIDPP20::IReprogControlsV4::Move m)
void Device::moveDiverted(uint16_t cid, HIDPP20::IReprogControlsV4::Move m)
{
auto action = config->actions.find(cid);
if(action == config->actions.end())
@ -493,7 +495,7 @@ void Device::move_diverted(uint16_t cid, HIDPP20::IReprogControlsV4::Move m)
}
}
std::map<uint16_t, uint8_t> Device::get_features()
std::map<uint16_t, uint8_t> Device::getFeatures()
{
std::map<uint16_t, uint8_t> _features;
HIDPP20::IFeatureSet ifs (hidpp_dev);

@ -30,16 +30,16 @@ namespace logid
void configure();
void reset();
void press_button(uint16_t cid);
void release_button(uint16_t cid);
void move_diverted(uint16_t cid, HIDPP20::IReprogControlsV4::Move move);
void pressButton(uint16_t cid);
void releaseButton(uint16_t cid);
void moveDiverted(uint16_t cid, HIDPP20::IReprogControlsV4::Move move);
void wait_for_receiver();
void waitForReceiver();
void start();
void stop();
bool testConnection();
std::map<uint16_t, uint8_t> get_features();
std::map<uint16_t, uint8_t> getFeatures();
std::map<uint16_t, uint8_t> features;
@ -58,9 +58,9 @@ namespace logid
EventListener* listener;
void divert_buttons();
void set_smartshift(HIDPP20::ISmartShift::SmartshiftStatus ops);
void set_hiresscroll(uint8_t flags);
void set_dpi(int dpi);
void setSmartShift(HIDPP20::ISmartShift::SmartshiftStatus ops);
void setHiresScroll(uint8_t flags);
void setDPI(int dpi);
};
class EventHandler

@ -15,7 +15,7 @@
#include "util.h"
#include "Device.h"
#define NON_WIRELESS_DEV(index) (index) == HIDPP::DefaultDevice ? "default" : "corderd"
#define NON_WIRELESS_DEV(index) (index) == HIDPP::DefaultDevice ? "default" : "corded"
using namespace logid;
@ -68,7 +68,7 @@ Device* DeviceFinder::insertNewReceiverDevice(const std::string &path, HIDPP::De
path_bucket->second.emplace(index, ConnectedDevice{
device,
std::thread([device]() {
device->wait_for_receiver();
device->waitForReceiver();
})
});
this->devices_mutex.unlock();

@ -24,13 +24,13 @@ EvdevDevice::EvdevDevice(const char* name)
throw std::system_error(-err, std::generic_category());
}
void EvdevDevice::move_axis(unsigned int axis, int movement)
void EvdevDevice::moveAxis(unsigned int axis, int movement)
{
libevdev_uinput_write_event(ui_device, EV_REL, axis, movement);
libevdev_uinput_write_event(ui_device, EV_SYN, SYN_REPORT, 0);
}
void EvdevDevice::send_event(unsigned int type, unsigned int code, int value)
void EvdevDevice::sendEvent(unsigned int type, unsigned int code, int value)
{
libevdev_uinput_write_event(ui_device, type, code, value);
libevdev_uinput_write_event(ui_device, EV_SYN, SYN_REPORT, 0);

@ -13,9 +13,9 @@ namespace logid
~EvdevDevice();
void move_axis(unsigned int axis, int movement);
void moveAxis(unsigned int axis, int movement);
void send_event(unsigned int type, unsigned int code, int value);
void sendEvent(unsigned int type, unsigned int code, int value);
libevdev *device;
libevdev_uinput *ui_device;

@ -75,7 +75,7 @@ int main(int argc, char** argv)
break;
}
std::string loglevel = argv[i];
try { global_verbosity = string_to_loglevel(argv[i]); }
try { global_verbosity = stringToLogLevel(argv[i]); }
catch (std::invalid_argument &e)
{
if (argv[i][0] == '-')

@ -34,7 +34,7 @@ const char* logid::level_prefix(LogLevel level)
return "DEBUG";
}
Direction logid::get_direction(int x, int y)
Direction logid::getDirection(int x, int y)
{
if(x == 0 && y == 0) return Direction::None;
@ -61,7 +61,7 @@ Direction logid::get_direction(int x, int y)
return Direction::None;
}
Direction logid::string_to_direction(std::string s)
Direction logid::stringToDirection(std::string s)
{
const char* original_str = s.c_str();
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
@ -77,7 +77,7 @@ Direction logid::string_to_direction(std::string s)
throw std::invalid_argument(s + " is an invalid direction.");
}
GestureMode logid::string_to_gesturemode(std::string s)
GestureMode logid::stringToGestureMode(std::string s)
{
const char* original_str = s.c_str();
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
@ -95,7 +95,7 @@ GestureMode logid::string_to_gesturemode(std::string s)
return GestureMode::OnRelease;
}
Action logid::string_to_action(std::string s)
Action logid::stringToAction(std::string s)
{
std::string original_str = s;
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
@ -111,7 +111,7 @@ Action logid::string_to_action(std::string s)
throw std::invalid_argument(original_str + " is an invalid action.");
}
LogLevel logid::string_to_loglevel(std::string s)
LogLevel logid::stringToLogLevel(std::string s)
{
std::string original_str = s;
std::transform(s.begin(), s.end(), s.begin(), ::tolower);

@ -19,11 +19,11 @@ namespace logid
const char* level_prefix(LogLevel level);
Direction get_direction(int x, int y);
Direction string_to_direction(std::string s);
GestureMode string_to_gesturemode(std::string s);
Action string_to_action(std::string s);
LogLevel string_to_loglevel(std::string s);
Direction getDirection(int x, int y);
Direction stringToDirection(std::string s);
GestureMode stringToGestureMode(std::string s);
Action stringToAction(std::string s);
LogLevel stringToLogLevel(std::string s);
}
#endif //LOGID_UTIL_H
Loading…
Cancel
Save