Skip to content

Commit

Permalink
Removed all references to uiApp. (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
avalonbits authored Apr 25, 2023
1 parent fd69e80 commit 1b2aa02
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 1,756 deletions.
24 changes: 5 additions & 19 deletions src/devdrivers/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ void Keyboard::begin(bool generateVirtualKeys, bool createVKQueue, int PS2Port)
m_capsLockLED = false;
m_scrollLockLED = false;

m_uiApp = nullptr;

reset();

enableVirtualKeys(generateVirtualKeys, createVKQueue);
Expand Down Expand Up @@ -534,11 +532,12 @@ void Keyboard::injectVirtualKey(VirtualKeyItem const & item, bool insert)

// has VK queue? Insert VK into it.
if (m_virtualKeyQueue) {
auto ticksToWait = (m_uiApp ? 0 : portMAX_DELAY); // 0, and not portMAX_DELAY to avoid uiApp locks
if (insert)
auto ticksToWait = portMAX_DELAY;
if (insert) {
xQueueSendToFront(m_virtualKeyQueue, &item, ticksToWait);
else
} else {
xQueueSendToBack(m_virtualKeyQueue, &item, ticksToWait);
}
}
}

Expand All @@ -562,24 +561,11 @@ void Keyboard::injectVirtualKey(VirtualKey virtualKey, bool keyDown, bool insert
}


// inject a virtual key item into virtual key queue calling injectVirtualKey() and into m_uiApp
// inject a virtual key item into virtual key queue calling injectVirtualKey().
void Keyboard::postVirtualKeyItem(VirtualKeyItem const & item)
{
// add into m_virtualKeyQueue and update m_VKMap
injectVirtualKey(item, false);

// need to send events to uiApp?
if (m_uiApp) {
uiEvent evt = uiEvent(nullptr, item.down ? UIEVT_KEYDOWN : UIEVT_KEYUP);
evt.params.key.VK = item.vk;
evt.params.key.ASCII = item.ASCII;
evt.params.key.LALT = item.LALT;
evt.params.key.RALT = item.RALT;
evt.params.key.CTRL = item.CTRL;
evt.params.key.SHIFT = item.SHIFT;
evt.params.key.GUI = item.GUI;
m_uiApp->postEvent(&evt);
}
}


Expand Down
14 changes: 1 addition & 13 deletions src/devdrivers/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

#include "fabglconf.h"
#include "comdrivers/ps2device.h"
#include "fabui.h"
#include "kbdlayouts.h"
#include "codepages.h"

Expand All @@ -65,7 +64,7 @@ namespace fabgl {
* Example:
*
* fabgl::Keyboard Keyboard;
*
*
* // Setup pins GPIO33 for CLK and GPIO32 for DATA
* Keyboard.begin(GPIO_NUM_33, GPIO_NUM_32); // clk, dat
*
Expand Down Expand Up @@ -139,15 +138,6 @@ class Keyboard : public PS2Device {
*/
void enableVirtualKeys(bool generateVirtualKeys, bool createVKQueue);

/**
* @brief Sets current UI app
*
* To use this generateVirtualKeys must be true in begin().
*
* @param app The UI app where to send keyboard events
*/
void setUIApp(uiApp * app) { m_uiApp = app; }

/**
* @brief Sends a Reset command to the keyboard.
*
Expand Down Expand Up @@ -428,8 +418,6 @@ class Keyboard : public PS2Device {

KeyboardLayout const * m_layout;

uiApp * m_uiApp;

bool m_CTRL;
bool m_LALT;
bool m_RALT;
Expand Down
54 changes: 3 additions & 51 deletions src/devdrivers/mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ Mouse::Mouse()
m_movementAcceleration(180),
m_wheelAcceleration(60000),
m_absoluteQueue(nullptr),
m_updateDisplayController(nullptr),
m_uiApp(nullptr)
{
m_updateDisplayController(nullptr) {
}


Expand Down Expand Up @@ -191,7 +189,7 @@ bool Mouse::getNextDelta(MouseDelta * delta, int timeOutMS, bool requestResendOn
}


void Mouse::setupAbsolutePositioner(int width, int height, bool createAbsolutePositionsQueue, BitmappedDisplayController * updateDisplayController, uiApp * app)
void Mouse::setupAbsolutePositioner(int width, int height, bool createAbsolutePositionsQueue, BitmappedDisplayController * updateDisplayController)
{
if (m_area != Size(width, height)) {
m_area = Size(width, height);
Expand All @@ -206,8 +204,6 @@ void Mouse::setupAbsolutePositioner(int width, int height, bool createAbsolutePo

m_updateDisplayController = updateDisplayController;

m_uiApp = app;

if (createAbsolutePositionsQueue && m_absoluteQueue == nullptr) {
m_absoluteQueue = xQueueCreate(FABGLIB_MOUSE_EVENTS_QUEUE_SIZE, sizeof(MouseStatus));
}
Expand All @@ -217,7 +213,7 @@ void Mouse::setupAbsolutePositioner(int width, int height, bool createAbsolutePo
m_updateDisplayController->setMouseCursorPos(m_status.X, m_status.Y);
}

m_absoluteUpdate = (m_updateDisplayController || createAbsolutePositionsQueue || m_uiApp);
m_absoluteUpdate = (m_updateDisplayController || createAbsolutePositionsQueue);
}


Expand All @@ -229,7 +225,6 @@ void Mouse::terminateAbsolutePositioner()
}
m_absoluteUpdate = false;
m_updateDisplayController = nullptr;
m_uiApp = nullptr;
}


Expand Down Expand Up @@ -316,52 +311,9 @@ void Mouse::mouseUpdateTask(void * arg)
if (mouse->m_absoluteQueue) {
xQueueSend(mouse->m_absoluteQueue, &mouse->m_status, 0);
}

if (mouse->m_uiApp) {
// generate uiApp events
if (mouse->m_prevStatus.X != mouse->m_status.X || mouse->m_prevStatus.Y != mouse->m_status.Y) {
// X and Y movement: UIEVT_MOUSEMOVE
uiEvent evt = uiEvent(nullptr, UIEVT_MOUSEMOVE);
evt.params.mouse.status = mouse->m_status;
evt.params.mouse.changedButton = 0;
mouse->m_uiApp->postEvent(&evt);
}
if (mouse->m_status.wheelDelta != 0) {
// wheel movement: UIEVT_MOUSEWHEEL
uiEvent evt = uiEvent(nullptr, UIEVT_MOUSEWHEEL);
evt.params.mouse.status = mouse->m_status;
evt.params.mouse.changedButton = 0;
mouse->m_uiApp->postEvent(&evt);
}
if (mouse->m_prevStatus.buttons.left != mouse->m_status.buttons.left) {
// left button: UIEVT_MOUSEBUTTONDOWN, UIEVT_MOUSEBUTTONUP
uiEvent evt = uiEvent(nullptr, mouse->m_status.buttons.left ? UIEVT_MOUSEBUTTONDOWN : UIEVT_MOUSEBUTTONUP);
evt.params.mouse.status = mouse->m_status;
evt.params.mouse.changedButton = 1;
mouse->m_uiApp->postEvent(&evt);
}
if (mouse->m_prevStatus.buttons.middle != mouse->m_status.buttons.middle) {
// middle button: UIEVT_MOUSEBUTTONDOWN, UIEVT_MOUSEBUTTONUP
uiEvent evt = uiEvent(nullptr, mouse->m_status.buttons.middle ? UIEVT_MOUSEBUTTONDOWN : UIEVT_MOUSEBUTTONUP);
evt.params.mouse.status = mouse->m_status;
evt.params.mouse.changedButton = 2;
mouse->m_uiApp->postEvent(&evt);
}
if (mouse->m_prevStatus.buttons.right != mouse->m_status.buttons.right) {
// right button: UIEVT_MOUSEBUTTONDOWN, UIEVT_MOUSEBUTTONUP
uiEvent evt = uiEvent(nullptr, mouse->m_status.buttons.right ? UIEVT_MOUSEBUTTONDOWN : UIEVT_MOUSEBUTTONUP);
evt.params.mouse.status = mouse->m_status;
evt.params.mouse.changedButton = 3;
mouse->m_uiApp->postEvent(&evt);
}
}

}

} else {

xQueueOverwrite(mouse->m_receivedPacket, &mousePacket);

}

}
Expand Down
13 changes: 2 additions & 11 deletions src/devdrivers/mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "fabglconf.h"
#include "fabutils.h"
#include "comdrivers/ps2device.h"
#include "fabui.h"
#include "displaycontroller.h"


namespace fabgl {
Expand Down Expand Up @@ -271,14 +271,7 @@ class Mouse : public PS2Device {
*
* Mouse.setupAbsolutePositioner(Canvas.getWidth(), Canvas.getHeight(), true);
*/
void setupAbsolutePositioner(int width, int height, bool createAbsolutePositionsQueue, BitmappedDisplayController * updateDisplayController = nullptr, uiApp * app = nullptr);

/**
* @brief Sets current UI app
*
* @param app The UI app where to send mouse events
*/
void setUIApp(uiApp * app) { m_uiApp = app; }
void setupAbsolutePositioner(int width, int height, bool createAbsolutePositionsQueue, BitmappedDisplayController * updateDisplayController = nullptr);

/**
* @brief Terminates absolute position handler.
Expand Down Expand Up @@ -398,8 +391,6 @@ class Mouse : public PS2Device {
int m_wheelAcceleration; // reasonable values: 0...100000
QueueHandle_t m_absoluteQueue; // a queue of messages generated by updateAbsolutePosition()
BitmappedDisplayController * m_updateDisplayController;

uiApp * m_uiApp;
};


Expand Down
8 changes: 0 additions & 8 deletions src/fabgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,6 @@
#include "dispdrivers/vga4controller.h"
#include "dispdrivers/vga8controller.h"
#include "dispdrivers/vga16controller.h"
#include "dispdrivers/vgadirectcontroller.h"
#include "fabui.h"
#include "inputbox.h"
#include "comdrivers/ps2controller.h"
#include "comdrivers/tsi2c.h"
#include "devdrivers/keyboard.h"
Expand Down Expand Up @@ -363,7 +360,6 @@ using fabgl::KbdMode;
using fabgl::VirtualKey;
using fabgl::VirtualKeyItem;
using fabgl::FileBrowser;
using fabgl::ModalWindowState;
using fabgl::Canvas;
using fabgl::PixelFormat;
using fabgl::RGB222;
Expand All @@ -379,7 +375,3 @@ using fabgl::CharStyle;
using fabgl::TerminalTransition;
using fabgl::SupportedLayouts;
using fabgl::CoreUsage;
using fabgl::InputResult;
using fabgl::InputBox;


2 changes: 1 addition & 1 deletion src/fabglconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
#define VGA_512x384_60Hz "\"512x384@60Hz\" 32.5 512 524 592 672 384 385 388 403 -HSync -VSync DoubleScan"

/** Modeline for 640x480@60Hz resolution */
#define QSVGA_640x480_60Hz "\"640x480@60Hz\" 25.175 640 656 752 800 480 490 492 525 -HSync -VSync"
#define VGA_640x480_60Hz "\"640x480@60Hz\" 25.175 640 656 752 800 480 490 492 525 -HSync -VSync"

/** Modeline for 640x512@60Hz resolution (for pixel perfect 1280x1024 double scan resolution) */
#define QSVGA_640x512_60Hz "\"640x512@60Hz\" 54 640 664 720 844 512 513 515 533 -HSync -VSync DoubleScan"
Expand Down
Loading

0 comments on commit 1b2aa02

Please sign in to comment.