-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pointer mode (Zoom) changes on double click (same behavior as of official software) #54
Conversation
Thanks for the pull request. 👍 While the idea of predefined spotlight settings (you call it pointer modes) is good, Code Review follows probably tonight. (Central European Time) |
A clarification: predefined spotlight settings does not mean hardcoded. I want to provide user the option that they can define three different set of settings -- Highlight, SpotLight(Zoom) and Digital Laser. The mode can customized by user. No, We are not copying everything. The idea of customized key event on Next/Back press is unique to In a way, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, so I had a quick review.
Please don't be put off comments on code style and indentation. But I like to be a bit picky here, since I really much like a code base that follows the same style (Even though I did not put up a style guide).
Your pull request is still really appreciated.
For the UInputDevice
class please see comments about making it a member instead of a Singleton - I want to avoid Singletons as much as global variables. Use them only if absolutely necessary.
src/uinputevents.h
Outdated
|
||
using namespace std; | ||
|
||
class uinputEvents; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary.
Thanks for quick review. I will be able to resolve them in the evening (IST). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See individual comments. Especially the memory leak.
@@ -87,15 +88,35 @@ namespace { | |||
Spotlight::Spotlight(QObject* parent) | |||
: QObject(parent) | |||
, m_activeTimer(new QTimer(this)) | |||
, m_clickTimer(new QTimer(this)) | |||
, m_virtualDevice(new VirtualDevice) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak, object will never get destroyed. m_virtualDevice
member should be of type QScopedPointer
or std::unique_ptr
@@ -62,4 +66,7 @@ class Spotlight : public QObject | |||
std::map<QString, QScopedPointer<QSocketNotifier>> m_eventNotifiers; | |||
QTimer* m_activeTimer; | |||
bool m_spotActive = false; | |||
bool m_clicked = false; | |||
QTimer* m_clickTimer; | |||
VirtualDevice* m_virtualDevice; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak. m_virtualDevice
member should be of type QScopedPointer
or std::unique_ptr
src/virtualdevice.h
Outdated
class VirtualDevice{ | ||
private: | ||
struct uinput_user_dev uinp; | ||
static int uinp_fd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, should be a regular memberstatic
int uinp_fd = -1;
|
||
// Setup uinput device that can send mouse and keyboard events. Logs the result too. | ||
void VirtualDevice::setupVirtualDevice() { | ||
int i=0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c-style ... remove .. use for (int i = 0; ....
instead
ioctl(uinp_fd, UI_SET_RELBIT, REL_X); | ||
ioctl(uinp_fd, UI_SET_RELBIT, REL_Y); | ||
|
||
for (i=0; i < 256; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use for (int i = 0; ....
instead
char msg[] = "A virtual device was not created. "\ | ||
"Some features like changing pointer modes might not work.\n\n"\ | ||
"Please check if uinput kernel module is loaded."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't be picked up by Qt's lupdate
tool.
Use const auto msg = tr("...");
and then the msg
variable directly for QMessagebox
#include <linux/uinput.h> | ||
#include <unistd.h> | ||
|
||
#include <QDebug> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to include this in the header
class VirtualDevice{ | ||
private: | ||
struct uinput_user_dev uinp; | ||
int uinp_fd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set default value
int uinp_fd = -1;
if (ioctl(uinp_fd, UI_DEV_CREATE)) { | ||
qDebug("Unable to create Virtual (UINPUT) device."); | ||
deviceCreated = false; | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close uinp_fd, otherwise it will not get closed.
Alternative: check in constructor if uinp_fd >= 0
and close
I'd rather would merge your changes to a feature branch and then after all bugs and major issues are resolved merge it to |
Please make the pull request for |
Ok, I am making a pull request to feature/pointer-mode-uinput-dev. |
The Zoom is toggled if user double tap the pointer (top most) button (within 300ms; can be changed as it is part of Setting).
A major redesign of events handling has occurred. As it was necessary that the double click (and associated two clicks) events should not be passed to presentation so
projecteur
now grabs the input fromSpotLight
device. However, all other events (except Mouse Click) is passed again to the system by usinguinput
interface. The current redesign can help in giving solution to #43 without using a custom bash script.Double Click is not passed to system rather used for changing the mode of presenter (toggling Zoom Setting). This is same behaviour as official software.
Further Work: To introduce the third mode (Digital Laser) and additionally the provision for different options/setting for each of the mode.