Gui: [skip ci] improve whitespaces in GuiNativeEvent::tdx_drv_handler

This commit is contained in:
wmayer
2022-07-14 15:49:36 +02:00
parent 339bb73e9f
commit 2003cb7506

View File

@@ -45,85 +45,80 @@ With special thanks to marcxs for making the first steps
UInt16 Gui::GuiNativeEvent::tdxClientID = 0;
uint32_t Gui::GuiNativeEvent::lastButtons = 0;
/* ----------------------------------------------------------------------------
/* ----------------------------------------------------------------------------
Handler for driver events. This function is able to handle the events in
different ways: (1) re-package the events as Carbon events, (2) compute
them directly, (3) write the event info in a shared memory location for
usage by reader threads.
*/
void
Gui::GuiNativeEvent::tdx_drv_handler(io_connect_t connection,
natural_t messageType,
void *messageArgument)
{
*/
void
Gui::GuiNativeEvent::tdx_drv_handler(io_connect_t connection,
natural_t messageType,
void *messageArgument)
{
Q_UNUSED(connection)
//printf("tdx_drv_handler\n");
//printf("connection: %X\n", connection);
//printf("messageType %c%c%c%c\n", messageType/0x1000000, messageType/0x10000, messageType/0x100, messageType);
ConnexionDeviceStatePtr msg = (ConnexionDeviceStatePtr)messageArgument;
switch(messageType)
{
case kConnexionMsgDeviceState:
/* Device state messages are broadcast to all clients. It is up to
* the client to figure out if the message is meant for them. This
* is done by comparing the "client" id sent in the message to our
* assigned id when the connection to the driver was established.
*/
//printf("msg->client: %d, tdxClientID: %d\n", msg->client, tdxClientID);
if (msg->client == tdxClientID)
{
switch (msg->command)
{
case kConnexionCmdHandleAxis:
{
motionDataArray[0] = -msg->axis[0];
motionDataArray[1] = msg->axis[1];
motionDataArray[2] = msg->axis[2];
motionDataArray[3] = -msg->axis[3];
motionDataArray[4] = msg->axis[4];
motionDataArray[5] = msg->axis[5];
mainApp->postMotionEvent(motionDataArray);
break;
}
case kConnexionCmdHandleButtons:
{
//printf("value: %d\n", msg->value);
//printf("buttons: %u\n", msg->buttons);
uint32_t changedButtons = msg->buttons ^ lastButtons;
uint32_t pressedButtons = msg->buttons & changedButtons;
uint32_t releasedButtons = lastButtons & changedButtons;
for (uint8_t bt = 0; bt < 32; bt++)
{
if (pressedButtons & 1)
mainApp->postButtonEvent(bt, 1);
pressedButtons = pressedButtons>>1;
}
for (uint8_t bt = 0; bt < 32; bt++)
{
if (releasedButtons & 1)
mainApp->postButtonEvent(bt, 0);
releasedButtons = releasedButtons>>1;
}
lastButtons = msg->buttons;
break;
}
default:
break;
} /* switch */
}
switch(messageType) {
case kConnexionMsgDeviceState:
/* Device state messages are broadcast to all clients. It is up to
* the client to figure out if the message is meant for them. This
* is done by comparing the "client" id sent in the message to our
* assigned id when the connection to the driver was established.
*/
//printf("msg->client: %d, tdxClientID: %d\n", msg->client, tdxClientID);
if (msg->client == tdxClientID) {
switch (msg->command) {
case kConnexionCmdHandleAxis:
{
motionDataArray[0] = -msg->axis[0];
motionDataArray[1] = msg->axis[1];
motionDataArray[2] = msg->axis[2];
motionDataArray[3] = -msg->axis[3];
motionDataArray[4] = msg->axis[4];
motionDataArray[5] = msg->axis[5];
mainApp->postMotionEvent(motionDataArray);
break;
}
break;
case kConnexionCmdHandleButtons:
{
//printf("value: %d\n", msg->value);
//printf("buttons: %u\n", msg->buttons);
uint32_t changedButtons = msg->buttons ^ lastButtons;
uint32_t pressedButtons = msg->buttons & changedButtons;
uint32_t releasedButtons = lastButtons & changedButtons;
for (uint8_t bt = 0; bt < 32; bt++) {
if (pressedButtons & 1)
mainApp->postButtonEvent(bt, 1);
pressedButtons = pressedButtons >> 1;
}
for (uint8_t bt = 0; bt < 32; bt++) {
if (releasedButtons & 1)
mainApp->postButtonEvent(bt, 0);
releasedButtons = releasedButtons >> 1;
}
lastButtons = msg->buttons;
break;
}
default:
break;
} /* switch */
}
break;
default:
/* other messageTypes can happen and should be ignored */
break;
}
}
default:
/* other messageTypes can happen and should be ignored */
break;
}
}
Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
: GuiAbstractNativeEvent(app)
{