2424#define RM1_BUTTONS " /dev/input/event1"
2525#define RM1_DIGITIZER " /dev/input/event0"
2626
27+ #define RMPP_TOUCHSCREEN " /dev/input/event3"
28+ #define RMPP_DIGITIZER " /dev/input/event2"
29+
2730#define RM1_MAX_DIGI_X 20967
2831#define RM1_MAX_DIGI_Y 15725
2932#define RMPP_MAX_DIGI_X 11180
4245#define RMPP_MAX_TOUCH_Y 2832
4346#define RMPP_MAX_PRESSURE 255
4447
45- const char *UNBOUND_INPUTS [] = { " /dev/input/event3" , };
46-
4748extern qtfb::ClientConnection *clientConnection;
49+ extern int shimInputType;
4850
4951struct TouchSlotState {
5052 int x, y;
@@ -111,6 +113,37 @@ static void pollInputUpdates() {
111113 if (clientConnection->pollServerPacket (message) && message.type == MESSAGE_USERINPUT ) {
112114 // Did we get a packet?
113115 char state_a;
116+
117+ int xTranslate, yTranslate, dTranslate;
118+ switch (shimInputType) {
119+ case SHIM_INPUT_RM1 :
120+ switch (message.userInput .inputType & 0xF0 ) {
121+ case INPUT_TOUCH_PRESS :
122+ xTranslate = RM1_MAX_TOUCH_X - ((message.userInput .x * RM1_MAX_TOUCH_X ) / (int ) clientConnection->width ());
123+ yTranslate = RM1_MAX_TOUCH_Y - ((message.userInput .y * RM1_MAX_TOUCH_Y ) / (int ) clientConnection->height ());
124+ break ;
125+ case INPUT_PEN_PRESS :
126+ xTranslate = RM1_MAX_DIGI_X - ((message.userInput .y * RM1_MAX_DIGI_X ) / clientConnection->height ());
127+ yTranslate = (message.userInput .x * RM1_MAX_DIGI_Y ) / clientConnection->width ();
128+ dTranslate = (message.userInput .d * 4096 ) / 100 ;
129+ break ;
130+ }
131+ break ;
132+ case SHIM_INPUT_RMPP :
133+ switch (message.userInput .inputType & 0xF0 ) {
134+ case INPUT_TOUCH_PRESS :
135+ xTranslate = ((message.userInput .x * RMPP_MAX_TOUCH_X ) / (int ) clientConnection->width ());
136+ yTranslate = ((message.userInput .y * RMPP_MAX_TOUCH_Y ) / (int ) clientConnection->height ());
137+ break ;
138+ case INPUT_PEN_PRESS :
139+ xTranslate = (message.userInput .x * RMPP_MAX_DIGI_X ) / clientConnection->width ();
140+ yTranslate = (message.userInput .y * RMPP_MAX_DIGI_Y ) / clientConnection->height ();
141+ dTranslate = (message.userInput .d * 255 ) / 100 ;
142+ break ;
143+ }
144+ break ;
145+ }
146+
114147 CERR << " [QTFB SHIM INPUT]: " << (int ) message.userInput .inputType << " , " << message.userInput .x << " , " << message.userInput .y << std::endl;
115148 switch (message.userInput .inputType ) {
116149 case INPUT_TOUCH_PRESS :
@@ -122,8 +155,8 @@ static void pollInputUpdates() {
122155 pushToAll (QUEUE_TOUCH , evt (EV_ABS , ABS_MT_TRACKING_ID , -1 ));
123156 sendpos:
124157 if (state_a != 0 ) {
125- pushToAll (QUEUE_TOUCH , evt (EV_ABS , ABS_MT_POSITION_X , RM1_MAX_TOUCH_X - ((message. userInput . x * RM1_MAX_TOUCH_X ) / ( int ) clientConnection-> width ()) ));
126- pushToAll (QUEUE_TOUCH , evt (EV_ABS , ABS_MT_POSITION_Y , RM1_MAX_TOUCH_Y - ((message. userInput . y * RM1_MAX_TOUCH_Y ) / ( int ) clientConnection-> height ()) ));
158+ pushToAll (QUEUE_TOUCH , evt (EV_ABS , ABS_MT_POSITION_X , xTranslate ));
159+ pushToAll (QUEUE_TOUCH , evt (EV_ABS , ABS_MT_POSITION_Y , yTranslate ));
127160 }
128161 if (state_a == 1 || state_a == 0 ) {
129162 pushToAll (QUEUE_TOUCH , evt (EV_KEY , BTN_TOUCH , state_a));
@@ -146,9 +179,9 @@ static void pollInputUpdates() {
146179 case INPUT_PEN_UPDATE :
147180 pushToAll (QUEUE_PEN , evt (EV_KEY , BTN_TOOL_PEN , 1 ));
148181 pen_fall:
149- pushToAll (QUEUE_PEN , evt (EV_ABS , ABS_X , RM1_MAX_DIGI_X - ((message. userInput . y * RM1_MAX_DIGI_X ) / clientConnection-> height ()) ));
150- pushToAll (QUEUE_PEN , evt (EV_ABS , ABS_Y , (message. userInput . x * RM1_MAX_DIGI_Y ) / clientConnection-> width () ));
151- pushToAll (QUEUE_PEN , evt (EV_ABS , ABS_PRESSURE , (message. userInput . d * 4096 ) / 100 ));
182+ pushToAll (QUEUE_PEN , evt (EV_ABS , ABS_X , xTranslate ));
183+ pushToAll (QUEUE_PEN , evt (EV_ABS , ABS_Y , yTranslate ));
184+ pushToAll (QUEUE_PEN , evt (EV_ABS , ABS_PRESSURE , dTranslate ));
152185 pushToAll (QUEUE_PEN , evt (EV_SYN , SYN_REPORT , 0 ));
153186 break ;
154187 case INPUT_BTN_PRESS :
@@ -197,29 +230,38 @@ static int createInEventMap(int type, int flags) {
197230}
198231
199232int inputShimOpen (const char *file, int (*realOpen)(const char *name, int flags, mode_t mode), int flags, mode_t mode) {
200- if (strcmp (file, RM1_DIGITIZER ) == 0 ) {
201- int fd = createInEventMap (QUEUE_PEN , flags);
202- CERR << " Open digitizer " << fd << std::endl;
203- return fd;
204- }
233+ if (shimInputType == SHIM_INPUT_RM1 ) {
234+ if (strcmp (file, RM1_DIGITIZER ) == 0 ) {
235+ int fd = createInEventMap (QUEUE_PEN , flags);
236+ CERR << " Open digitizer " << fd << std::endl;
237+ return fd;
238+ }
205239
206- if (strcmp (file, RM1_TOUCHSCREEN ) == 0 ) {
207- int fd = createInEventMap (QUEUE_TOUCH , flags);
208- CERR << " Open touchscreen " << fd << std::endl;
209- return fd;
210- }
240+ if (strcmp (file, RM1_TOUCHSCREEN ) == 0 ) {
241+ int fd = createInEventMap (QUEUE_TOUCH , flags);
242+ CERR << " Open touchscreen " << fd << std::endl;
243+ return fd;
244+ }
211245
212- if (strcmp (file, RM1_BUTTONS ) == 0 ) {
213- int fd = createInEventMap (QUEUE_BUTTONS , flags);
214- CERR << " Open buttons " << fd << std::endl;
215- return fd;
216- }
246+ if (strcmp (file, RM1_BUTTONS ) == 0 ) {
247+ int fd = createInEventMap (QUEUE_BUTTONS , flags);
248+ CERR << " Open buttons " << fd << std::endl;
249+ return fd;
250+ }
251+ } else if (shimInputType == SHIM_INPUT_RMPP ) {
252+ if (strcmp (file, RMPP_DIGITIZER ) == 0 ) {
253+ int fd = createInEventMap (QUEUE_PEN , flags);
254+ CERR << " Open digitizer " << fd << std::endl;
255+ return fd;
256+ }
257+
258+ if (strcmp (file, RMPP_TOUCHSCREEN ) == 0 ) {
259+ int fd = createInEventMap (QUEUE_TOUCH , flags);
260+ CERR << " Open touchscreen " << fd << std::endl;
261+ return fd;
262+ }
217263
218- // for(int i = 0; i < sizeof(UNBOUND_INPUTS) / sizeof(const char *); i++) {
219- // if(strcmp(file, UNBOUND_INPUTS[i]) == 0) {
220- // return nullPipe.pipeRead;
221- // }
222- // }
264+ }
223265
224266 return INTERNAL_SHIM_NOT_APPLICABLE ;
225267}
0 commit comments