Skip to content
This repository has been archived by the owner on Aug 31, 2020. It is now read-only.

Commit

Permalink
issue #35 - too many static_casts
Browse files Browse the repository at this point in the history
  • Loading branch information
juliagoda committed Oct 16, 2018
1 parent 08f73f1 commit 910b7b4
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 89 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ endif(UNIX)
target_link_libraries (antimicro Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Network)
endif(UNIX)

# target_compile_definitions(antimicro PUBLIC QT_DEBUG_NO_OUTPUT) # should be commented during development
target_compile_definitions(antimicro PUBLIC QT_DEBUG_NO_OUTPUT) # should be commented during development


# Add link libraries.
Expand Down
2 changes: 1 addition & 1 deletion src/addeditautoprofiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void AddEditAutoProfileDialog::checkForGrabbedWindow(UnixCaptureWindowUtility* u
qDebug() << "ORIGINAL: " << QString::number(targetWindow, 16);
#endif

long tempWindow = static_cast<long>(X11Extras::getInstance()->findClientWindow(static_cast<Window>(targetWindow)));
long tempWindow = X11Extras::getInstance()->findClientWindow(targetWindow);
if (tempWindow > 0)
{
targetWindow = tempWindow;
Expand Down
2 changes: 1 addition & 1 deletion src/advancebuttondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ AdvanceButtonDialog::AdvanceButtonDialog(JoyButton *button, QWidget *parent) :
if ((m_button->getSetSelection() > -1) &&
(m_button->getChangeSetCondition() != JoyButton::SetChangeDisabled))
{
int selectIndex = static_cast<int>(m_button->getChangeSetCondition());
int selectIndex = m_button->getChangeSetCondition();
selectIndex += m_button->getSetSelection() * 3;

if (m_button->getOriginSet() < m_button->getSetSelection()) selectIndex -= 3;
Expand Down
4 changes: 2 additions & 2 deletions src/autoprofilewatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ void AutoProfileWatcher::runAppCheck()
nowWindowName = WinExtras::getCurrentWindowText();
#elif defined(Q_OS_UNIX)

long currentWindow = static_cast<long>(X11Extras::getInstance()->getWindowInFocus());
long currentWindow = X11Extras::getInstance()->getWindowInFocus();

if (currentWindow > 0)
{
long tempWindow = static_cast<long>(X11Extras::getInstance()->findParentClient(static_cast<Window>(currentWindow)));
long tempWindow = X11Extras::getInstance()->findParentClient(currentWindow);

if (tempWindow > 0) currentWindow = tempWindow;

Expand Down
4 changes: 2 additions & 2 deletions src/buttoneditdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ void ButtonEditDialog::keyReleaseEvent(QKeyEvent *event)
}
else if (ui->virtualKeyMouseTabWidget->isKeyboardTabVisible())
{
int controlcode = static_cast<int>(event->nativeScanCode());
int virtualactual = static_cast<int>(event->nativeVirtualKey());
int controlcode = event->nativeScanCode();
int virtualactual = event->nativeVirtualKey();

BaseEventHandler *handler = EventHandlerFactory::getInstance()->handler();

Expand Down
20 changes: 10 additions & 10 deletions src/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ void fakeAbsMouseCoordinates(double springX, double springY,
destMidWidth = destSpringWidth / 2;
destMidHeight = destSpringHeight / 2;

finalx = (screenMidwidth + (static_cast<int>(springX) * destMidWidth) + deskRect.x());
finaly = (screenMidheight + (static_cast<int>(springY) * destMidHeight) + deskRect.y());
finalx = (screenMidwidth + (springX * destMidWidth) + deskRect.x());
finaly = (screenMidheight + (springY * destMidHeight) + deskRect.y());
}

// Create the event used by the operating system.
Expand Down Expand Up @@ -213,10 +213,10 @@ void sendSpringEventRefactor(PadderCommon::springModeInfo *fullSpring,
int yRelativeMoovCoor = 0;

if (relativeSpring->displacementX >= -1.0)
xRelativeMoovCoor = (static_cast<int>(relativeSpring->displacementX) * destRelativeWidth) / 2;
xRelativeMoovCoor = (relativeSpring->displacementX * destRelativeWidth) / 2;

if (relativeSpring->displacementY >= -1.0)
yRelativeMoovCoor = (static_cast<int>(relativeSpring->displacementY) * destRelativeHeight) / 2;
yRelativeMoovCoor = (relativeSpring->displacementY * destRelativeHeight) / 2;

xmovecoor += xRelativeMoovCoor;
ymovecoor += yRelativeMoovCoor;
Expand Down Expand Up @@ -351,8 +351,8 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
}
}

xmovecoor = (fullSpring->displacementX >= -1.0) ? (midwidth + (static_cast<int>(fullSpring->displacementX) * destMidWidth) + deskRect.x()): pivotX;
ymovecoor = (fullSpring->displacementY >= -1.0) ? (midheight + (static_cast<int>(fullSpring->displacementY) * destMidHeight) + deskRect.y()) : pivotY;
xmovecoor = (fullSpring->displacementX >= -1.0) ? (midwidth + (fullSpring->displacementX * destMidWidth) + deskRect.x()): pivotX;
ymovecoor = (fullSpring->displacementY >= -1.0) ? (midheight + (fullSpring->displacementY * destMidHeight) + deskRect.y()) : pivotY;

int fullSpringDestX = xmovecoor;
int fullSpringDestY = ymovecoor;
Expand All @@ -369,10 +369,10 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
int yRelativeMoovCoor = 0;

if (relativeSpring->displacementX >= -1.0)
xRelativeMoovCoor = (static_cast<int>(relativeSpring->displacementX) * destRelativeWidth) / 2;
xRelativeMoovCoor = (relativeSpring->displacementX * destRelativeWidth) / 2;

if (relativeSpring->displacementY >= -1.0)
yRelativeMoovCoor = (static_cast<int>(relativeSpring->displacementY) * destRelativeHeight) / 2;
yRelativeMoovCoor = (relativeSpring->displacementY * destRelativeHeight) / 2;

xmovecoor += xRelativeMoovCoor;
ymovecoor += yRelativeMoovCoor;
Expand Down Expand Up @@ -686,7 +686,7 @@ QString keycodeToKeyString(int keycode, int alias)
else
{
XKeyPressedEvent tempevent;
tempevent.keycode = static_cast<unsigned int>(keycode);
tempevent.keycode = keycode;
tempevent.type = KeyPress;
tempevent.display = display;
tempevent.state = 0;
Expand Down Expand Up @@ -768,7 +768,7 @@ int X11KeyCodeToX11KeySym(int keycode)
#ifdef WITH_X11

Display* display = X11Extras::getInstance()->display();
return static_cast<int>(XkbKeycodeToKeysym(display, static_cast<KeyCode>(keycode), 0, 0));
return XkbKeycodeToKeysym(display, static_cast<KeyCode>(keycode), 0, 0);

#else

Expand Down
24 changes: 12 additions & 12 deletions src/eventhandlers/uinputeventhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void UInputEventHandler::sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed)
}
}

write_uinput_event(mouseFileHandler, EV_KEY, static_cast<int>(tempcode), pressed ? 1 : 0);
write_uinput_event(mouseFileHandler, EV_KEY, tempcode, pressed ? 1 : 0);
}
else if (code == 4)
{
Expand Down Expand Up @@ -298,8 +298,8 @@ void UInputEventHandler::sendMouseSpringEvent(int xDis, int yDis,
double midwidth = width / 2.0;
double midheight = height / 2.0;

int fx = static_cast<int>(ceil(32767 * ((xDis - midwidth) / midwidth)));
int fy = static_cast<int>(ceil(32767 * ((yDis - midheight) / midheight)));
int fx = ceil(32767 * ((xDis - midwidth) / midwidth));
int fy = ceil(32767 * ((yDis - midheight) / midheight));
sendMouseAbsEvent(fx, fy, -1);
}
}
Expand All @@ -310,8 +310,8 @@ void UInputEventHandler::sendMouseSpringEvent(int xDis, int yDis)
if ((xDis >= -1.0) && (xDis <= 1.0) &&
(yDis >= -1.0) && (yDis <= 1.0))
{
int fx = static_cast<int>(ceil(32767 * xDis));
int fy = static_cast<int>(ceil(32767 * yDis));
int fx = ceil(32767 * xDis);
int fy = ceil(32767 * yDis);
sendMouseAbsEvent(fx, fy, -1);
}
}
Expand Down Expand Up @@ -499,8 +499,8 @@ void UInputEventHandler::write_uinput_event(int filehandle, int type,

memset(&ev, 0, sizeof(struct input_event));
gettimeofday(&ev.time, nullptr);
ev.type = static_cast<unsigned short>(type);
ev.code = static_cast<unsigned short>(code);
ev.type = type;
ev.code = code;
ev.value = value;

write(filehandle, &ev, sizeof(struct input_event));
Expand Down Expand Up @@ -574,11 +574,11 @@ void UInputEventHandler::sendTextEntryEvent(QString maintext)
{
QtX11KeyMapper::charKeyInformation tempX11 = nativeWinKeyMapper->getCharKeyInformation(maintext.at(i));
tempX11.virtualkey = X11Extras::getInstance()->getGroup1KeySym(tempX11.virtualkey);
unsigned int tempQtKey = static_cast<unsigned int>(nativeWinKeyMapper->returnQtKey(tempX11.virtualkey));
unsigned int tempQtKey = nativeWinKeyMapper->returnQtKey(tempX11.virtualkey);

if (tempQtKey > 0)
{
temp.virtualkey = keymapper->returnVirtualKey(static_cast<int>(tempQtKey));
temp.virtualkey = keymapper->returnVirtualKey(tempQtKey);
temp.modifiers = tempX11.modifiers;
}
else
Expand All @@ -601,7 +601,7 @@ void UInputEventHandler::sendTextEntryEvent(QString maintext)
testAndAppend(temp.modifiers.testFlag(Qt::MetaModifier), tempList, KEY_LEFTMETA);
}

tempList.append(static_cast<unsigned int>(temp.virtualkey));
tempList.append(temp.virtualkey);
write_uinput_event(keyboardFileHandler, EV_KEY, temp.virtualkey, 1, true);
}

Expand All @@ -614,7 +614,7 @@ void UInputEventHandler::sendTextEntryEvent(QString maintext)
{
unsigned int currentcode = tempiter.previous();
bool sync = !tempiter.hasPrevious() ? true : false;
write_uinput_event(keyboardFileHandler, EV_KEY, static_cast<int>(currentcode), 0, sync);
write_uinput_event(keyboardFileHandler, EV_KEY, currentcode, 0, sync);
}
}
}
Expand All @@ -627,7 +627,7 @@ void UInputEventHandler::testAndAppend(bool tested, QList<unsigned int>& tempLis
if (tested)
{
tempList.append(key);
write_uinput_event(keyboardFileHandler, EV_KEY, static_cast<int>(key), 1, false);
write_uinput_event(keyboardFileHandler, EV_KEY, key, 1, false);
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/eventhandlers/xtesteventhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void XTestEventHandler::sendKeyboardEvent(JoyButtonSlot *slot, bool pressed)

if (tempcode > 0)
{
XTestFakeKeyEvent(display, static_cast<unsigned int>(tempcode), pressed, 0);
XTestFakeKeyEvent(display, tempcode, pressed, 0);
XFlush(display);
}
}
Expand All @@ -102,7 +102,7 @@ void XTestEventHandler::sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed)

if (device == JoyButtonSlot::JoyMouseButton)
{
XTestFakeButtonEvent(display, static_cast<unsigned int>(code), pressed, 0);
XTestFakeButtonEvent(display, code, pressed, 0);
XFlush(display);
}
}
Expand Down Expand Up @@ -168,35 +168,35 @@ void XTestEventHandler::sendTextEntryEvent(QString maintext)
{
int shiftcode = XKeysymToKeycode(display, XK_Shift_L);
int modifiercode = shiftcode;
XTestFakeKeyEvent(display, static_cast<unsigned int>(modifiercode), 1, 0);
XTestFakeKeyEvent(display, modifiercode, 1, 0);
tempList.append(modifiercode);
}

if ((temp.modifiers != Qt::NoModifier) && temp.modifiers.testFlag(Qt::ControlModifier))
{
int controlcode = XKeysymToKeycode(display, XK_Control_L);
int modifiercode = controlcode;
XTestFakeKeyEvent(display, static_cast<unsigned int>(modifiercode), 1, 0);
XTestFakeKeyEvent(display, modifiercode, 1, 0);
tempList.append(modifiercode);
}

if ((temp.modifiers != Qt::NoModifier) && temp.modifiers.testFlag(Qt::AltModifier))
{
int altcode = XKeysymToKeycode(display, XK_Alt_L);
int modifiercode = altcode;
XTestFakeKeyEvent(display, static_cast<unsigned int>(modifiercode), 1, 0);
XTestFakeKeyEvent(display, modifiercode, 1, 0);
tempList.append(modifiercode);
}

if ((temp.modifiers != Qt::NoModifier) && temp.modifiers.testFlag(Qt::MetaModifier))
{
int metacode = XKeysymToKeycode(display, XK_Meta_L);
int modifiercode = metacode;
XTestFakeKeyEvent(display, static_cast<unsigned int>(modifiercode), 1, 0);
XTestFakeKeyEvent(display, modifiercode, 1, 0);
tempList.append(modifiercode);
}

XTestFakeKeyEvent(display, static_cast<unsigned int>(tempcode), 1, 0);
XTestFakeKeyEvent(display, tempcode, 1, 0);
tempList.append(tempcode);

XFlush(display);
Expand All @@ -209,7 +209,7 @@ void XTestEventHandler::sendTextEntryEvent(QString maintext)
while (tempiter.hasPrevious())
{
int currentcode = tempiter.previous();
XTestFakeKeyEvent(display, static_cast<unsigned int>(currentcode), 0, 0);
XTestFakeKeyEvent(display, currentcode, 0, 0);
}

XFlush(display);
Expand Down
4 changes: 2 additions & 2 deletions src/inputdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
{
if (axis->getThrottle() != static_cast<int>(JoyAxis::NormalThrottle))
{
event.jaxis.value = static_cast<short>(axis->getProperReleaseValue());
event.jaxis.value = axis->getProperReleaseValue();
}
}
}
Expand Down Expand Up @@ -900,7 +900,7 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
if ((event.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT) ||
(event.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT))
{
event.caxis.value = static_cast<short>(axis->getProperReleaseValue());
event.caxis.value = axis->getProperReleaseValue();
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/joybutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4376,10 +4376,10 @@ void JoyButton::moveMouseCursor(int &movedX, int &movedY, int &movedElapsed, QLi
// This check is more of a precaution than anything. No need to cause
// a sync to happen when not needed.
if (!qFuzzyIsNull(adjustedX) || !qFuzzyIsNull(adjustedY))
sendevent(static_cast<int>(adjustedX), static_cast<int>(adjustedY));
sendevent(adjustedX, adjustedY);

movedX = static_cast<int>(adjustedX);
movedY = static_cast<int>(adjustedY);
movedX = adjustedX;
movedY = adjustedY;
}
else
{
Expand Down Expand Up @@ -4902,7 +4902,7 @@ int JoyButton::calculateFinalMouseSpeed(JoyMouseCurve curve, int value, const fl
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

int result = static_cast<int>(joyspeed) * value;
int result = joyspeed * value;

switch (curve)
{
Expand Down
2 changes: 1 addition & 1 deletion src/joybuttontypes/joycontrolstickbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ JoyControlStickButton::JoyControlStickButton(JoyControlStick *stick, int index,


JoyControlStickButton::JoyControlStickButton(JoyControlStick *stick, JoyStickDirectionsType::JoyStickDirections index, int originset, SetJoystick *parentSet, QObject *parent) :
JoyGradientButton(static_cast<int>(index), originset, parentSet, parent)
JoyGradientButton(index, originset, parentSet, parent)
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

Expand Down
Loading

0 comments on commit 910b7b4

Please sign in to comment.